Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcvs2svn2006-02-17 15:20:47 +0000
committercvs2svn2006-02-17 15:20:47 +0000
commit6e9dab802e975eee66f802435d8043d204e32d11 (patch)
tree7b5bffc6c250c75bb3c5db6714bbf171879db428
parent86cd021e214806581937071df1ed1fb685e543d9 (diff)
downloadrt.equinox.bundles-6e9dab802e975eee66f802435d8043d204e32d11.tar.gz
rt.equinox.bundles-6e9dab802e975eee66f802435d8043d204e32d11.tar.xz
rt.equinox.bundles-6e9dab802e975eee66f802435d8043d204e32d11.zip
This commit was manufactured by cvs2svn to create branch 'M5_32_branch'.
Sprout from master 2006-02-17 15:20:45 UTC DJ Houghton <dj> 'Fixed javadoc.' Delete: bundles/org.eclipse.equinox.app/.classpath bundles/org.eclipse.equinox.app/.cvsignore bundles/org.eclipse.equinox.app/.project bundles/org.eclipse.equinox.app/.settings/org.eclipse.core.resources.prefs bundles/org.eclipse.equinox.app/.settings/org.eclipse.jdt.core.prefs bundles/org.eclipse.equinox.app/.settings/org.eclipse.jdt.ui.prefs bundles/org.eclipse.equinox.app/.settings/org.eclipse.pde.core.prefs bundles/org.eclipse.equinox.app/META-INF/MANIFEST.MF bundles/org.eclipse.equinox.app/about.html bundles/org.eclipse.equinox.app/build.properties bundles/org.eclipse.equinox.app/plugin.properties bundles/org.eclipse.equinox.app/plugin.xml bundles/org.eclipse.equinox.app/schema/applications.exsd bundles/org.eclipse.equinox.app/schema/containers.exsd bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/app/IAppContext.java bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/app/IApplication.java bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/app/IContainer.java bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/Activator.java bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/AppCommands.java bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/AppPersistenceUtil.java bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/ContainerManager.java bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/EclipseAppDescriptor.java bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/EclipseAppHandle.java bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/EclipseScheduledApplication.java bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/ErrorApplication.java bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/MainThreadApplication.java bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/MainThreadContainer.java bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/Messages.java bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/SingletonContainer.java bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/messages.properties bundles/org.eclipse.equinox.app/src/org/osgi/service/application/ApplicationAdminPermission.java bundles/org.eclipse.equinox.app/src/org/osgi/service/application/ApplicationDescriptor.java bundles/org.eclipse.equinox.app/src/org/osgi/service/application/ApplicationException.java bundles/org.eclipse.equinox.app/src/org/osgi/service/application/ApplicationHandle.java bundles/org.eclipse.equinox.app/src/org/osgi/service/application/ScheduledApplication.java bundles/org.eclipse.equinox.common/.classpath bundles/org.eclipse.equinox.common/.cvsignore bundles/org.eclipse.equinox.common/.project bundles/org.eclipse.equinox.common/META-INF/MANIFEST.MF bundles/org.eclipse.equinox.common/about.html bundles/org.eclipse.equinox.common/build.properties bundles/org.eclipse.equinox.common/plugin.properties bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/Activator.java bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/AdapterManager.java bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/CommonMessages.java bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/CommonOSGiUtils.java bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/DataArea.java bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/DevClassPathHelper.java bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/FindSupport.java bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/IAdapterFactoryExt.java bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/IRuntimeConstants.java bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/ListenerList.java bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/MessageResourceBundle.java bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/MetaDataKeeper.java bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/ReferenceHashSet.java bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/ResourceTranslator.java bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/RuntimeLog.java bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/commonMessages.properties bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/package.html bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Assert.java bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/AssertionFailedException.java bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/BundleFinder.java bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/CoreException.java bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/FileLocator.java bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IAdaptable.java bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IAdapterFactory.java bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IAdapterManager.java bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IBundleGroup.java bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IBundleGroupProvider.java bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ILogListener.java bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IPath.java bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IProgressMonitor.java bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IProgressMonitorWithBlocking.java bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ISafeRunnable.java bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IStatus.java bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ListenerList.java bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/MultiStatus.java bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/NullProgressMonitor.java bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/OperationCanceledException.java bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Path.java bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/PlatformObject.java bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/PluginVersionIdentifier.java bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ProgressMonitorWrapper.java bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/QualifiedName.java bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/SafeRunner.java bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Status.java bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/SubProgressMonitor.java bundles/org.eclipse.equinox.device/.classpath bundles/org.eclipse.equinox.device/.cvsignore bundles/org.eclipse.equinox.device/.project bundles/org.eclipse.equinox.device/.settings/org.eclipse.jdt.core.prefs bundles/org.eclipse.equinox.device/META-INF/MANIFEST.MF bundles/org.eclipse.equinox.device/about.html bundles/org.eclipse.equinox.device/build.properties bundles/org.eclipse.equinox.device/plugin.properties bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/Activator.java bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/DeviceMsg.java bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/DeviceTracker.java bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/DriverLocatorTracker.java bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/DriverSelectorTracker.java bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/DriverTracker.java bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/ExternalMessages.properties bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/LogMessages.properties bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/LogTracker.java bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/LogTrackerMsg.java bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/Match.java bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/SecureAction.java bundles/org.eclipse.equinox.ds/.classpath bundles/org.eclipse.equinox.ds/.cvsignore bundles/org.eclipse.equinox.ds/.project bundles/org.eclipse.equinox.ds/.settings/org.eclipse.jdt.core.prefs bundles/org.eclipse.equinox.ds/META-INF/MANIFEST.MF bundles/org.eclipse.equinox.ds/about.html bundles/org.eclipse.equinox.ds/build.properties bundles/org.eclipse.equinox.ds/plugin.properties bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/AbstractReflector.java bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/Activator.java bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/FrameworkHook.java bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/Log.java bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/instance/BuildDispose.java bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/instance/InstanceProcess.java bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/instance/InvokeMethod.java bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/instance/RegisterComponentService.java bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/model/ComponentDescription.java bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/model/ComponentDescriptionCache.java bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/model/ComponentDescriptionProp.java bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/model/ImplementationDescription.java bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/model/PropertyDescription.java bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/model/PropertyResourceDescription.java bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/model/PropertyValueDescription.java bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/model/ProvideDescription.java bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/model/ReferenceDescription.java bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/model/ServiceDescription.java bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/parser/ComponentElement.java bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/parser/ImplementationElement.java bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/parser/Parser.java bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/parser/ParserConstants.java bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/parser/ParserHandler.java bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/parser/PropertiesElement.java bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/parser/PropertyElement.java bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/parser/ProvideElement.java bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/parser/ReferenceElement.java bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/parser/ServiceElement.java bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/resolver/CircularityException.java bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/resolver/Reference.java bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/resolver/Resolver.java bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/service/ComponentContextImpl.java bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/service/ComponentFactoryImpl.java bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/service/ComponentInstanceImpl.java bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/tracker/BundleTracker.java bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/tracker/BundleTrackerCustomizer.java bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/workqueue/WorkDispatcher.java bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/workqueue/WorkQueue.java bundles/org.eclipse.equinox.event/.classpath bundles/org.eclipse.equinox.event/.cvsignore bundles/org.eclipse.equinox.event/.project bundles/org.eclipse.equinox.event/.settings/org.eclipse.jdt.core.prefs bundles/org.eclipse.equinox.event/META-INF/MANIFEST.MF bundles/org.eclipse.equinox.event/about.html bundles/org.eclipse.equinox.event/build.properties bundles/org.eclipse.equinox.event/plugin.properties bundles/org.eclipse.equinox.event/src/org/eclipse/equinox/event/Activator.java bundles/org.eclipse.equinox.event/src/org/eclipse/equinox/event/EventAdminImpl.java bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/BundleEventAdapter.java bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/ConfigurationEventAdapter.java bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/Constants.java bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/EventAdapter.java bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/EventRedeliverer.java bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/FrameworkEventAdapter.java bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/LogEntryAdapter.java bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/LogReaderServiceListener.java bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/LogReaderServiceTracker.java bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/ServiceEventAdapter.java bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/UPnPEventAdapter.java bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/UserAdminEventAdapter.java bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/WireAdminEventAdapter.java bundles/org.eclipse.equinox.http/.classpath bundles/org.eclipse.equinox.http/.cvsignore bundles/org.eclipse.equinox.http/.project bundles/org.eclipse.equinox.http/.settings/org.eclipse.jdt.core.prefs bundles/org.eclipse.equinox.http/META-INF/MANIFEST.MF bundles/org.eclipse.equinox.http/OSGI-INF/l10n/bundle_en.properties bundles/org.eclipse.equinox.http/OSGI-INF/metatype/METADATA.XML bundles/org.eclipse.equinox.http/about.html bundles/org.eclipse.equinox.http/build.properties bundles/org.eclipse.equinox.http/plugin.properties bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/Activator.java bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/DefaultHttpContext.java bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/ExternalMessages.properties bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/Http.java bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpConfiguration.java bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpDate.java bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpListener.java bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpMsg.java bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpSecurityTracker.java bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpServerSocket.java bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpService.java bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpSocket.java bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpThread.java bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpThreadPool.java bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/LogMessages.properties bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/LogTracker.java bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/LogTrackerMsg.java bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/Registration.java bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/ResourceRegistration.java bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/ResourceUnavailableException.java bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/SSLTracker.java bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/SecureAction.java bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/ServletRegistration.java bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/StaticDataReader.java bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/Tokenizer.java bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/URI.java bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/mime.types bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/HttpServletRequestImpl.java bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/HttpServletResponseImpl.java bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/HttpSessionContextImpl.java bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/HttpSessionImpl.java bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/RequestDispatcherImpl.java bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/ServletConfigImpl.java bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/ServletContextImpl.java bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/ServletInputStreamImpl.java bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/ServletOutputStreamImpl.java bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/ServletPrintWriter.java bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/status.codes bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/socket/ServerSocketInterface.java bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/socket/SocketInterface.java bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/socket/https/HttpsServerSocket.java bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/socket/https/HttpsSocket.java bundles/org.eclipse.equinox.log/.classpath bundles/org.eclipse.equinox.log/.cvsignore bundles/org.eclipse.equinox.log/.project bundles/org.eclipse.equinox.log/.settings/org.eclipse.jdt.core.prefs bundles/org.eclipse.equinox.log/META-INF/MANIFEST.MF bundles/org.eclipse.equinox.log/OSGI-INF/l10n/bundle_en.properties bundles/org.eclipse.equinox.log/OSGI-INF/metatype/METADATA.XML bundles/org.eclipse.equinox.log/about.html bundles/org.eclipse.equinox.log/build.properties bundles/org.eclipse.equinox.log/plugin.properties bundles/org.eclipse.equinox.log/src/org/eclipse/equinox/log/Activator.java bundles/org.eclipse.equinox.log/src/org/eclipse/equinox/log/ExternalMessages.properties bundles/org.eclipse.equinox.log/src/org/eclipse/equinox/log/LogEntry.java bundles/org.eclipse.equinox.log/src/org/eclipse/equinox/log/LogMsg.java bundles/org.eclipse.equinox.log/src/org/eclipse/equinox/log/LogReaderService.java bundles/org.eclipse.equinox.log/src/org/eclipse/equinox/log/LogReaderServiceFactory.java bundles/org.eclipse.equinox.log/src/org/eclipse/equinox/log/LogServiceFactory.java bundles/org.eclipse.equinox.log/src/org/eclipse/equinox/log/LogServiceImpl.java bundles/org.eclipse.equinox.log/src/org/eclipse/equinox/log/LoggedException.java bundles/org.eclipse.equinox.metatype/.classpath bundles/org.eclipse.equinox.metatype/.cvsignore bundles/org.eclipse.equinox.metatype/.project bundles/org.eclipse.equinox.metatype/.settings/org.eclipse.jdt.core.prefs bundles/org.eclipse.equinox.metatype/META-INF/MANIFEST.MF bundles/org.eclipse.equinox.metatype/about.html bundles/org.eclipse.equinox.metatype/build.properties bundles/org.eclipse.equinox.metatype/plugin.properties bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/Activator.java bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/AttributeDefinitionImpl.java bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/DataParser.java bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/ExternalMessages.properties bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/FragmentUtils.java bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/Icon.java bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/LocalizationElement.java bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/Logging.java bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/MetaTypeInformationImpl.java bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/MetaTypeMsg.java bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/MetaTypeProviderImpl.java bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/MetaTypeProviderTracker.java bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/MetaTypeServiceImpl.java bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/ObjectClassDefinitionImpl.java bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/ValueTokenizer.java bundles/org.eclipse.equinox.preferences/.classpath bundles/org.eclipse.equinox.preferences/.cvsignore bundles/org.eclipse.equinox.preferences/.options bundles/org.eclipse.equinox.preferences/.project bundles/org.eclipse.equinox.preferences/META-INF/MANIFEST.MF bundles/org.eclipse.equinox.preferences/about.html bundles/org.eclipse.equinox.preferences/build.properties bundles/org.eclipse.equinox.preferences/plugin.properties bundles/org.eclipse.equinox.preferences/plugin.xml bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/AbstractScope.java bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/Activator.java bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/Base64.java bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/ConfigurationPreferences.java bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/DefaultPreferences.java bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/EclipsePreferences.java bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/ExportedPreferences.java bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/ILegacyPreferences.java bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/IPreferencesConstants.java bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/ImmutableMap.java bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/InstancePreferences.java bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/ListenerRegistry.java bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/LookupOrder.java bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/OSGiPreferencesServiceImpl.java bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/OSGiPreferencesServiceManager.java bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/PreferencesOSGiUtils.java bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/PreferencesService.java bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/PrefsMessages.java bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/RootPreferences.java bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/StringPool.java bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/messages.properties bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/AbstractPreferenceInitializer.java bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/ConfigurationScope.java bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/DefaultScope.java bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/IEclipsePreferences.java bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/IExportedPreferences.java bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/IPreferenceFilter.java bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/IPreferenceNodeVisitor.java bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/IPreferencesService.java bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/IProductPreferencesService.java bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/IScope.java bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/IScopeContext.java bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/InstanceScope.java bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/PreferenceFilterEntry.java bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/PreferenceModifyListener.java bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/package.html bundles/org.eclipse.equinox.preferences/src/org/osgi/service/prefs/BackingStoreException.java bundles/org.eclipse.equinox.preferences/src/org/osgi/service/prefs/Preferences.java bundles/org.eclipse.equinox.preferences/src/org/osgi/service/prefs/PreferencesService.java bundles/org.eclipse.equinox.useradmin/.classpath bundles/org.eclipse.equinox.useradmin/.cvsignore bundles/org.eclipse.equinox.useradmin/.project bundles/org.eclipse.equinox.useradmin/.settings/org.eclipse.jdt.core.prefs bundles/org.eclipse.equinox.useradmin/META-INF/MANIFEST.MF bundles/org.eclipse.equinox.useradmin/about.html bundles/org.eclipse.equinox.useradmin/build.properties bundles/org.eclipse.equinox.useradmin/plugin.properties bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/Activator.java bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/Authorization.java bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/ExternalMessages.properties bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/Group.java bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/LogMessages.properties bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/LogTracker.java bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/LogTrackerMsg.java bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/Role.java bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/User.java bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/UserAdmin.java bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/UserAdminEventProducer.java bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/UserAdminHashtable.java bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/UserAdminMsg.java bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/UserAdminStore.java bundles/org.eclipse.equinox.wireadmin/.classpath bundles/org.eclipse.equinox.wireadmin/.cvsignore bundles/org.eclipse.equinox.wireadmin/.project bundles/org.eclipse.equinox.wireadmin/.settings/org.eclipse.jdt.core.prefs bundles/org.eclipse.equinox.wireadmin/META-INF/MANIFEST.MF bundles/org.eclipse.equinox.wireadmin/about.html bundles/org.eclipse.equinox.wireadmin/build.properties bundles/org.eclipse.equinox.wireadmin/plugin.properties bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/Activator.java bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/ConsumerCustomizer.java bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/ConsumersCustomizer.java bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/ExternalMessages.properties bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/LogMessages.properties bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/LogTracker.java bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/LogTrackerMsg.java bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/ProducerCustomizer.java bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/ProducersCustomizer.java bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/ReadOnlyDictionary.java bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/Wire.java bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/WireAdmin.java bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/WireAdminEventProducer.java bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/WireAdminMsg.java bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/WireAdminStore.java
-rwxr-xr-xbundles/org.eclipse.equinox.app/.classpath7
-rwxr-xr-xbundles/org.eclipse.equinox.app/.cvsignore1
-rwxr-xr-xbundles/org.eclipse.equinox.app/.project28
-rwxr-xr-xbundles/org.eclipse.equinox.app/.settings/org.eclipse.core.resources.prefs3
-rwxr-xr-xbundles/org.eclipse.equinox.app/.settings/org.eclipse.jdt.core.prefs77
-rwxr-xr-xbundles/org.eclipse.equinox.app/.settings/org.eclipse.jdt.ui.prefs3
-rwxr-xr-xbundles/org.eclipse.equinox.app/.settings/org.eclipse.pde.core.prefs4
-rwxr-xr-xbundles/org.eclipse.equinox.app/META-INF/MANIFEST.MF28
-rwxr-xr-xbundles/org.eclipse.equinox.app/about.html60
-rwxr-xr-xbundles/org.eclipse.equinox.app/build.properties16
-rwxr-xr-xbundles/org.eclipse.equinox.app/plugin.properties14
-rwxr-xr-xbundles/org.eclipse.equinox.app/plugin.xml22
-rwxr-xr-xbundles/org.eclipse.equinox.app/schema/applications.exsd173
-rwxr-xr-xbundles/org.eclipse.equinox.app/schema/containers.exsd124
-rwxr-xr-xbundles/org.eclipse.equinox.app/src/org/eclipse/equinox/app/IAppContext.java76
-rwxr-xr-xbundles/org.eclipse.equinox.app/src/org/eclipse/equinox/app/IApplication.java64
-rwxr-xr-xbundles/org.eclipse.equinox.app/src/org/eclipse/equinox/app/IContainer.java40
-rwxr-xr-xbundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/Activator.java88
-rwxr-xr-xbundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/AppCommands.java251
-rwxr-xr-xbundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/AppPersistenceUtil.java589
-rwxr-xr-xbundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/ContainerManager.java499
-rwxr-xr-xbundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/EclipseAppDescriptor.java161
-rwxr-xr-xbundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/EclipseAppHandle.java120
-rwxr-xr-xbundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/EclipseScheduledApplication.java130
-rwxr-xr-xbundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/ErrorApplication.java37
-rwxr-xr-xbundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/MainThreadApplication.java70
-rwxr-xr-xbundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/MainThreadContainer.java78
-rwxr-xr-xbundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/Messages.java42
-rwxr-xr-xbundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/SingletonContainer.java68
-rwxr-xr-xbundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/messages.properties26
-rwxr-xr-xbundles/org.eclipse.equinox.app/src/org/osgi/service/application/ApplicationAdminPermission.java403
-rwxr-xr-xbundles/org.eclipse.equinox.app/src/org/osgi/service/application/ApplicationDescriptor.java501
-rwxr-xr-xbundles/org.eclipse.equinox.app/src/org/osgi/service/application/ApplicationException.java104
-rwxr-xr-xbundles/org.eclipse.equinox.app/src/org/osgi/service/application/ApplicationHandle.java174
-rwxr-xr-xbundles/org.eclipse.equinox.app/src/org/osgi/service/application/ScheduledApplication.java89
-rw-r--r--bundles/org.eclipse.equinox.common/.classpath7
-rw-r--r--bundles/org.eclipse.equinox.common/.cvsignore1
-rw-r--r--bundles/org.eclipse.equinox.common/.project28
-rw-r--r--bundles/org.eclipse.equinox.common/META-INF/MANIFEST.MF18
-rw-r--r--bundles/org.eclipse.equinox.common/about.html24
-rw-r--r--bundles/org.eclipse.equinox.common/build.properties17
-rw-r--r--bundles/org.eclipse.equinox.common/plugin.properties12
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/Activator.java98
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/AdapterManager.java353
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/CommonMessages.java58
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/CommonOSGiUtils.java180
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/DataArea.java126
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/DevClassPathHelper.java98
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/FindSupport.java246
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/IAdapterFactoryExt.java31
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/IRuntimeConstants.java37
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/ListenerList.java160
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/MessageResourceBundle.java225
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/MetaDataKeeper.java37
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/ReferenceHashSet.java323
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/ResourceTranslator.java134
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/RuntimeLog.java94
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/commonMessages.properties42
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/package.html24
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Assert.java110
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/AssertionFailedException.java28
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/BundleFinder.java179
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/CoreException.java98
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/FileLocator.java147
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IAdaptable.java47
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IAdapterFactory.java53
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IAdapterManager.java223
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IBundleGroup.java91
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IBundleGroupProvider.java37
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ILogListener.java33
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IPath.java504
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IProgressMonitor.java128
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IProgressMonitorWithBlocking.java60
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ISafeRunnable.java48
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IStatus.java184
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ListenerList.java176
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/MultiStatus.java146
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/NullProgressMonitor.java124
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/OperationCanceledException.java42
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Path.java986
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/PlatformObject.java67
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/PluginVersionIdentifier.java455
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ProgressMonitorWrapper.java168
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/QualifiedName.java114
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/SafeRunner.java67
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Status.java231
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/SubProgressMonitor.java177
-rw-r--r--bundles/org.eclipse.equinox.device/.classpath7
-rw-r--r--bundles/org.eclipse.equinox.device/.cvsignore1
-rw-r--r--bundles/org.eclipse.equinox.device/.project28
-rw-r--r--bundles/org.eclipse.equinox.device/.settings/org.eclipse.jdt.core.prefs49
-rw-r--r--bundles/org.eclipse.equinox.device/META-INF/MANIFEST.MF15
-rw-r--r--bundles/org.eclipse.equinox.device/about.html22
-rw-r--r--bundles/org.eclipse.equinox.device/build.properties17
-rw-r--r--bundles/org.eclipse.equinox.device/plugin.properties13
-rw-r--r--bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/Activator.java420
-rw-r--r--bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/DeviceMsg.java43
-rw-r--r--bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/DeviceTracker.java341
-rw-r--r--bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/DriverLocatorTracker.java344
-rw-r--r--bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/DriverSelectorTracker.java150
-rw-r--r--bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/DriverTracker.java485
-rw-r--r--bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/ExternalMessages.properties31
-rw-r--r--bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/LogMessages.properties15
-rw-r--r--bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/LogTracker.java150
-rw-r--r--bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/LogTrackerMsg.java27
-rw-r--r--bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/Match.java36
-rw-r--r--bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/SecureAction.java50
-rw-r--r--bundles/org.eclipse.equinox.ds/.classpath7
-rw-r--r--bundles/org.eclipse.equinox.ds/.cvsignore1
-rw-r--r--bundles/org.eclipse.equinox.ds/.project28
-rw-r--r--bundles/org.eclipse.equinox.ds/.settings/org.eclipse.jdt.core.prefs49
-rw-r--r--bundles/org.eclipse.equinox.ds/META-INF/MANIFEST.MF28
-rw-r--r--bundles/org.eclipse.equinox.ds/about.html22
-rw-r--r--bundles/org.eclipse.equinox.ds/build.properties17
-rw-r--r--bundles/org.eclipse.equinox.ds/plugin.properties13
-rw-r--r--bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/AbstractReflector.java141
-rw-r--r--bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/Activator.java390
-rw-r--r--bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/FrameworkHook.java54
-rw-r--r--bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/Log.java51
-rw-r--r--bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/instance/BuildDispose.java717
-rw-r--r--bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/instance/InstanceProcess.java365
-rw-r--r--bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/instance/InvokeMethod.java322
-rw-r--r--bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/instance/RegisterComponentService.java160
-rw-r--r--bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/model/ComponentDescription.java388
-rw-r--r--bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/model/ComponentDescriptionCache.java168
-rw-r--r--bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/model/ComponentDescriptionProp.java151
-rw-r--r--bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/model/ImplementationDescription.java47
-rw-r--r--bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/model/PropertyDescription.java23
-rw-r--r--bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/model/PropertyResourceDescription.java42
-rw-r--r--bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/model/PropertyValueDescription.java72
-rw-r--r--bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/model/ProvideDescription.java45
-rw-r--r--bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/model/ReferenceDescription.java214
-rw-r--r--bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/model/ServiceDescription.java69
-rw-r--r--bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/parser/ComponentElement.java128
-rw-r--r--bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/parser/ImplementationElement.java67
-rw-r--r--bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/parser/Parser.java122
-rw-r--r--bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/parser/ParserConstants.java49
-rw-r--r--bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/parser/ParserHandler.java173
-rw-r--r--bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/parser/PropertiesElement.java63
-rw-r--r--bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/parser/PropertyElement.java222
-rw-r--r--bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/parser/ProvideElement.java64
-rw-r--r--bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/parser/ReferenceElement.java96
-rw-r--r--bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/parser/ServiceElement.java79
-rw-r--r--bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/resolver/CircularityException.java35
-rw-r--r--bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/resolver/Reference.java247
-rw-r--r--bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/resolver/Resolver.java946
-rw-r--r--bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/service/ComponentContextImpl.java365
-rw-r--r--bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/service/ComponentFactoryImpl.java91
-rw-r--r--bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/service/ComponentInstanceImpl.java86
-rw-r--r--bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/tracker/BundleTracker.java376
-rw-r--r--bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/tracker/BundleTrackerCustomizer.java77
-rw-r--r--bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/workqueue/WorkDispatcher.java32
-rw-r--r--bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/workqueue/WorkQueue.java179
-rw-r--r--bundles/org.eclipse.equinox.event/.classpath7
-rw-r--r--bundles/org.eclipse.equinox.event/.cvsignore1
-rw-r--r--bundles/org.eclipse.equinox.event/.project28
-rw-r--r--bundles/org.eclipse.equinox.event/.settings/org.eclipse.jdt.core.prefs49
-rw-r--r--bundles/org.eclipse.equinox.event/META-INF/MANIFEST.MF19
-rw-r--r--bundles/org.eclipse.equinox.event/about.html22
-rw-r--r--bundles/org.eclipse.equinox.event/build.properties17
-rw-r--r--bundles/org.eclipse.equinox.event/plugin.properties13
-rw-r--r--bundles/org.eclipse.equinox.event/src/org/eclipse/equinox/event/Activator.java30
-rw-r--r--bundles/org.eclipse.equinox.event/src/org/eclipse/equinox/event/EventAdminImpl.java367
-rw-r--r--bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/BundleEventAdapter.java84
-rw-r--r--bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/ConfigurationEventAdapter.java71
-rw-r--r--bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/Constants.java33
-rw-r--r--bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/EventAdapter.java102
-rw-r--r--bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/EventRedeliverer.java307
-rw-r--r--bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/FrameworkEventAdapter.java73
-rw-r--r--bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/LogEntryAdapter.java79
-rw-r--r--bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/LogReaderServiceListener.java26
-rw-r--r--bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/LogReaderServiceTracker.java53
-rw-r--r--bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/ServiceEventAdapter.java70
-rw-r--r--bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/UPnPEventAdapter.java59
-rw-r--r--bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/UserAdminEventAdapter.java82
-rw-r--r--bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/WireAdminEventAdapter.java108
-rw-r--r--bundles/org.eclipse.equinox.http/.classpath7
-rw-r--r--bundles/org.eclipse.equinox.http/.cvsignore1
-rw-r--r--bundles/org.eclipse.equinox.http/.project28
-rw-r--r--bundles/org.eclipse.equinox.http/.settings/org.eclipse.jdt.core.prefs49
-rw-r--r--bundles/org.eclipse.equinox.http/META-INF/MANIFEST.MF22
-rw-r--r--bundles/org.eclipse.equinox.http/OSGI-INF/l10n/bundle_en.properties33
-rw-r--r--bundles/org.eclipse.equinox.http/OSGI-INF/metatype/METADATA.XML20
-rw-r--r--bundles/org.eclipse.equinox.http/about.html22
-rw-r--r--bundles/org.eclipse.equinox.http/build.properties17
-rw-r--r--bundles/org.eclipse.equinox.http/plugin.properties13
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/Activator.java44
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/DefaultHttpContext.java45
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/ExternalMessages.properties59
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/Http.java206
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpConfiguration.java581
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpDate.java388
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpListener.java16
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpMsg.java71
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpSecurityTracker.java42
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpServerSocket.java76
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpService.java75
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpSocket.java94
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpThread.java224
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpThreadPool.java287
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/LogMessages.properties16
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/LogTracker.java151
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/LogTrackerMsg.java27
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/Registration.java32
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/ResourceRegistration.java230
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/ResourceUnavailableException.java15
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/SSLTracker.java27
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/SecureAction.java92
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/ServletRegistration.java87
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/StaticDataReader.java226
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/Tokenizer.java113
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/URI.java127
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/mime.types44
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/HttpServletRequestImpl.java1444
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/HttpServletResponseImpl.java861
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/HttpSessionContextImpl.java53
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/HttpSessionImpl.java501
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/RequestDispatcherImpl.java294
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/ServletConfigImpl.java71
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/ServletContextImpl.java446
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/ServletInputStreamImpl.java515
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/ServletOutputStreamImpl.java133
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/ServletPrintWriter.java46
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/status.codes52
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/socket/ServerSocketInterface.java32
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/socket/SocketInterface.java73
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/socket/https/HttpsServerSocket.java155
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/socket/https/HttpsSocket.java117
-rw-r--r--bundles/org.eclipse.equinox.log/.classpath7
-rw-r--r--bundles/org.eclipse.equinox.log/.cvsignore1
-rw-r--r--bundles/org.eclipse.equinox.log/.project28
-rw-r--r--bundles/org.eclipse.equinox.log/.settings/org.eclipse.jdt.core.prefs49
-rw-r--r--bundles/org.eclipse.equinox.log/META-INF/MANIFEST.MF16
-rw-r--r--bundles/org.eclipse.equinox.log/OSGI-INF/l10n/bundle_en.properties21
-rw-r--r--bundles/org.eclipse.equinox.log/OSGI-INF/metatype/METADATA.XML15
-rw-r--r--bundles/org.eclipse.equinox.log/about.html22
-rw-r--r--bundles/org.eclipse.equinox.log/build.properties17
-rw-r--r--bundles/org.eclipse.equinox.log/plugin.properties13
-rw-r--r--bundles/org.eclipse.equinox.log/src/org/eclipse/equinox/log/Activator.java533
-rw-r--r--bundles/org.eclipse.equinox.log/src/org/eclipse/equinox/log/ExternalMessages.properties19
-rw-r--r--bundles/org.eclipse.equinox.log/src/org/eclipse/equinox/log/LogEntry.java130
-rw-r--r--bundles/org.eclipse.equinox.log/src/org/eclipse/equinox/log/LogMsg.java30
-rw-r--r--bundles/org.eclipse.equinox.log/src/org/eclipse/equinox/log/LogReaderService.java121
-rw-r--r--bundles/org.eclipse.equinox.log/src/org/eclipse/equinox/log/LogReaderServiceFactory.java39
-rw-r--r--bundles/org.eclipse.equinox.log/src/org/eclipse/equinox/log/LogServiceFactory.java39
-rw-r--r--bundles/org.eclipse.equinox.log/src/org/eclipse/equinox/log/LogServiceImpl.java118
-rw-r--r--bundles/org.eclipse.equinox.log/src/org/eclipse/equinox/log/LoggedException.java204
-rw-r--r--bundles/org.eclipse.equinox.metatype/.classpath7
-rw-r--r--bundles/org.eclipse.equinox.metatype/.cvsignore1
-rw-r--r--bundles/org.eclipse.equinox.metatype/.project28
-rw-r--r--bundles/org.eclipse.equinox.metatype/.settings/org.eclipse.jdt.core.prefs49
-rw-r--r--bundles/org.eclipse.equinox.metatype/META-INF/MANIFEST.MF16
-rw-r--r--bundles/org.eclipse.equinox.metatype/about.html22
-rw-r--r--bundles/org.eclipse.equinox.metatype/build.properties17
-rw-r--r--bundles/org.eclipse.equinox.metatype/plugin.properties13
-rw-r--r--bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/Activator.java159
-rw-r--r--bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/AttributeDefinitionImpl.java486
-rw-r--r--bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/DataParser.java921
-rw-r--r--bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/ExternalMessages.properties33
-rw-r--r--bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/FragmentUtils.java85
-rw-r--r--bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/Icon.java72
-rw-r--r--bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/LocalizationElement.java55
-rw-r--r--bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/Logging.java73
-rw-r--r--bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/MetaTypeInformationImpl.java87
-rw-r--r--bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/MetaTypeMsg.java45
-rw-r--r--bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/MetaTypeProviderImpl.java240
-rw-r--r--bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/MetaTypeProviderTracker.java143
-rw-r--r--bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/MetaTypeServiceImpl.java107
-rw-r--r--bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/ObjectClassDefinitionImpl.java323
-rw-r--r--bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/ValueTokenizer.java76
-rw-r--r--bundles/org.eclipse.equinox.preferences/.classpath7
-rw-r--r--bundles/org.eclipse.equinox.preferences/.cvsignore1
-rw-r--r--bundles/org.eclipse.equinox.preferences/.options6
-rw-r--r--bundles/org.eclipse.equinox.preferences/.project28
-rw-r--r--bundles/org.eclipse.equinox.preferences/META-INF/MANIFEST.MF15
-rw-r--r--bundles/org.eclipse.equinox.preferences/about.html60
-rw-r--r--bundles/org.eclipse.equinox.preferences/build.properties19
-rw-r--r--bundles/org.eclipse.equinox.preferences/plugin.properties14
-rw-r--r--bundles/org.eclipse.equinox.preferences/plugin.xml11
-rw-r--r--bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/AbstractScope.java67
-rw-r--r--bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/Activator.java126
-rw-r--r--bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/Base64.java198
-rw-r--r--bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/ConfigurationPreferences.java118
-rw-r--r--bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/DefaultPreferences.java362
-rw-r--r--bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/EclipsePreferences.java1167
-rw-r--r--bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/ExportedPreferences.java78
-rw-r--r--bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/ILegacyPreferences.java29
-rw-r--r--bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/IPreferencesConstants.java58
-rw-r--r--bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/ImmutableMap.java279
-rw-r--r--bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/InstancePreferences.java211
-rw-r--r--bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/ListenerRegistry.java159
-rw-r--r--bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/LookupOrder.java33
-rw-r--r--bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/OSGiPreferencesServiceImpl.java199
-rw-r--r--bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/OSGiPreferencesServiceManager.java119
-rw-r--r--bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/PreferencesOSGiUtils.java178
-rw-r--r--bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/PreferencesService.java1153
-rw-r--r--bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/PrefsMessages.java69
-rw-r--r--bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/RootPreferences.java129
-rw-r--r--bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/StringPool.java68
-rw-r--r--bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/messages.properties34
-rw-r--r--bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/AbstractPreferenceInitializer.java52
-rw-r--r--bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/ConfigurationScope.java86
-rw-r--r--bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/DefaultScope.java77
-rw-r--r--bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/IEclipsePreferences.java316
-rw-r--r--bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/IExportedPreferences.java34
-rw-r--r--bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/IPreferenceFilter.java77
-rw-r--r--bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/IPreferenceNodeVisitor.java47
-rw-r--r--bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/IPreferencesService.java618
-rw-r--r--bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/IProductPreferencesService.java30
-rw-r--r--bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/IScope.java39
-rw-r--r--bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/IScopeContext.java70
-rw-r--r--bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/InstanceScope.java71
-rw-r--r--bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/PreferenceFilterEntry.java47
-rw-r--r--bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/PreferenceModifyListener.java49
-rw-r--r--bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/package.html17
-rw-r--r--bundles/org.eclipse.equinox.preferences/src/org/osgi/service/prefs/BackingStoreException.java74
-rw-r--r--bundles/org.eclipse.equinox.preferences/src/org/osgi/service/prefs/Preferences.java694
-rw-r--r--bundles/org.eclipse.equinox.preferences/src/org/osgi/service/prefs/PreferencesService.java48
-rw-r--r--bundles/org.eclipse.equinox.useradmin/.classpath7
-rw-r--r--bundles/org.eclipse.equinox.useradmin/.cvsignore1
-rw-r--r--bundles/org.eclipse.equinox.useradmin/.project28
-rw-r--r--bundles/org.eclipse.equinox.useradmin/.settings/org.eclipse.jdt.core.prefs49
-rw-r--r--bundles/org.eclipse.equinox.useradmin/META-INF/MANIFEST.MF18
-rw-r--r--bundles/org.eclipse.equinox.useradmin/about.html22
-rw-r--r--bundles/org.eclipse.equinox.useradmin/build.properties17
-rw-r--r--bundles/org.eclipse.equinox.useradmin/plugin.properties13
-rw-r--r--bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/Activator.java116
-rw-r--r--bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/Authorization.java148
-rw-r--r--bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/ExternalMessages.properties27
-rw-r--r--bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/Group.java295
-rw-r--r--bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/LogMessages.properties15
-rw-r--r--bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/LogTracker.java150
-rw-r--r--bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/LogTrackerMsg.java27
-rw-r--r--bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/Role.java137
-rw-r--r--bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/User.java143
-rw-r--r--bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/UserAdmin.java362
-rw-r--r--bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/UserAdminEventProducer.java139
-rw-r--r--bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/UserAdminHashtable.java177
-rw-r--r--bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/UserAdminMsg.java38
-rw-r--r--bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/UserAdminStore.java353
-rw-r--r--bundles/org.eclipse.equinox.wireadmin/.classpath7
-rw-r--r--bundles/org.eclipse.equinox.wireadmin/.cvsignore1
-rw-r--r--bundles/org.eclipse.equinox.wireadmin/.project28
-rw-r--r--bundles/org.eclipse.equinox.wireadmin/.settings/org.eclipse.jdt.core.prefs49
-rw-r--r--bundles/org.eclipse.equinox.wireadmin/META-INF/MANIFEST.MF18
-rw-r--r--bundles/org.eclipse.equinox.wireadmin/about.html22
-rw-r--r--bundles/org.eclipse.equinox.wireadmin/build.properties16
-rw-r--r--bundles/org.eclipse.equinox.wireadmin/plugin.properties13
-rw-r--r--bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/Activator.java76
-rw-r--r--bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/ConsumerCustomizer.java60
-rw-r--r--bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/ConsumersCustomizer.java59
-rw-r--r--bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/ExternalMessages.properties14
-rw-r--r--bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/LogMessages.properties14
-rw-r--r--bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/LogTracker.java151
-rw-r--r--bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/LogTrackerMsg.java27
-rw-r--r--bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/ProducerCustomizer.java53
-rw-r--r--bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/ProducersCustomizer.java60
-rw-r--r--bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/ReadOnlyDictionary.java76
-rw-r--r--bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/Wire.java490
-rw-r--r--bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/WireAdmin.java432
-rw-r--r--bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/WireAdminEventProducer.java178
-rw-r--r--bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/WireAdminMsg.java28
-rw-r--r--bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/WireAdminStore.java242
363 files changed, 0 insertions, 47008 deletions
diff --git a/bundles/org.eclipse.equinox.app/.classpath b/bundles/org.eclipse.equinox.app/.classpath
deleted file mode 100755
index 751c8f2e5..000000000
--- a/bundles/org.eclipse.equinox.app/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/bundles/org.eclipse.equinox.app/.cvsignore b/bundles/org.eclipse.equinox.app/.cvsignore
deleted file mode 100755
index ba077a403..000000000
--- a/bundles/org.eclipse.equinox.app/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
diff --git a/bundles/org.eclipse.equinox.app/.project b/bundles/org.eclipse.equinox.app/.project
deleted file mode 100755
index c1246c349..000000000
--- a/bundles/org.eclipse.equinox.app/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.equinox.app</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/bundles/org.eclipse.equinox.app/.settings/org.eclipse.core.resources.prefs b/bundles/org.eclipse.equinox.app/.settings/org.eclipse.core.resources.prefs
deleted file mode 100755
index 16532b29e..000000000
--- a/bundles/org.eclipse.equinox.app/.settings/org.eclipse.core.resources.prefs
+++ /dev/null
@@ -1,3 +0,0 @@
-#Tue May 25 15:00:03 EDT 2004
-encoding/<project>=ISO-8859-1
-eclipse.preferences.version=1
diff --git a/bundles/org.eclipse.equinox.app/.settings/org.eclipse.jdt.core.prefs b/bundles/org.eclipse.equinox.app/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100755
index 9509abc7e..000000000
--- a/bundles/org.eclipse.equinox.app/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,77 +0,0 @@
-#Wed Dec 14 13:44:11 CST 2005
-eclipse.preferences.version=1
-org.eclipse.jdt.core.builder.cleanOutputFolder=clean
-org.eclipse.jdt.core.builder.duplicateResourceTask=warning
-org.eclipse.jdt.core.builder.invalidClasspath=abort
-org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch
-org.eclipse.jdt.core.circularClasspath=error
-org.eclipse.jdt.core.classpath.exclusionPatterns=enabled
-org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.4
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.doc.comment.support=enabled
-org.eclipse.jdt.core.compiler.maxProblemPerUnit=1000
-org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
-org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
-org.eclipse.jdt.core.compiler.problem.deprecation=warning
-org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
-org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled
-org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
-org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
-org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
-org.eclipse.jdt.core.compiler.problem.finalParameterBound=ignore
-org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
-org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
-org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
-org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
-org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning
-org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning
-org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private
-org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
-org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
-org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
-org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore
-org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=enabled
-org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public
-org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore
-org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=enabled
-org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
-org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
-org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
-org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
-org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
-org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
-org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning
-org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
-org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
-org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
-org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-org.eclipse.jdt.core.compiler.problem.unsafeTypeOperation=warning
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=enabled
-org.eclipse.jdt.core.compiler.problem.unusedImport=error
-org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
-org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=enabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=enabled
-org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.3
-org.eclipse.jdt.core.incompatibleJDKLevel=ignore
-org.eclipse.jdt.core.incompleteClasspath=error
diff --git a/bundles/org.eclipse.equinox.app/.settings/org.eclipse.jdt.ui.prefs b/bundles/org.eclipse.equinox.app/.settings/org.eclipse.jdt.ui.prefs
deleted file mode 100755
index a0bbd3f76..000000000
--- a/bundles/org.eclipse.equinox.app/.settings/org.eclipse.jdt.ui.prefs
+++ /dev/null
@@ -1,3 +0,0 @@
-#Wed Dec 14 13:44:11 CST 2005
-eclipse.preferences.version=1
-internal.default.compliance=default
diff --git a/bundles/org.eclipse.equinox.app/.settings/org.eclipse.pde.core.prefs b/bundles/org.eclipse.equinox.app/.settings/org.eclipse.pde.core.prefs
deleted file mode 100755
index e993d41da..000000000
--- a/bundles/org.eclipse.equinox.app/.settings/org.eclipse.pde.core.prefs
+++ /dev/null
@@ -1,4 +0,0 @@
-#Fri Dec 02 16:20:40 CST 2005
-eclipse.preferences.version=1
-pluginProject.equinox=false
-pluginProject.extensions=true
diff --git a/bundles/org.eclipse.equinox.app/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.app/META-INF/MANIFEST.MF
deleted file mode 100755
index 2ae82137a..000000000
--- a/bundles/org.eclipse.equinox.app/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,28 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %pluginName
-Bundle-SymbolicName: org.eclipse.equinox.app; singleton:=true
-Bundle-Version: 1.0.0.qualifier
-Bundle-Vendor: %providerName
-Bundle-Activator: org.eclipse.equinox.internal.app.Activator
-Bundle-Localization: plugin
-Export-Package: org.eclipse.equinox.app;version="1.0",
- org.eclipse.equinox.internal.app;x-friends:="org.eclipse.core.runtime",
- org.osgi.service.application;version="1.0"
-Import-Package: org.osgi.framework;version="1.3",
- org.osgi.service.condpermadmin,
- org.osgi.service.event;version="1.0.0";resolution:=optional,
- org.osgi.service.packageadmin; version="1.2",
- org.osgi.util.tracker,
- org.eclipse.equinox.registry,
- org.eclipse.osgi.framework.log,
- org.eclipse.core.runtime.adaptor,
- org.eclipse.osgi.service.debug,
- org.eclipse.osgi.service.datalocation,
- org.eclipse.osgi.service.environment,
- org.eclipse.osgi.service.runnable,
- org.eclipse.osgi.storagemanager,
- org.eclipse.osgi.util,
- org.eclipse.osgi.framework.console; resolution:=optional
-Require-Bundle: org.eclipse.equinox.common
-DynamicImport-Package: org.osgi.service.event;version="1.0.0"
diff --git a/bundles/org.eclipse.equinox.app/about.html b/bundles/org.eclipse.equinox.app/about.html
deleted file mode 100755
index bd87495af..000000000
--- a/bundles/org.eclipse.equinox.app/about.html
+++ /dev/null
@@ -1,60 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<html>
-<head>
-<title>About</title>
-<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-</head>
-<body lang="EN-US">
-<h2>About This Content</h2>
-
-<p>September 26, 2005</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" target="_blank">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.</p>
-
-<h3>Third Party Content</h3>
-
-<p>The Content includes items that have been sourced from third parties as follows:</p>
-
-<p><b>OSGi Materials</b></p>
-
-<p>All files in the following sub-directories (and their sub-directories):</p>
-
-<ul>
- <li>org/osgi</li>
-</ul>
-
-<p>shall be defined as the &quot;OSGi Materials.&quot; The OSGi Materials are:</p>
-
-<blockquote>
-Copyright (c) 2000, 2005
-<br /><br />
-OSGi Alliance
-Bishop Ranch 6<br/>
-2400 Camino Ramon, Suite 375<br/>
-San Ramon, CA 94583 USA
-<br /><br />
-All Rights Reserved.
-</blockquote>
-
-<p>The OSGi Materials are provided to you under the terms and conditions of the
-Eclipse Public License Version 1.0 (&quot;EPL&quot;). For purposes of the EPL, &quot;Program&quot; will mean the OSGi Materials.</p>
-
-<p>Implementation of certain elements of the OSGi Materials may be subject to third party intellectual property rights, including without limitation, patent rights (such a third party may
-or may not be a member of the OSGi Alliance). The OSGi Alliance and its members are not responsible and shall not be held responsible in any manner for identifying or failing to identify any or all such third party
-intellectual property rights.</p>
-
-<small>OSGi&trade; is a trademark, registered trademark, or service mark of The OSGi Alliance in the US and other countries. Java is a trademark,
-registered trademark, or service mark of Sun Microsystems, Inc. in the US and other countries. All other trademarks, registered trademarks, or
-service marks used in the Content are the property of their respective owners and are hereby recognized.</small>
-
-<small>Java and all Java-based trademarks and logos are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries.</small>
-
-</body>
-</html>
diff --git a/bundles/org.eclipse.equinox.app/build.properties b/bundles/org.eclipse.equinox.app/build.properties
deleted file mode 100755
index cefe3b679..000000000
--- a/bundles/org.eclipse.equinox.app/build.properties
+++ /dev/null
@@ -1,16 +0,0 @@
-###############################################################################
-# Copyright (c) 2005 IBM Corporation 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:
-# IBM Corporation - initial API and implementation
-###############################################################################
-source.. = src/
-output.. = bin/
-bin.includes = META-INF/,\
- .,\
- about.html
-src.includes = about.html
diff --git a/bundles/org.eclipse.equinox.app/plugin.properties b/bundles/org.eclipse.equinox.app/plugin.properties
deleted file mode 100755
index 31bd8dc65..000000000
--- a/bundles/org.eclipse.equinox.app/plugin.properties
+++ /dev/null
@@ -1,14 +0,0 @@
-###############################################################################
-# Copyright (c) 2003, 2004 IBM Corporation 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:
-# IBM Corporation - initial API and implementation
-###############################################################################
-pluginName = Equinox Application Container
-providerName = Eclipse.org
-applicationsName = Applications
-containersName = Containers
diff --git a/bundles/org.eclipse.equinox.app/plugin.xml b/bundles/org.eclipse.equinox.app/plugin.xml
deleted file mode 100755
index 412d4286f..000000000
--- a/bundles/org.eclipse.equinox.app/plugin.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.0"?>
-<plugin>
- <extension-point id="applications" name="%applicationsName" schema="schema/applications.exsd"/>
- <extension-point id="containers" name="%containersName" schema="schema/containers.exsd"/>
- <extension
- id="main.thread"
- point="org.eclipse.equinox.app.containers">
- <container
- singleton="true"
- type="main.thread">
- <run class="org.eclipse.equinox.internal.app.MainThreadContainer"/>
- </container>
- </extension>
- <extension
- id="error"
- point="org.eclipse.equinox.app.applications">
- <application visible="false">
- <run class="org.eclipse.equinox.internal.app.ErrorApplication"/>
- </application>
- </extension>
-</plugin>
diff --git a/bundles/org.eclipse.equinox.app/schema/applications.exsd b/bundles/org.eclipse.equinox.app/schema/applications.exsd
deleted file mode 100755
index 042b71888..000000000
--- a/bundles/org.eclipse.equinox.app/schema/applications.exsd
+++ /dev/null
@@ -1,173 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.equinox.app">
-<annotation>
- <appInfo>
- <meta.schema plugin="org.eclipse.equinox.app" id="applications" name="Applications"/>
- </appInfo>
- <documentation>
- Platform runtime supports plug-ins which would like to
-declare main entry points. That is, programs which
-would like to run using the platform runtime but yet
-control all aspects of execution can declare themselves
-as an application. Declared applications can be run
-directly from the main platform launcher by specifying
-the &lt;i&gt;-application&lt;/i&gt; argument where the parameter
-is the id of an extension supplied to the
-applications extension point described here.
-This application is instantiated and run by the platform.
-Platform clients can also use the platform to lookup and
-run multiple applications.
- </documentation>
- </annotation>
-
- <element name="extension">
- <complexType>
- <sequence>
- <element ref="application"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="application">
- <complexType>
- <sequence>
- <element ref="run" minOccurs="0" maxOccurs="1"/>
- </sequence>
- <attribute name="type" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="visible" type="boolean" use="default" value="true">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="run">
- <complexType>
- <sequence>
- <element ref="parameter" minOccurs="0" maxOccurs="unbounded"/>
- </sequence>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
- the fully-qualified name of a class which implements
-&lt;samp&gt;org.eclipse.equinox.application.IApplication&lt;/samp&gt;.
- </documentation>
- <appInfo>
- <meta.attribute kind="java" basedOn="org.eclipse.equinox.app.IApplication"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="parameter">
- <annotation>
- <appInfo>
- <meta.element labelAttribute="name"/>
- </appInfo>
- </annotation>
- <complexType>
- <attribute name="name" type="string" use="required">
- <annotation>
- <documentation>
- the name of this parameter made available to instances of the specified application class
- </documentation>
- </annotation>
- </attribute>
- <attribute name="value" type="string" use="required">
- <annotation>
- <documentation>
- the value of this parameter made available to instances of the specified application class
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appInfo>
- <meta.section type="examples"/>
- </appInfo>
- <documentation>
- Following is an example of an application declaration:
-&lt;p&gt;
-&lt;pre&gt;
- &lt;extension id=&quot;coolApplication&quot; point=&quot;org.eclipse.equinox.applications&quot;&gt;
- &lt;application&gt;
- &lt;run class=&quot;com.xyz.applications.Cool&quot;&gt;
- &lt;parameter name=&quot;optimize&quot; value=&quot;true&quot;/&gt;
- &lt;/run&gt;
- &lt;/application&gt;
- &lt;/extension&gt;
-&lt;/pre&gt;
-&lt;/p&gt;
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="apiInfo"/>
- </appInfo>
- <documentation>
- The value of the class attribute must represent an
-implementor of
-&lt;samp&gt;org.eclipse.equinox.IPlatformRunnable&lt;/samp&gt;.
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="implementation"/>
- </appInfo>
- <documentation>
- The platform supplies a number of applications including the platform workbench itself.
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="copyright"/>
- </appInfo>
- <documentation>
- Copyright (c) 2004, 2005 IBM Corporation and others.&lt;br&gt;
-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
-&lt;a
-href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
- </documentation>
- </annotation>
-
-</schema>
diff --git a/bundles/org.eclipse.equinox.app/schema/containers.exsd b/bundles/org.eclipse.equinox.app/schema/containers.exsd
deleted file mode 100755
index 9f8f736e8..000000000
--- a/bundles/org.eclipse.equinox.app/schema/containers.exsd
+++ /dev/null
@@ -1,124 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.equinox.app">
-<annotation>
- <appInfo>
- <meta.schema plugin="org.eclipse.equinox.app" id="containers" name="Containers"/>
- </appInfo>
- <documentation>
- [Enter description of this extension point.]
- </documentation>
- </annotation>
-
- <element name="extension">
- <complexType>
- <sequence>
- <element ref="container"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="container">
- <complexType>
- <sequence>
- <element ref="run"/>
- </sequence>
- <attribute name="type" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="singleton" type="boolean" use="default" value="false">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="run">
- <complexType>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute kind="java" basedOn="org.eclipse.equinox.app.IContainer"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appInfo>
- <meta.section type="since"/>
- </appInfo>
- <documentation>
- [Enter the first release in which this extension point appears.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="examples"/>
- </appInfo>
- <documentation>
- [Enter extension point usage example here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="apiInfo"/>
- </appInfo>
- <documentation>
- [Enter API information here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="implementation"/>
- </appInfo>
- <documentation>
- [Enter information about supplied implementation of this extension point.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="copyright"/>
- </appInfo>
- <documentation>
-
- </documentation>
- </annotation>
-
-</schema>
diff --git a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/app/IAppContext.java b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/app/IAppContext.java
deleted file mode 100755
index 9f8c7666d..000000000
--- a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/app/IAppContext.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.equinox.app;
-
-import java.util.Map;
-import org.eclipse.equinox.registry.IConfigurationElement;
-import org.osgi.service.application.ApplicationDescriptor;
-
-/**
- * A context is used by a container to launch an application using
- * {@link IContainer#launch(IAppContext)}. The initial status of a
- * context is {@link #ACTIVE} when it is given to a container to
- * launch an application.
- * @see IApplication
- * @see IContainer
- * <p>
- * Clients may not implement this interface.
- * </p>
- * @since 3.2
- */
-public interface IAppContext {
- /**
- * Indicates the application is active for this context
- */
- public int ACTIVE = 0x01;
- /**
- * Indicates the application is stopping for this context
- */
- public int STOPPING = 0x02;
- /**
- * Indicates the application is stopped for this context
- */
- public int STOPPED = 0x04;
-
- /**
- * Returns the arguments to use when launching an application.
- * @return the arguments to use when launching an applicaiton, null may be returned.
- */
- public Map getArguments();
-
- /**
- * Returns the application descriptor for this context.
- * @return the application descriptor for this context.
- */
- public ApplicationDescriptor getApplicationDescriptor();
-
- /**
- * Returns the configuration element for this context.
- * @return the configuration element for this context.
- */
- public IConfigurationElement getConfiguration();
-
- /**
- * Called by the container when an application is stopping or has stopped.
- * @param status may be {@link #STOPPING} or {@link #STOPPED}
- * @see #STOPPING
- * @see #STOPPED
- * @throws IllegalArgumentException if {@link #ACTIVE} is used as the status.
- */
- public void setAppStatus(int status);
-
- /**
- * Returns the current app status according to the context
- * @return the current app status according to the context
- */
- public int getAppStatus();
-}
diff --git a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/app/IApplication.java b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/app/IApplication.java
deleted file mode 100755
index e83c0a87e..000000000
--- a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/app/IApplication.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.equinox.app;
-
-/**
- * Bootstrap type for an application. An IApplication represent executable
- * entry points into an application. An IApplication can be configured into
- * the Platform's <code>org.eclipse.equinox.applications</code> extension-point.
- *
- * <p>
- * Clients may implement this interface.
- * </p>
- *
- * @since 3.2
- */
-public interface IApplication {
-
- /**
- * Exit object indicating normal termination
- */
- public static final Integer EXIT_OK = new Integer(0);
-
- /**
- * Exit object requesting platform restart
- */
- public static final Integer EXIT_RESTART = new Integer(23);
-
- /**
- * Exit object requesting that the command passed back be executed. Typically
- * this is used to relaunch Eclipse with different command line arguments.
- */
- public static final Integer EXIT_RELAUNCH = new Integer(24);
-
- /**
- * Runs this application with the given args and returns a result.
- * The content of the args is unchecked and should conform to the expectations of
- * the runnable being invoked. Typically this is a <code>String</code> array. <p>
- *
- * Applications can return any object they like. If an <code>Integer</code> is returned
- * it is treated as the program exit code if Eclipse is exiting.
- * @return the return value of the application
- * @see #EXIT_OK
- * @see #EXIT_RESTART
- * @see #EXIT_RELAUNCH
- * @param args the argument(s) to pass to the application
- * @exception Exception if there is a problem running this application.
- */
- public Object run(Object args) throws Exception;
-
- /**
- * Forces a running application to exit. This method must block until the
- * running application has completely stopped.
- */
- public void stop();
-}
diff --git a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/app/IContainer.java b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/app/IContainer.java
deleted file mode 100755
index 6c9d2e5d1..000000000
--- a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/app/IContainer.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.equinox.app;
-
-/**
- * A container is used to launch applications.
- * @see IAppContext
- * @see IApplication
- * <p>
- * Clients may implement this interface.
- * </p>
- * @since 3.2
- */
-public interface IContainer {
- /**
- * Launch an application with the given application context. The given
- * context must have its {@link IAppContext#setAppStatus(int)} method called by
- * the container when the returned application has stopped.
- * @param context the application context to launch an application with
- * @return the application which was launched
- * @throws Exception if any errors occur while launching the application
- */
- IApplication launch(IAppContext context) throws Exception;
-
- /**
- * This method should shutdown the container and free any resources it may have
- * been using. All applications currently active in this container will be
- * asked to stop before this method is called.
- */
- void shutdown();
-}
diff --git a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/Activator.java b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/Activator.java
deleted file mode 100755
index 99da716f1..000000000
--- a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/Activator.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.equinox.internal.app;
-
-import org.eclipse.equinox.registry.IExtensionRegistry;
-import org.eclipse.osgi.service.debug.DebugOptions;
-import org.osgi.framework.*;
-import org.osgi.util.tracker.ServiceTracker;
-import org.osgi.util.tracker.ServiceTrackerCustomizer;
-
-public class Activator implements BundleActivator, ServiceTrackerCustomizer {
- public static final String PI_APP = "org.eclipse.equinox.app"; //$NON-NLS-1$
- public static boolean DEBUG = false;
- private BundleContext bContext;
- private ContainerManager containerMgr;
- // tracks the extension registry
- private ServiceTracker registryTracker;
-
- public void start(BundleContext context) throws Exception {
- this.bContext = context;
- getDebugOptions(context);
- // set the app manager context before starting the containerMgr
- AppPersistenceUtil.setBundleContext(context);
- registryTracker = new ServiceTracker(context, IExtensionRegistry.class.getName(), this);
- registryTracker.open();
- // start the app commands for the console
- try {
- AppCommands.create(context);
- } catch (NoClassDefFoundError e) {
- // catch incase CommandProvider is not available
- }
- }
-
- public void stop(BundleContext context) throws Exception {
- // stop the app commands for the console
- try {
- AppCommands.destroy(context);
- } catch (NoClassDefFoundError e) {
- // catch incase CommandProvider is not available
- }
- // close the registry tracker; this will stop the containerMgr if it was started
- registryTracker.close();
- registryTracker = null;
- // unset the app manager context after the containerMgr has been stopped
- AppPersistenceUtil.setBundleContext(null);
- bContext = null;
- }
-
- private void getDebugOptions(BundleContext context) {
- ServiceReference debugRef = context.getServiceReference(DebugOptions.class.getName());
- if (debugRef == null)
- return;
- DebugOptions debugOptions = (DebugOptions) context.getService(debugRef);
- DEBUG = debugOptions.getBooleanOption(PI_APP + "/debug", false); //$NON-NLS-1$
- context.ungetService(debugRef);
- }
-
- public Object addingService(ServiceReference reference) {
- if (containerMgr != null)
- return null;
- // create and start the app containerMgr
- IExtensionRegistry registry = (IExtensionRegistry) bContext.getService(reference);
- containerMgr = new ContainerManager(bContext, registry);
- containerMgr.startManager();
- return registry;
- }
-
- public void modifiedService(ServiceReference reference, Object service) {
- // do nothing
- }
-
- public void removedService(ServiceReference reference, Object service) {
- if (containerMgr == null)
- return;
- // stop the app containerMgr
- containerMgr.stopManager();
- containerMgr = null;
- }
-}
diff --git a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/AppCommands.java b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/AppCommands.java
deleted file mode 100755
index 06258a566..000000000
--- a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/AppCommands.java
+++ /dev/null
@@ -1,251 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.internal.app;
-
-import java.util.*;
-import org.eclipse.osgi.framework.console.CommandInterpreter;
-import org.eclipse.osgi.framework.console.CommandProvider;
-import org.osgi.framework.*;
-import org.osgi.service.application.*;
-import org.osgi.util.tracker.ServiceTracker;
-
-public class AppCommands implements CommandProvider {
- private final static String LAUNCHABLE_APP_FILTER = "(&(application.locked=false)(application.launchable=true)(application.visible=true))"; //$NON-NLS-1$
- private final static String ACTIVE_APP_FILTER = "(!(application.state=STOPPING))"; //$NON-NLS-1$
-
- private static AppCommands instance;
- private BundleContext context;
- private ServiceTracker appDescTracker;
- private ServiceTracker appHandleTracker;
- private ServiceTracker schedAppTracker;
- private Filter launchableApp;
- private Filter activeApp;
- private ServiceRegistration sr;
-
- static synchronized void create(BundleContext context) {
- if (instance != null)
- return;
- instance = new AppCommands();
- instance.start(context);
- }
-
- static synchronized void destroy(BundleContext context) {
- if (instance == null)
- return;
- instance.stop(context);
- instance = null;
- }
-
- protected AppCommands() {
- // empty
- }
-
- public void start(BundleContext ctx) {
- this.context = ctx;
- try {
- appDescTracker = new ServiceTracker(ctx, ApplicationDescriptor.class.getName(), null);
- appDescTracker.open();
- appHandleTracker = new ServiceTracker(ctx, ApplicationHandle.class.getName(), null);
- appHandleTracker.open();
- schedAppTracker = new ServiceTracker(ctx, ScheduledApplication.class.getName(), null);
- schedAppTracker.open();
- launchableApp = ctx.createFilter(LAUNCHABLE_APP_FILTER);
- activeApp = ctx.createFilter(ACTIVE_APP_FILTER);
- sr = ctx.registerService(CommandProvider.class.getName(), this, null);
- } catch (InvalidSyntaxException e) {
- // should not happen.
- }
- }
-
- public void stop(BundleContext ctx) {
- sr.unregister();
- if (appDescTracker != null)
- appDescTracker.close();
- if (appHandleTracker != null)
- appHandleTracker.close();
- if (schedAppTracker != null)
- schedAppTracker.close();
- }
-
- public String getHelp() {
- StringBuffer sb = new StringBuffer();
- sb.append("---Application Admin Commands---\n"); //$NON-NLS-1$
- sb.append("\tactiveApps - lists all running application IDs\n"); //$NON-NLS-1$
- sb.append("\tapps - lists all installed application IDs\n"); //$NON-NLS-1$
- sb.append("\tlockApp <application id> - locks the specified application ID\n"); //$NON-NLS-1$
- sb.append("\tschedApp <application id> <time filter> [true|false] - schedules the specified application id to launch at the specified time filter. Can optionally make the schedule recurring.\n"); //$NON-NLS-1$
- sb.append("\tstartApp <application id> - starts the specified application ID\n"); //$NON-NLS-1$
- sb.append("\tstopApp <application id> - stops the specified running application ID\n"); //$NON-NLS-1$
- sb.append("\tunlockApp <application id> - unlocks the specified application ID\n"); //$NON-NLS-1$
- sb.append("\tunschedApp <application id> - unschedules all scheduled applications with the specified application ID\n"); //$NON-NLS-1$
- return sb.toString();
- }
-
- private Dictionary getServiceProps(ServiceReference ref) {
- String[] keys = ref.getPropertyKeys();
- Hashtable props = new Hashtable(keys.length);
- for (int i = 0; i < keys.length; i++)
- props.put(keys[i], ref.getProperty(keys[i]));
- return props;
- }
-
- public void _apps(CommandInterpreter intp) {
- ServiceReference[] apps = appDescTracker.getServiceReferences();
- if (apps == null) {
- intp.println("No applications found."); //$NON-NLS-1$
- return;
- }
- for (int i = 0; i < apps.length; i++) {
- intp.print(apps[i].getProperty(ApplicationDescriptor.APPLICATION_PID));
- intp.print(" ["); //$NON-NLS-1$
- intp.print(launchableApp.match(getServiceProps(apps[i])) ? "enabled" : "disabled"); //$NON-NLS-1$ //$NON-NLS-2$
- intp.println("]"); //$NON-NLS-1$
- }
- }
-
- public void _activeApps(CommandInterpreter intp) {
- ServiceReference[] active = appHandleTracker.getServiceReferences();
- if (active == null) {
- intp.println("No active applications found"); //$NON-NLS-1$
- return;
- }
- for (int i = 0; i < active.length; i++) {
- intp.print(active[i].getProperty(ApplicationHandle.APPLICATION_PID));
- intp.print(" ["); //$NON-NLS-1$
- intp.print(activeApp.match(getServiceProps(active[i])) ? "running" : "stopping"); //$NON-NLS-1$ //$NON-NLS-2$
- intp.println("]"); //$NON-NLS-1$
- }
- }
-
- public void _startApp(CommandInterpreter intp) throws Exception {
- String appId = intp.nextArgument();
- ServiceReference[] apps = appDescTracker.getServiceReferences();
- if (apps != null)
- for (int i = 0; i < apps.length; i++)
- if (appId.equals(apps[i].getProperty(ApplicationDescriptor.APPLICATION_PID))) {
- if (launchableApp.match(getServiceProps(apps[i]))) {
- ArrayList argList = new ArrayList();
- String arg = null;
- while ((arg = intp.nextArgument()) != null)
- argList.add(arg);
- String[] args = argList.size() == 0 ? null : (String[]) argList.toArray(new String[argList.size()]);
- ApplicationDescriptor appDesc = (ApplicationDescriptor) context.getService(apps[i]);
- try {
- HashMap launchArgs = new HashMap(1);
- if (args != null)
- launchArgs.put(ContainerManager.PROP_ECLIPSE_APPLICATION_ARGS, args);
- appDesc.launch(launchArgs);
- intp.println("Launched application: " + appId); //$NON-NLS-1$
- } finally {
- context.ungetService(apps[i]);
- }
- } else {
- intp.println("Application is not enabled: " + appId); //$NON-NLS-1$
- }
- return;
- }
- intp.println("No application with the id \"" + appId + "\" exists."); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void _stopApp(CommandInterpreter intp) throws Exception {
- String runningId = intp.nextArgument();
- ServiceReference[] runningApps = appHandleTracker.getServiceReferences();
- if (runningApps != null)
- for (int i = 0; i < runningApps.length; i++)
- if (runningId.equals(runningApps[i].getProperty(ApplicationHandle.APPLICATION_PID))) {
- if (activeApp.match(getServiceProps(runningApps[i]))) {
- try {
- ApplicationHandle appDesc = (ApplicationHandle) context.getService(runningApps[i]);
- appDesc.destroy();
- intp.println("Stopped application: " + runningId); //$NON-NLS-1$
- } finally {
- context.ungetService(runningApps[i]);
- }
- } else {
- intp.println("Applicationi is already stopping: " + runningId); //$NON-NLS-1$
- }
- return;
- }
- intp.println("No running application with the id \"" + runningId + "\" exists."); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void _lockApp(CommandInterpreter intp) throws Exception {
- String appId = intp.nextArgument();
- ServiceReference[] apps = appDescTracker.getServiceReferences();
- if (apps != null)
- for (int i = 0; i < apps.length; i++)
- if (appId.equals(apps[i].getProperty(ApplicationDescriptor.APPLICATION_PID))) {
- try {
- ApplicationDescriptor appDesc = (ApplicationDescriptor) context.getService(apps[i]);
- appDesc.lock();
- intp.println("Locked application: " + appId); //$NON-NLS-1$
- } finally {
- context.ungetService(apps[i]);
- }
- return;
- }
- intp.println("No application with the id \"" + appId + "\" exists."); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void _unlockApp(CommandInterpreter intp) throws Exception {
- String appId = intp.nextArgument();
- ServiceReference[] apps = appDescTracker.getServiceReferences();
- if (apps != null)
- for (int i = 0; i < apps.length; i++)
- if (appId.equals(apps[i].getProperty(ApplicationDescriptor.APPLICATION_PID))) {
- try {
- ApplicationDescriptor appDesc = (ApplicationDescriptor) context.getService(apps[i]);
- appDesc.unlock();
- intp.println("Unlocked application: " + appId); //$NON-NLS-1$
- } finally {
- context.ungetService(apps[i]);
- }
- return;
- }
- intp.println("No application with the id \"" + appId + "\" exists."); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void _schedApp(CommandInterpreter intp) throws Exception {
- String appId = intp.nextArgument();
- ServiceReference[] apps = appDescTracker.getServiceReferences();
- if (apps != null)
- for (int i = 0; i < apps.length; i++)
- if (appId.equals(apps[i].getProperty(ApplicationDescriptor.APPLICATION_PID))) {
- try {
- ApplicationDescriptor appDesc = (ApplicationDescriptor) context.getService(apps[i]);
- String filter = intp.nextArgument();
- boolean recure = Boolean.valueOf(intp.nextArgument()).booleanValue();
- appDesc.schedule(null, "org/osgi/application/timer", filter, recure); //$NON-NLS-1$
- intp.println("scheduled application: " + appId); //$NON-NLS-1$
- } finally {
- context.ungetService(apps[i]);
- }
- return;
- }
- intp.println("No application with the id \"" + appId + "\" exists."); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void _unschedApp(CommandInterpreter intp) throws Exception {
- String schedId = intp.nextArgument();
- ServiceReference[] scheds = schedAppTracker.getServiceReferences();
- if (scheds != null)
- for (int i = 0; i < scheds.length; i++) {
- ScheduledApplication schedApp = (ScheduledApplication) context.getService(scheds[i]);
- try {
- if (schedId.equals(schedApp.getApplicationDescriptor().getApplicationId()))
- schedApp.remove();
- } finally {
- context.ungetService(scheds[i]);
- }
- }
-
- }
-}
diff --git a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/AppPersistenceUtil.java b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/AppPersistenceUtil.java
deleted file mode 100755
index e95118bf0..000000000
--- a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/AppPersistenceUtil.java
+++ /dev/null
@@ -1,589 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.equinox.internal.app;
-
-import java.io.*;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.*;
-import org.eclipse.osgi.service.datalocation.Location;
-import org.eclipse.osgi.service.environment.EnvironmentInfo;
-import org.eclipse.osgi.storagemanager.StorageManager;
-import org.osgi.framework.*;
-import org.osgi.service.application.ApplicationDescriptor;
-import org.osgi.service.application.ScheduledApplication;
-import org.osgi.service.event.*;
-import org.osgi.service.packageadmin.PackageAdmin;
-import org.osgi.util.tracker.ServiceTracker;
-
-/**
- * Manages all persistent data for ApplicationDescriptors (lock status,
- * scheduled applications etc.)
- */
-public class AppPersistenceUtil {
- private static final String PROP_CONFIG_AREA = "osgi.configuration.area"; //$NON-NLS-1$
-
- private static final String FILTER_PREFIX = "(&(objectClass=org.eclipse.osgi.service.datalocation.Location)(type="; //$NON-NLS-1$
- private static final String FILE_APPLOCKS = ".locks"; //$NON-NLS-1$
- private static final String FILE_APPSCHEDULED = ".scheduled"; //$NON-NLS-1$
- private static final String EVENT_HANDLER = "org.osgi.service.event.EventHandler"; //$NON-NLS-1$
- private static final String EVENT_TIMER_TOPIC = "org/osgi/application/timer"; //$NON-NLS-1$
-
- private static final int DATA_VERSION = 1;
- private static final byte NULL = 0;
- private static final int OBJECT = 1;
-
- // obsolete command line args
- private static final String NO_PACKAGE_PREFIXES = "-noPackagePrefixes"; //$NON-NLS-1$
- private static final String CLASSLOADER_PROPERTIES = "-classloaderProperties"; //$NON-NLS-1$
- private static final String PLUGINS = "-plugins"; //$NON-NLS-1$
- private static final String FIRST_USE = "-firstUse"; //$NON-NLS-1$
- private static final String NO_UPDATE = "-noUpdate"; //$NON-NLS-1$
- private static final String NEW_UPDATES = "-newUpdates"; //$NON-NLS-1$
- private static final String UPDATE = "-update"; //$NON-NLS-1$
- private static final String BOOT = "-boot"; //$NON-NLS-1$
-
- // command line args not used by app container
- private static final String KEYRING = "-keyring"; //$NON-NLS-1$
- private static final String PASSWORD = "-password"; //$NON-NLS-1$
-
- // command line args used by app container
- private static final String PRODUCT = "-product"; //$NON-NLS-1$
- private static final String FEATURE = "-feature"; //$NON-NLS-1$
- private static final String APPLICATION = "-application"; //$NON-NLS-1$
-
- private static BundleContext context;
- private static ServiceTracker configuration;
- private static ServiceTracker pkgAdminTracker;
- private static Collection locks = new ArrayList();
- private static Map scheduledApps = new HashMap();
- static ArrayList timerApps = new ArrayList();
- private static StorageManager storageManager;
- private static boolean dirty;
- private static boolean scheduling = false;
- static boolean shutdown = false;
- private static int nextScheduledID = 1;
- private static Thread timerThread;
- private static String[] appArgs;
-
- static synchronized void setBundleContext(BundleContext context) {
- if (context != null) {
- AppPersistenceUtil.context = context;
- init();
- } else {
- shutdown();
- AppPersistenceUtil.context = context;
- }
- }
-
- private static void init() {
- shutdown = false;
- appArgs = processCommandLine();
- initPackageAdmin();
- initConfiguration();
- loadData(FILE_APPLOCKS);
- loadData(FILE_APPSCHEDULED);
- }
-
- private static void shutdown() {
- shutdown = true;
- stopTimer();
- saveData();
- if (storageManager != null) {
- storageManager.close();
- storageManager = null;
- }
- closeConfiguration();
- closePackageAdmin();
- appArgs = null;
- }
-
- private static void initPackageAdmin() {
- closePackageAdmin(); // just incase
- pkgAdminTracker = new ServiceTracker(context, PackageAdmin.class.getName(), null);
- pkgAdminTracker.open();
- }
-
- private static void closePackageAdmin() {
- if (pkgAdminTracker != null)
- pkgAdminTracker.close();
- pkgAdminTracker = null;
- }
-
- private static void initConfiguration() {
- closeConfiguration(); // just incase
- Filter filter = null;
- try {
- filter = context.createFilter(FILTER_PREFIX + PROP_CONFIG_AREA + "))"); //$NON-NLS-1$
- } catch (InvalidSyntaxException e) {
- // ignore this. It should never happen as we have tested the above format.
- }
- configuration = new ServiceTracker(context, filter, null);
- configuration.open();
- }
-
- private static void closeConfiguration() {
- if (configuration != null)
- configuration.close();
- configuration = null;
- }
-
- /**
- * Used by {@link ApplicationDescriptor} to determine if an application is locked.
- * @param desc the application descriptor
- * @return true if the application is persistently locked.
- */
- public synchronized static boolean isLocked(ApplicationDescriptor desc) {
- return locks.contains(desc.getApplicationId());
- }
-
- /**
- * Used by {@link ApplicationDescriptor} to determine lock and unlock and application.
- * @param desc the application descriptor
- * @param locked the locked flag
- */
- public synchronized static void saveLock(ApplicationDescriptor desc, boolean locked) {
- if (locked) {
- if (!locks.contains(desc.getApplicationId())) {
- dirty = true;
- locks.add(desc.getApplicationId());
- }
- } else if (locks.remove(desc.getApplicationId())) {
- dirty = true;
- }
- }
-
- synchronized static void removeScheduledApp(EclipseScheduledApplication scheduledApp) {
- if (scheduledApps.remove(scheduledApp.getID()) != null) {
- timerApps.remove(scheduledApp);
- dirty = true;
- }
- }
-
- /**
- * Used by {@link ScheduledApplication} to persistently schedule an application launch
- * @param descriptor
- * @param arguments
- * @param topic
- * @param eventFilter
- * @param recurring
- * @return the scheduled application
- * @throws InvalidSyntaxException
- */
- public synchronized static ScheduledApplication addScheduledApp(ApplicationDescriptor descriptor, Map arguments, String topic, String eventFilter, boolean recurring) throws InvalidSyntaxException {
- if (!scheduling && !checkSchedulingSupport())
- throw new UnsupportedOperationException("Cannot support scheduling without org.osgi.service.event package"); //$NON-NLS-1$
- // check the event filter for correct syntax
- context.createFilter(eventFilter);
- EclipseScheduledApplication result = new EclipseScheduledApplication(context, getNextScheduledID(), descriptor.getApplicationId(), arguments, topic, eventFilter, recurring);
- addScheduledApp(result);
- dirty = true;
- return result;
- }
-
- private static void addScheduledApp(EclipseScheduledApplication scheduledApp) {
- if (EVENT_TIMER_TOPIC.equals(scheduledApp.getTopic())) {
- timerApps.add(scheduledApp);
- if (timerThread == null)
- startTimer();
- }
- scheduledApps.put(scheduledApp.getID(), scheduledApp);
- Hashtable serviceProps = new Hashtable();
- if (scheduledApp.getTopic() != null)
- serviceProps.put(EventConstants.EVENT_TOPIC, new String[] {scheduledApp.getTopic()});
- if (scheduledApp.getEventFilter() != null)
- serviceProps.put(EventConstants.EVENT_FILTER, scheduledApp.getEventFilter());
- ServiceRegistration sr = context.registerService(new String[] {ScheduledApplication.class.getName(), EVENT_HANDLER}, scheduledApp, serviceProps);
- scheduledApp.setServiceRegistration(sr);
- }
-
- private static Integer getNextScheduledID() {
- if (nextScheduledID == Integer.MAX_VALUE)
- nextScheduledID = 0;
- Integer result = new Integer(nextScheduledID++);
- while (scheduledApps.get(result) != null && nextScheduledID < Integer.MAX_VALUE)
- result = new Integer(nextScheduledID++);
- if (nextScheduledID == Integer.MAX_VALUE)
- throw new IllegalStateException("Maximum number of scheduled applications reached"); //$NON-NLS-1$
- return result;
- }
-
- private static boolean checkSchedulingSupport() {
- // cannot support scheduling without the event admin package
- try {
- Class.forName(EVENT_HANDLER);
- scheduling = true;
- return true;
- } catch (ClassNotFoundException e) {
- scheduling = false;
- return false;
- }
- }
-
- private synchronized static boolean loadData(String fileName) {
- try {
- Location location = (Location) configuration.getService();
- if (location == null)
- return false;
- File theStorageDir = new File(location.getURL().getPath() + '/' + Activator.PI_APP);
- boolean readOnly = location.isReadOnly();
- storageManager = new StorageManager(theStorageDir, readOnly ? "none" : null, readOnly); //$NON-NLS-1$
- storageManager.open(!readOnly);
- File dataFile = storageManager.lookup(fileName, false);
- if (dataFile == null || !dataFile.isFile()) {
- Location parent = location.getParentLocation();
- if (parent != null) {
- theStorageDir = new File(parent.getURL().getPath() + '/' + Activator.PI_APP);
- StorageManager tmp = new StorageManager(theStorageDir, "none", true); //$NON-NLS-1$
- tmp.open(false);
- dataFile = tmp.lookup(fileName, false);
- tmp.close();
- }
- }
- if (dataFile == null || !dataFile.isFile())
- return true;
- if (fileName.equals(FILE_APPLOCKS))
- loadLocks(dataFile);
- else if (fileName.equals(FILE_APPSCHEDULED))
- loadSchedules(dataFile);
- } catch (IOException e) {
- return false;
- }
- return true;
- }
-
- private static void loadLocks(File locksData) throws IOException {
- ObjectInputStream in = null;
- try {
- in = new ObjectInputStream(new FileInputStream(locksData));
- int dataVersion = in.readInt();
- if (dataVersion != DATA_VERSION)
- return;
- int numLocks = in.readInt();
- for (int i = 0; i < numLocks; i++)
- locks.add(in.readUTF());
- } finally {
- if (in != null)
- in.close();
- }
- }
-
- private static void loadSchedules(File schedulesData) throws IOException {
- ObjectInputStream in = null;
- try {
- in = new ObjectInputStream(new FileInputStream(schedulesData));
- int dataVersion = in.readInt();
- if (dataVersion != DATA_VERSION)
- return;
- int numScheds = in.readInt();
- for (int i = 0; i < numScheds; i++) {
- Integer id = new Integer(in.readInt());
- String appPid = readString(in, false);
- String topic = readString(in, false);
- String eventFilter = readString(in, false);
- boolean recurring = in.readBoolean();
- Map args = (Map) in.readObject();
- EclipseScheduledApplication schedApp = new EclipseScheduledApplication(context, id, appPid, args, topic, eventFilter, recurring);
- addScheduledApp(schedApp);
- }
- } catch (InvalidSyntaxException e) {
- throw new IOException(e.getMessage());
- } catch (NoClassDefFoundError e) {
- throw new IOException(e.getMessage());
- } catch (ClassNotFoundException e) {
- throw new IOException(e.getMessage());
- } finally {
- if (in != null)
- in.close();
- }
- }
-
- private synchronized static void saveData() {
- if (!dirty || storageManager.isReadOnly())
- return;
- try {
- File locksData = storageManager.createTempFile(FILE_APPLOCKS);
- saveLocks(locksData);
- File schedulesData = storageManager.createTempFile(FILE_APPSCHEDULED);
- saveSchedules(schedulesData);
- storageManager.lookup(FILE_APPLOCKS, true);
- storageManager.lookup(FILE_APPSCHEDULED, true);
- storageManager.update(new String[] {FILE_APPLOCKS, FILE_APPSCHEDULED}, new String[] {locksData.getName(), schedulesData.getName()});
- } catch (IOException e) {
- // TODO should log this!!
- }
- dirty = false;
- }
-
- private static void saveLocks(File locksData) throws IOException {
- ObjectOutputStream out = null;
- try {
- out = new ObjectOutputStream(new FileOutputStream(locksData));
- out.writeInt(DATA_VERSION);
- out.writeInt(locks.size());
- for (Iterator iterLocks = locks.iterator(); iterLocks.hasNext();)
- out.writeUTF((String) iterLocks.next());
- } finally {
- if (out != null)
- out.close();
- }
- }
-
- private static void saveSchedules(File schedulesData) throws IOException {
- ObjectOutputStream out = null;
- try {
- out = new ObjectOutputStream(new FileOutputStream(schedulesData));
- out.writeInt(DATA_VERSION);
- out.writeInt(scheduledApps.size());
- for (Iterator apps = scheduledApps.values().iterator(); apps.hasNext();) {
- EclipseScheduledApplication app = (EclipseScheduledApplication) apps.next();
- out.writeInt(app.getID().intValue());
- writeStringOrNull(out, app.getAppPid());
- writeStringOrNull(out, app.getTopic());
- writeStringOrNull(out, app.getEventFilter());
- out.writeBoolean(app.isRecurring());
- out.writeObject(app.getArguments());
- }
- } finally {
- if (out != null)
- out.close();
- }
- }
-
- private static void startTimer() {
- timerThread = new Thread(new AppTimer(), "app schedule timer"); //$NON-NLS-1$
- timerThread.start();
- }
-
- private static void stopTimer() {
- if (timerThread != null)
- timerThread.interrupt();
- timerThread = null;
- }
-
- private static class AppTimer implements Runnable {
- public void run() {
- int lastMin = -1;
- while (!shutdown) {
- try {
- Thread.sleep(30000); // sleeping 30 secs instead of 60 to try to avoid skipping minutes
- Calendar cal = Calendar.getInstance();
- int minute = cal.get(Calendar.MINUTE);
- if (minute == lastMin)
- continue;
- lastMin = minute;
- Hashtable props = new Hashtable();
- props.put("year", new Integer(cal.get(Calendar.YEAR))); //$NON-NLS-1$
- props.put("month", new Integer(cal.get(Calendar.MONTH))); //$NON-NLS-1$
- props.put("day_of_month", new Integer(cal.get(Calendar.DAY_OF_MONTH))); //$NON-NLS-1$
- props.put("day_of_week", new Integer(cal.get(Calendar.DAY_OF_WEEK))); //$NON-NLS-1$
- props.put("hour_of_day", new Integer(cal.get(Calendar.HOUR_OF_DAY))); //$NON-NLS-1$
- props.put("minute", new Integer(minute)); //$NON-NLS-1$
- Event timerEvent = new Event(EVENT_TIMER_TOPIC, props);
- synchronized (AppPersistenceUtil.class) {
- // poor mans implementation of dispatching events; the spec will not allow us to use event admin to dispatch the virtual timer events; boo!!
- if (timerApps.size() == 0)
- continue;
- EclipseScheduledApplication[] apps = (EclipseScheduledApplication[]) timerApps.toArray(new EclipseScheduledApplication[timerApps.size()]);
- for (int i = 0; i < apps.length; i++) {
- try {
- String filterString = apps[i].getEventFilter();
- Filter filter = filterString == null ? null : FrameworkUtil.createFilter(filterString);
- if (filter == null || filter.match(props))
- apps[i].handleEvent(timerEvent);
- } catch (Throwable t) {
- t.printStackTrace();
- // TODO should log this
- }
- }
- }
- } catch (InterruptedException e) {
- // do nothing;
- }
- }
- }
- }
-
- private static String readString(ObjectInputStream in, boolean intern) throws IOException {
- byte type = in.readByte();
- if (type == NULL)
- return null;
- return intern ? in.readUTF().intern() : in.readUTF();
- }
-
- private static void writeStringOrNull(ObjectOutputStream out, String string) throws IOException {
- if (string == null)
- out.writeByte(NULL);
- else {
- out.writeByte(OBJECT);
- out.writeUTF(string);
- }
- }
-
- public static Bundle getBundle(String symbolicName) {
- PackageAdmin packageAdmin = (PackageAdmin) getService(pkgAdminTracker);
- if (packageAdmin == null)
- return null;
- Bundle[] bundles = packageAdmin.getBundles(symbolicName, null);
- if (bundles == null)
- return null;
- //Return the first bundle that is not installed or uninstalled
- for (int i = 0; i < bundles.length; i++)
- if ((bundles[i].getState() & (Bundle.INSTALLED | Bundle.UNINSTALLED)) == 0)
- return bundles[i];
- return null;
- }
-
- /**
- * Returns the default application args that should be used to launch an application
- * when args are not supplied.
- * @return the default application args.
- */
- public static String[] getApplicationArgs() {
- return appArgs;
- }
-
- private static String[] processCommandLine() {
- ServiceReference infoRef = context.getServiceReference(EnvironmentInfo.class.getName());
- if (infoRef == null)
- return null;
- EnvironmentInfo envInfo = (EnvironmentInfo) context.getService(infoRef);
- if (envInfo == null)
- return null;
- String[] args = envInfo.getNonFrameworkArgs();
- context.ungetService(infoRef);
- if (args == null)
- return args;
- if (args.length == 0)
- return args;
-
- int[] configArgs = new int[args.length];
- //need to initialize the first element to something that could not be an index.
- configArgs[0] = -1;
- int configArgIndex = 0;
- for (int i = 0; i < args.length; i++) {
- boolean found = false;
- // check for args without parameters (i.e., a flag arg)
-
- // consume obsolete args
- if (args[i].equalsIgnoreCase(CLASSLOADER_PROPERTIES))
- found = true; // ignored
- if (args[i].equalsIgnoreCase(NO_PACKAGE_PREFIXES))
- found = true; // ignored
- if (args[i].equalsIgnoreCase(PLUGINS))
- found = true; // ignored
- if (args[i].equalsIgnoreCase(FIRST_USE))
- found = true; // ignored
- if (args[i].equalsIgnoreCase(NO_UPDATE))
- found = true; // ignored
- if (args[i].equalsIgnoreCase(NEW_UPDATES))
- found = true; // ignored
- if (args[i].equalsIgnoreCase(UPDATE))
- found = true; // ignored
-
- // done checking for args. Remember where an arg was found
- if (found) {
- configArgs[configArgIndex++] = i;
- continue;
- }
- // check for args with parameters
- if (i == args.length - 1 || args[i + 1].startsWith("-")) //$NON-NLS-1$
- continue;
- String arg = args[++i];
-
- // consume args not used by app container
- if (args[i - 1].equalsIgnoreCase(KEYRING))
- found = true;
- if (args[i - 1].equalsIgnoreCase(PASSWORD))
- found = true;
-
- // consume obsolete args for compatibilty
- if (args[i - 1].equalsIgnoreCase(CLASSLOADER_PROPERTIES))
- found = true; // ignore
- if (args[i - 1].equalsIgnoreCase(BOOT))
- found = true; // ignore
-
- // look for the product to run
- // treat -feature as a synonym for -product for compatibility.
- if (args[i - 1].equalsIgnoreCase(PRODUCT) || args[i - 1].equalsIgnoreCase(FEATURE)) {
- // use the long way to set the property to compile against eeminimum
- System.getProperties().setProperty(ContainerManager.PROP_PRODUCT, arg);
- found = true;
- }
-
- // look for the application to run.
- if (args[i - 1].equalsIgnoreCase(APPLICATION)) {
- // use the long way to set the property to compile against eeminimum
- System.getProperties().setProperty(ContainerManager.PROP_ECLIPSE_APPLICATION, arg);
- found = true;
- }
-
- // done checking for args. Remember where an arg was found
- if (found) {
- configArgs[configArgIndex++] = i - 1;
- configArgs[configArgIndex++] = i;
- }
- }
-
- // remove all the arguments consumed by this argument parsing
- if (configArgIndex == 0) {
- appArgs = args;
- return args;
- }
- appArgs = new String[args.length - configArgIndex];
- configArgIndex = 0;
- int j = 0;
- for (int i = 0; i < args.length; i++) {
- if (i == configArgs[configArgIndex])
- configArgIndex++;
- else
- appArgs[j++] = args[i];
- }
- return appArgs;
- }
-
- static void openTracker(final ServiceTracker tracker, final boolean allServices) {
- if (System.getSecurityManager() == null)
- tracker.open(allServices);
- else
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- tracker.open(allServices);
- return null;
- }
- });
- }
-
- static Object getService(final ServiceTracker tracker) {
- if (System.getSecurityManager() == null)
- return tracker.getService();
- return AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- return tracker.getService();
- }
- });
- }
-
- static String getLocation(final Bundle bundle) {
- if (System.getSecurityManager() == null)
- return bundle.getLocation();
- return (String) AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- return bundle.getLocation();
- }
- });
- }
-
- static BundleContext getContext() {
- return context;
- }
-}
diff --git a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/ContainerManager.java b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/ContainerManager.java
deleted file mode 100755
index 8920964fd..000000000
--- a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/ContainerManager.java
+++ /dev/null
@@ -1,499 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.equinox.internal.app;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.*;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.equinox.app.IContainer;
-import org.eclipse.equinox.registry.*;
-import org.eclipse.osgi.framework.log.FrameworkLog;
-import org.eclipse.osgi.framework.log.FrameworkLogEntry;
-import org.eclipse.osgi.util.NLS;
-import org.osgi.framework.*;
-import org.osgi.service.application.ApplicationDescriptor;
-import org.osgi.service.application.ApplicationHandle;
-import org.osgi.util.tracker.ServiceTracker;
-
-/*
- * A MEG application container that understands eclipse applications. This
- * container will discover installed eclipse applications and register the
- * appropriate ApplicatoinDescriptor service with the service registry.
- * It also manages container extensions which are uses to launch
- * different application types.
- */
-public class ContainerManager implements IRegistryChangeListener, SynchronousBundleListener {
- private static final String PI_RUNTIME = "org.eclipse.core.runtime"; //$NON-NLS-1$
- private static final String PT_APPLICATIONS = "applications"; //$NON-NLS-1$
- private static final String PT_APP_TYPE = "type"; //$NON-NLS-1$
- private static final String PT_APP_VISIBLE = "visible"; //$NON-NLS-1$
- private static final String PT_APP_SINGLETON = "singleton"; //$NON-NLS-1$
- private static final String PT_RUN = "run"; //$NON-NLS-1$
- private static final String PT_PRODUCTS = "products"; //$NON-NLS-1$
- private static final String PT_CONTAINERS = "containers"; //$NON-NLS-1$
- private static final String ATTR_APPLICATION = "application"; //$NON-NLS-1$
- private static final String EXT_ERROR_APP = "org.eclipse.equinox.app.error"; //$NON-NLS-1$
- static final String APP_TYPE_MAIN_THREAD = "main.thread"; //$NON-NLS-1$
-
- public static final String PROP_PRODUCT = "eclipse.product"; //$NON-NLS-1$
- public static final String PROP_ECLIPSE_APPLICATION = "eclipse.application"; //$NON-NLS-1$
- public static final String PROP_ECLIPSE_APPLICATION_ARGS = "eclipse.application.args"; //$NON-NLS-1$
- public static final String PROP_ECLIPSE_APPLICATION_NODEFAULT = "eclipse.application.noDefault"; //$NON-NLS-1$
-
- BundleContext context;
- // A map of ApplicationDescriptors keyed by eclipse application ID
- private HashMap apps = new HashMap();
- // A map of containers keyed by application type
- private HashMap containers = new HashMap();
- // tracks the FrameworkLog
- private ServiceTracker frameworkLog;
- private boolean missingProductReported;
- private IExtensionRegistry extensionRegistry;
-
- public ContainerManager(BundleContext context, IExtensionRegistry extensionRegistry) {
- this.context = context;
- this.extensionRegistry = extensionRegistry;
- }
-
- void startManager() {
- frameworkLog = new ServiceTracker(context, FrameworkLog.class.getName(), null);
- frameworkLog.open();
- getExtensionRegistry().addRegistryChangeListener(this);
- registerAppDecriptors();
- // need to listen for system bundle stopping
- context.addBundleListener(this);
- // Start the default application
- startDefaultApp();
- }
-
- void stopManager() {
- // stop all applications and containers first
- stopAll();
- context.removeBundleListener(this);
- getExtensionRegistry().removeRegistryChangeListener(this);
- frameworkLog.close();
- frameworkLog = null;
- // flush the apps and containers
- apps.clear();
- containers.clear();
- }
-
- /*
- * Only used to find the default application
- */
- private EclipseAppDescriptor getAppDescriptor(String applicationId) {
- EclipseAppDescriptor result = null;
- synchronized (apps) {
- result = (EclipseAppDescriptor) apps.get(applicationId);
- }
- if (result == null) {
- registerAppDecriptors(); // try again just in case we are waiting for an event
- synchronized (apps) {
- result = (EclipseAppDescriptor) apps.get(applicationId);
- }
- }
- return result;
- }
-
- EclipseAppDescriptor[] getAppDescriptorsByType(String type) {
- ArrayList result = new ArrayList();
- synchronized (apps) {
- for (Iterator iApps = apps.values().iterator(); iApps.hasNext();) {
- EclipseAppDescriptor app = (EclipseAppDescriptor) iApps.next();
- if (type.equals(app.getType()))
- result.add(app);
- }
- }
- return (EclipseAppDescriptor[]) result.toArray(new EclipseAppDescriptor[result.size()]);
- }
-
- private IContainer getContainer(String type) {
- synchronized (containers) {
- IContainer container = (IContainer) containers.get(type);
- if (container != null)
- return container;
- container = createContainer(type);
- if (container != null)
- containers.put(type, container);
- return container;
- }
- }
-
- private EclipseAppDescriptor createAppDescriptor(IExtension appExtension) {
- synchronized (apps) {
- EclipseAppDescriptor appDescriptor = (EclipseAppDescriptor) apps.get(appExtension.getUniqueIdentifier());
- if (appDescriptor != null)
- return appDescriptor;
- // the appDescriptor does not exist for the app ID; create it
- IConfigurationElement[] configs = appExtension.getConfigurationElements();
- String type = null;
- boolean visible = true;
- if (configs.length > 0) {
- type = configs[0].getAttribute(PT_APP_TYPE);
- String sVisible = configs[0].getAttribute(PT_APP_VISIBLE);
- visible = sVisible == null ? true : Boolean.valueOf(sVisible).booleanValue();
- }
- appDescriptor = new EclipseAppDescriptor(appExtension.getNamespace(), appExtension.getUniqueIdentifier(), type, visible, this);
- // register the appDescriptor as a service
- ServiceRegistration sr = (ServiceRegistration) AccessController.doPrivileged(new RegisterService(ApplicationDescriptor.class.getName(), appDescriptor, appDescriptor.getServiceProperties()));
- appDescriptor.setServiceRegistration(sr);
- // save the app descriptor in the cache
- apps.put(appExtension.getUniqueIdentifier(), appDescriptor);
- return appDescriptor;
- }
- }
-
- private EclipseAppDescriptor removeAppDescriptor(String applicationId) {
- synchronized (apps) {
- EclipseAppDescriptor appDescriptor = (EclipseAppDescriptor) apps.remove(applicationId);
- if (appDescriptor == null)
- return null;
- appDescriptor.unregister();
- return appDescriptor;
- }
- }
-
- /*
- * Gives access to the RegisterService privileged action.
- */
- PrivilegedAction getRegServiceAction(String serviceClass, Object serviceObject, Dictionary serviceProps) {
- return new RegisterService(serviceClass, serviceObject, serviceProps);
- }
-
- /*
- * PrivilegedAction used to register ApplicationDescriptor and ApplicationHandle services
- */
- private class RegisterService implements PrivilegedAction {
- String serviceClass;
- Object serviceObject;
- Dictionary serviceProps;
-
- RegisterService(String serviceClass, Object serviceObject, Dictionary serviceProps) {
- this.serviceClass = serviceClass;
- this.serviceObject = serviceObject;
- this.serviceProps = serviceProps;
- }
-
- public Object run() {
- return context.registerService(serviceClass, serviceObject, serviceProps);
- }
- }
-
- private void startDefaultApp() {
- if (!Boolean.getBoolean(ContainerManager.PROP_ECLIPSE_APPLICATION_NODEFAULT)) {
- // find the default application
- EclipseAppDescriptor defaultDesc = findDefaultApp();
- // if the default app is a main thread one then we have to just tell the
- // main thread container about the default app so it can launch it when it is ready
- if (APP_TYPE_MAIN_THREAD.equals(defaultDesc.getType())) {
- MainThreadContainer container = (MainThreadContainer) ((SingletonContainer) getContainer(APP_TYPE_MAIN_THREAD)).getContainer();
- container.setDefaultApp(defaultDesc);
- } else
- // just launch the default application
- try {
- defaultDesc.launch(null);
- } catch (Exception e) {
- // TODO should log this!!
- }
- }
- }
-
- private EclipseAppDescriptor findDefaultApp() {
- String applicationId = System.getProperty(PROP_ECLIPSE_APPLICATION);
- if (applicationId == null) {
- //Derive the application from the product information
- applicationId = getProductAppId();
- if (applicationId != null)
- // use the long way to set the property to compile against eeminimum
- System.getProperties().setProperty(PROP_ECLIPSE_APPLICATION, applicationId);
- }
- if (applicationId == null) {
- // the application id is not set; return a descriptor that will throw an exception
- // return new EclipseAppDescriptor(Activator.PI_APP, Activator.PI_APP + ".missingapp", null, false, this, new RuntimeException(Messages.application_noIdFound)); //$NON-NLS-1$
- ErrorApplication.setError(new RuntimeException(Messages.application_noIdFound));
- return getAppDescriptor(EXT_ERROR_APP);
- }
- EclipseAppDescriptor defaultApp = getAppDescriptor(applicationId);
- if (defaultApp == null) {
- // the application id is not available in the registry; return a descriptor that will throw an exception
- //return new EclipseAppDescriptor(applicationId, applicationId, null, false, this, new RuntimeException(NLS.bind(Messages.application_notFound, applicationId, getAvailableAppsMsg(getExtensionRegistry()))));
- ErrorApplication.setError(new RuntimeException(NLS.bind(Messages.application_notFound, applicationId, getAvailableAppsMsg(getExtensionRegistry()))));
- return getAppDescriptor(EXT_ERROR_APP);
- }
- return defaultApp;
- }
-
- /*
- * Registers an ApplicationDescriptor service for each eclipse application
- * available in the extension registry.
- */
- private void registerAppDecriptors() {
- // look in the old core.runtime applications extension point
- IExtension[] availableApps = getAvailableApps(getExtensionRegistry(), PI_RUNTIME);
- for (int i = 0; i < availableApps.length; i++)
- createAppDescriptor(availableApps[i]);
- // look in the new equinox.app applications extinsion point
- availableApps = getAvailableApps(getExtensionRegistry(), Activator.PI_APP);
- for (int i = 0; i < availableApps.length; i++)
- createAppDescriptor(availableApps[i]);
- }
-
- private IContainer createContainer(String type) {
- IExtensionPoint extPoint = getExtensionRegistry().getExtensionPoint(Activator.PI_APP, PT_CONTAINERS);
- if (extPoint == null)
- return null;
- IExtension[] availableContainers = extPoint.getExtensions();
- for (int i = 0; i < availableContainers.length; i++) {
- IConfigurationElement[] configs = availableContainers[i].getConfigurationElements();
- if (configs.length == 0)
- return null;
- String containerType = configs[0].getAttribute(PT_APP_TYPE);
- if (type.equals(containerType)) {
- boolean singleton = Boolean.valueOf(configs[0].getAttribute(PT_APP_SINGLETON)).booleanValue();
- return createContainer(configs[0], type, singleton);
- }
- }
- return null;
- }
-
- private IContainer createContainer(IConfigurationElement config, String type, boolean singleton) {
- try {
- IContainer container = (IContainer) config.createExecutableExtension(PT_RUN);
- if (singleton)
- container = new SingletonContainer(container, type, this);
- return container;
- } catch (CoreException e) {
- // TODO should log this
- e.printStackTrace();
- }
- return null;
- }
-
- private IContainer removeContainer(IExtension containerExt) {
- IConfigurationElement[] configs = containerExt.getConfigurationElements();
- if (configs.length == 0)
- return null;
- String type = configs[0].getAttribute(PT_APP_TYPE);
- if (type == null)
- return null;
- // stop all applications for the container first
- stopAllApplications(type);
- IContainer result = null;
- synchronized (containers) {
- result = (IContainer) containers.remove(type);
- }
- // shutdown the container
- if (result != null)
- result.shutdown();
- return result;
- }
-
- /*
- * Returns a list of all the available application IDs which are available
- * in the extension registry.
- */
- private IExtension[] getAvailableApps(IExtensionRegistry registry, String pi) {
- IExtensionPoint point = registry.getExtensionPoint(pi + '.' + PT_APPLICATIONS);
- if (point == null)
- return new IExtension[0];
- return point.getExtensions();
- }
-
- private String getAvailableAppsMsg(IExtensionRegistry registry) {
- IExtension[] availableApps = getAvailableApps(registry, PI_RUNTIME);
- String availableAppsMsg = "<NONE>"; //$NON-NLS-1$
- if (availableApps.length != 0) {
- availableAppsMsg = availableApps[0].getUniqueIdentifier();
- for (int i = 1; i < availableApps.length; i++)
- availableAppsMsg = availableAppsMsg + ", " + availableApps[i].getUniqueIdentifier(); //$NON-NLS-1$
- }
- availableApps = getAvailableApps(registry, Activator.PI_APP);
- if (availableApps.length != 0) {
- if (!availableAppsMsg.equals("<NONE>")) //$NON-NLS-1$
- availableAppsMsg = availableAppsMsg + ", "; //$NON-NLS-1$
- availableAppsMsg = availableAppsMsg + availableApps[0].getUniqueIdentifier();
- for (int i = 1; i < availableApps.length; i++)
- availableAppsMsg = availableAppsMsg + ", " + availableApps[i].getUniqueIdentifier(); //$NON-NLS-1$
- }
- return availableAppsMsg;
- }
-
- /*
- * Returns the application extension for the specified applicaiton ID.
- * A RuntimeException is thrown if the extension does not exist for the
- * given application ID.
- */
- IExtension getAppExtension(String applicationId) {
- IExtensionRegistry registry = getExtensionRegistry();
- IExtension applicationExtension = registry.getExtension(PI_RUNTIME, PT_APPLICATIONS, applicationId);
- if (applicationExtension == null)
- applicationExtension = registry.getExtension(Activator.PI_APP, PT_APPLICATIONS, applicationId);
- if (applicationExtension == null)
- throw new RuntimeException(NLS.bind(Messages.application_notFound, applicationId, getAvailableAppsMsg(registry)));
- return applicationExtension;
- }
-
- private IExtensionRegistry getExtensionRegistry() {
- return extensionRegistry;
- }
-
- private FrameworkLog getFrameworkLog() {
- return (FrameworkLog) AppPersistenceUtil.getService(frameworkLog);
- }
-
- private String getProductAppId() {
- String productId = System.getProperty(PROP_PRODUCT);
- if (productId == null)
- return null;
- IConfigurationElement[] entries = getExtensionRegistry().getConfigurationElementsFor(PI_RUNTIME, PT_PRODUCTS, productId);
- if (entries.length > 0)
- // There should only be one product with the given id so just take the first element
- return entries[0].getAttribute(ATTR_APPLICATION);
- IConfigurationElement[] elements = getExtensionRegistry().getConfigurationElementsFor(PI_RUNTIME, PT_PRODUCTS);
- List logEntries = null;
- for (int i = 0; i < elements.length; i++) {
- IConfigurationElement element = elements[i];
- if (element.getName().equalsIgnoreCase("provider")) { //$NON-NLS-1$
- try {
- Object provider = element.createExecutableExtension(PT_RUN);
- Object[] products = (Object[]) ContainerManager.execMethod(provider, "getProducts", null, null); //$NON-NLS-1$
- for (int j = 0; j < products.length; j++) {
- Object provided = products[j];
- if (productId.equalsIgnoreCase((String) ContainerManager.execMethod(provided, "getId", null, null))) //$NON-NLS-1$
- return (String) ContainerManager.execMethod(provided, "getApplication", null, null); //$NON-NLS-1$
- }
- } catch (CoreException e) {
- if (logEntries == null)
- logEntries = new ArrayList(3);
- logEntries.add(new FrameworkLogEntry(Activator.PI_APP, NLS.bind(Messages.provider_invalid, element.getParent().toString()), 0, e, null));
- }
- }
- }
- if (logEntries != null)
- getFrameworkLog().log(new FrameworkLogEntry(Activator.PI_APP, Messages.provider_invalid_general, 0, null, (FrameworkLogEntry[]) logEntries.toArray()));
-
- if (!missingProductReported) {
- getFrameworkLog().log(new FrameworkLogEntry(Activator.PI_APP, NLS.bind(Messages.product_notFound, productId), 0, null, null));
- missingProductReported = true;
- }
- return null;
- }
-
- public static Object execMethod(Object obj, String methodName, Class argType, Object arg) {
- try {
- Method method = obj.getClass().getMethod(methodName, argType == null ? null : new Class[] {argType});
- return method.invoke(obj, arg == null ? null : new Object[] {arg});
- } catch (NoSuchMethodException e) {
- throw new IllegalArgumentException(e.getMessage());
- } catch (IllegalArgumentException e) {
- throw new IllegalArgumentException(e.getMessage());
- } catch (IllegalAccessException e) {
- throw new IllegalArgumentException(e.getMessage());
- } catch (InvocationTargetException e) {
- throw new IllegalArgumentException(e.getMessage());
- }
- }
-
- void launch(EclipseAppHandle appHandle) throws Exception {
- String type = ((EclipseAppDescriptor) appHandle.getApplicationDescriptor()).getType();
- if (type == null)
- type = APP_TYPE_MAIN_THREAD;
- IContainer container = getContainer(type);
- if (container != null)
- appHandle.setApplication(container.launch(appHandle));
- else
- throw new UnsupportedOperationException(NLS.bind(Messages.container_notFound, appHandle.getApplicationDescriptor().getApplicationId(), type));
- }
-
- public void registryChanged(IRegistryChangeEvent event) {
- processAppDeltas(event.getExtensionDeltas(PI_RUNTIME, PT_APPLICATIONS));
- processAppDeltas(event.getExtensionDeltas(Activator.PI_APP, PT_APPLICATIONS));
- processContainerDeltas(event.getExtensionDeltas(Activator.PI_APP, PT_CONTAINERS));
- }
-
- private void processAppDeltas(IExtensionDelta[] deltas) {
- for (int i = 0; i < deltas.length; i++) {
- switch (deltas[i].getKind()) {
- case IExtensionDelta.ADDED :
- createAppDescriptor(deltas[i].getExtension());
- break;
- case IExtensionDelta.REMOVED :
- removeAppDescriptor(deltas[i].getExtension().getUniqueIdentifier());
- break;
- }
- }
- }
-
- private void processContainerDeltas(IExtensionDelta[] deltas) {
- for (int i = 0; i < deltas.length; i++) {
- switch (deltas[i].getKind()) {
- case IExtensionDelta.ADDED :
- // don't create containers agressively
- break;
- case IExtensionDelta.REMOVED :
- removeContainer(deltas[i].getExtension());
- break;
- }
- }
- }
-
- public void bundleChanged(BundleEvent event) {
- // if this is not the system bundle stopping then ignore the event
- if ((BundleEvent.STOPPING & event.getType()) == 0 || event.getBundle().getBundleId() != 0)
- return;
- // The system bundle is stopping; better stop all applications and containers now
- stopAll();
- }
-
- private void stopAllApplications(String type) {
- try {
- ServiceReference[] runningRefs = context.getServiceReferences(ApplicationHandle.class.getName(), "(&(eclipse.application.type=" + type + ")(!(application.state=STOPPING)))"); //$NON-NLS-1$ //$NON-NLS-2$
- if (runningRefs != null)
- for (int i = 0; i < runningRefs.length; i++) {
- ApplicationHandle handle = (ApplicationHandle) context.getService(runningRefs[i]);
- try {
- handle.destroy();
- } catch (Throwable t) {
- // just ignore; nothing we can really do and we need to continue
- }
- }
- } catch (InvalidSyntaxException e) {
- // do nothing; we already tested the filter string above
- }
- }
-
- private void stopAll() {
- // get a stapshot of running applications
- try {
- ServiceReference[] runningRefs = context.getServiceReferences(ApplicationHandle.class.getName(), "(!(application.state=STOPPING))"); //$NON-NLS-1$
- if (runningRefs != null)
- for (int i = 0; i < runningRefs.length; i++) {
- ApplicationHandle handle = (ApplicationHandle) context.getService(runningRefs[i]);
- try {
- handle.destroy();
- } catch (Throwable t) {
- // TODO should log this
- }
- }
- } catch (InvalidSyntaxException e) {
- // do nothing; we already tested the filter string above
- }
- // shutdown all containers
- synchronized (containers) {
- for (Iterator iContainers = containers.values().iterator(); iContainers.hasNext();)
- ((IContainer) iContainers.next()).shutdown();
- }
- }
-}
diff --git a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/EclipseAppDescriptor.java b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/EclipseAppDescriptor.java
deleted file mode 100755
index 02e0f45f8..000000000
--- a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/EclipseAppDescriptor.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.equinox.internal.app;
-
-import java.security.AccessController;
-import java.util.*;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.application.ApplicationDescriptor;
-import org.osgi.service.application.ApplicationHandle;
-import org.osgi.service.condpermadmin.BundleSignerCondition;
-import org.osgi.service.condpermadmin.ConditionInfo;
-
-/*
- * An ApplicationDescriptor for an eclipse application.
- */
-public class EclipseAppDescriptor extends ApplicationDescriptor {
- static final String APP_TYPE = "eclipse.application.type"; //$NON-NLS-1$
- private ServiceRegistration sr;
- private Boolean locked = Boolean.FALSE;
- private SingletonContainer singletonMgr;
- private ContainerManager containerMgr;
- private String namespace;
- private String type;
- private boolean visible;
-
- protected EclipseAppDescriptor(String namespace, String pid, String type, boolean visible, ContainerManager containerMgr) {
- super(pid);
- this.type = type == null ? ContainerManager.APP_TYPE_MAIN_THREAD : type;
- this.namespace = namespace;
- this.containerMgr = containerMgr;
- this.locked = AppPersistenceUtil.isLocked(this) ? Boolean.TRUE : Boolean.FALSE;
- this.visible = visible;
- }
-
- protected Map getPropertiesSpecific(String locale) {
- // just use the service properties; for now we do not localize any properties
- return getServiceProperties();
- }
-
- protected synchronized ApplicationHandle launchSpecific(Map arguments) throws Exception {
- // we only allow one application to run at a time; do not launch an application
- // if one is already launched or if this application is locked.
- if (locked.booleanValue())
- throw new IllegalStateException("Cannot launch a locked application."); //$NON-NLS-1$
- // initialize the appHandle
- EclipseAppHandle appHandle = createAppHandle();
- appHandle.setArguments(arguments);
- try {
- // use the containerMgr to launch the application on the main thread.
- containerMgr.launch(appHandle);
- } catch (Throwable t) {
- // be sure to destroy the appHandle if an error occurs
- appHandle.destroy();
- if (t instanceof Exception)
- throw (Exception) t;
- throw (Error) t;
- }
- return appHandle;
- }
-
- protected synchronized void lockSpecific() {
- locked = Boolean.TRUE;
- // make sure the service properties are updated with the latest lock info
- refreshProperties();
- }
-
- protected synchronized void unlockSpecific() {
- locked = Boolean.FALSE;
- // make sure the service properties are updated with the latest lock info
- refreshProperties();
- }
-
- /*
- * Indicates to this descriptor that the appHandle was destroyed
- */
- synchronized void appHandleDestroyed() {
- if (singletonMgr != null)
- singletonMgr.unlock();
- }
-
- void refreshProperties() {
- if (sr != null)
- sr.setProperties(getServiceProperties());
- }
-
- void setSingletonMgr(SingletonContainer singletonMgr) {
- this.singletonMgr = singletonMgr;
- }
-
- void setServiceRegistration(ServiceRegistration sr) {
- this.sr = sr;
- }
-
- /*
- * Gets a snapshot of the current service properties.
- */
- Hashtable getServiceProperties() {
- Hashtable props = new Hashtable(10);
- props.put(ApplicationDescriptor.APPLICATION_PID, getApplicationId());
- props.put(ApplicationDescriptor.APPLICATION_CONTAINER, Activator.PI_APP);
- props.put(ApplicationDescriptor.APPLICATION_LOCATION, getLocation());
- props.put(ApplicationDescriptor.APPLICATION_LAUNCHABLE, singletonMgr == null ? Boolean.TRUE : singletonMgr.isLocked() ? Boolean.FALSE : Boolean.TRUE);
- props.put(ApplicationDescriptor.APPLICATION_LOCKED, locked);
- props.put(ApplicationDescriptor.APPLICATION_VISIBLE, visible ? Boolean.TRUE : Boolean.FALSE);
- props.put(EclipseAppDescriptor.APP_TYPE, getType());
- return props;
- }
-
- private String getLocation() {
- final Bundle bundle = AppPersistenceUtil.getBundle(namespace);
- if (bundle == null)
- return ""; //$NON-NLS-1$
- return AppPersistenceUtil.getLocation(bundle);
- }
-
- /*
- * Returns the appHandle. If it does not exist then one is created.
- */
- private synchronized EclipseAppHandle createAppHandle() {
- // TODO not sure what instance pid should be used; for now just use the appDesciptor pid because apps are singletons anyway
- EclipseAppHandle newAppHandle = new EclipseAppHandle(getApplicationId(), this);
- ServiceRegistration appHandleReg = (ServiceRegistration) AccessController.doPrivileged(containerMgr.getRegServiceAction(ApplicationHandle.class.getName(), newAppHandle, newAppHandle.getServiceProperties()));
- newAppHandle.setServiceRegistration(appHandleReg);
- return newAppHandle;
- }
-
- ContainerManager getContainerManager() {
- return containerMgr;
- }
-
- String getType() {
- return type;
- }
-
- public boolean matchDNChain(String pattern) {
- Bundle bundle = AppPersistenceUtil.getBundle(namespace);
- if (bundle == null)
- return false;
- return BundleSignerCondition.getCondition(bundle, new ConditionInfo(BundleSignerCondition.class.getName(), new String[] {pattern})).isSatisfied();
- }
-
- protected boolean isLaunchableSpecific() {
- // TODO Auto-generated method stub
- return true;
- }
-
- public void unregister() {
- if (sr != null)
- sr.unregister();
- }
-}
diff --git a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/EclipseAppHandle.java b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/EclipseAppHandle.java
deleted file mode 100755
index 9d4b96376..000000000
--- a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/EclipseAppHandle.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.equinox.internal.app;
-
-import java.util.*;
-import org.eclipse.equinox.app.IAppContext;
-import org.eclipse.equinox.app.IApplication;
-import org.eclipse.equinox.registry.IConfigurationElement;
-import org.eclipse.equinox.registry.IExtension;
-import org.eclipse.osgi.util.NLS;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.application.ApplicationHandle;
-
-/*
- * An ApplicationHandle that represents a single instance of a running eclipse application.
- */
-public class EclipseAppHandle extends ApplicationHandle implements IAppContext {
- private ServiceRegistration sr;
- private String state = ApplicationHandle.RUNNING;
- private int status = IAppContext.ACTIVE;
- private Object application;
- private Map arguments;
-
- /*
- * Constructs a handle for a single running instance of a eclipse application.
- */
- EclipseAppHandle(String instanceId, EclipseAppDescriptor descriptor) {
- super(instanceId, descriptor);
- }
-
- synchronized public String getState() {
- return state;
- }
-
- protected void destroySpecific() {
- // when this method is called we must force the application to exit.
- // first set the status to stopping
- setAppStatus(IAppContext.STOPPING);
- // now force the appliction to stop
- if (application instanceof IApplication)
- ((IApplication) application).stop();
- // make sure the app status is stopped
- setAppStatus(IAppContext.STOPPED);
- }
-
- void setServiceRegistration(ServiceRegistration sr) {
- this.sr = sr;
- }
-
- void setApplication(Object application) {
- this.application = application;
- }
-
- /*
- * Gets a snapshot of the current service properties.
- */
- Dictionary getServiceProperties() {
- Dictionary props = new Hashtable(6);
- props.put(ApplicationHandle.APPLICATION_PID, getInstanceId());
- props.put(ApplicationHandle.APPLICATION_STATE, getState());
- props.put(ApplicationHandle.APPLICATION_DESCRIPTOR, getApplicationDescriptor().getApplicationId());
- props.put(EclipseAppDescriptor.APP_TYPE, ((EclipseAppDescriptor) getApplicationDescriptor()).getType());
- return props;
- }
-
- /*
- * Changes the state of this handle to STOPPING.
- * Finally the handle is unregistered if the status is STOPPED
- */
- public synchronized void setAppStatus(int status) {
- if ((status & IAppContext.ACTIVE) != 0)
- throw new IllegalArgumentException("Cannot set app status to ACTIVE"); //$NON-NLS-1$
- // if status is stopping and the context is already stopping the return
- if ((status & IAppContext.STOPPING) != 0)
- if (ApplicationHandle.STOPPING.equals(state))
- return;
- // in both cases if the the context is not stopping then set it and
- // change the service properties to reflect the state change.
- if (state != ApplicationHandle.STOPPING) {
- state = ApplicationHandle.STOPPING;
- sr.setProperties(getServiceProperties());
- }
- // if the status is stopped then unregister the service
- if ((status & IAppContext.STOPPED) != 0 && (this.status & IAppContext.STOPPED) == 0) {
- sr.unregister();
- ((EclipseAppDescriptor) getApplicationDescriptor()).appHandleDestroyed();
- }
- this.status = status;
- }
-
- public int getAppStatus() {
- return status;
- }
-
- public Map getArguments() {
- return arguments;
- }
-
- void setArguments(Map arguments) {
- this.arguments = arguments;
- }
-
- public IConfigurationElement getConfiguration() {
- IExtension applicationExtension = ((EclipseAppDescriptor) getApplicationDescriptor()).getContainerManager().getAppExtension(getApplicationDescriptor().getApplicationId());
- IConfigurationElement[] configs = applicationExtension.getConfigurationElements();
- if (configs.length == 0)
- throw new RuntimeException(NLS.bind(Messages.application_invalidExtension, getApplicationDescriptor().getApplicationId()));
- return configs[0];
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/EclipseScheduledApplication.java b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/EclipseScheduledApplication.java
deleted file mode 100755
index 33a75cac2..000000000
--- a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/EclipseScheduledApplication.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.equinox.internal.app;
-
-import java.security.Guard;
-import java.security.GuardedObject;
-import java.util.HashMap;
-import java.util.Map;
-import org.osgi.framework.*;
-import org.osgi.service.application.ApplicationDescriptor;
-import org.osgi.service.application.ScheduledApplication;
-import org.osgi.service.event.*;
-import org.osgi.util.tracker.ServiceTracker;
-
-public class EclipseScheduledApplication implements ScheduledApplication, EventHandler {
- private static final String FILTER_PREFIX = "(&(objectclass=" + ApplicationDescriptor.class.getName() + ")(" + ApplicationDescriptor.APPLICATION_PID + "="; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- private static final String FILTER_POSTFIX = "))"; //$NON-NLS-1$
- private static final String TRIGGERING_EVENT = "org.osgi.triggeringevent"; //$NON-NLS-1$
-
- private boolean recurring;
- private String topic;
- private String eventFilter;
- private Map args;
- private String appPid;
- private Integer id;
- private ServiceRegistration sr;
- private ServiceTracker appTracker;
- private boolean removed = false;
-
- EclipseScheduledApplication(BundleContext context, Integer id, String appPid, Map args, String topic, String eventFilter, boolean recurring) throws InvalidSyntaxException {
- this.id = id;
- this.appPid = appPid;
- this.args = args;
- this.topic = topic == null || topic.trim().equals("") || topic.trim().equals("*") ? null : topic; //$NON-NLS-1$ //$NON-NLS-2$
- this.eventFilter = eventFilter;
- this.recurring = recurring;
- appTracker = new ServiceTracker(context, context.createFilter(FILTER_PREFIX + appPid + FILTER_POSTFIX), null);
- AppPersistenceUtil.openTracker(appTracker, false);
- }
-
- Integer getID() {
- return id;
- }
-
- String getAppPid() {
- return appPid;
- }
-
- public String getTopic() {
- return topic;
- }
-
- public String getEventFilter() {
- return eventFilter;
- }
-
- public boolean isRecurring() {
- return recurring;
- }
-
- public synchronized ApplicationDescriptor getApplicationDescriptor() {
- if (removed)
- throw new IllegalStateException(Messages.EclipseScheduledApplication_7);
- return (ApplicationDescriptor) AppPersistenceUtil.getService(appTracker);
- }
-
- public Map getArguments() {
- return args == null ? null : new HashMap(args);
- }
-
- private Map getArguments(Event trigger) {
- Map result = args == null ? new HashMap() : getArguments();
- result.put(TRIGGERING_EVENT, new GuardedObject(trigger, new TriggerGuard(trigger.getTopic())));
- return result;
- }
-
- public synchronized void remove() {
- if (removed)
- return;
- removed = true;
- AppPersistenceUtil.removeScheduledApp(this);
- if (sr != null)
- sr.unregister();
- appTracker.close();
- }
-
- public synchronized void handleEvent(Event event) {
- try {
- ApplicationDescriptor desc = getApplicationDescriptor();
- if (desc == null)
- return;
- desc.launch(getArguments(event));
- } catch (Exception e) {
- // TODO should log this
- return; // return here to avoid removing non-recurring apps when an error occurs
- }
- if (!isRecurring())
- remove();
- }
-
- void setServiceRegistration(ServiceRegistration sr) {
- this.sr = sr;
- if (removed) // just incase we were removed before the sr was set
- sr.unregister();
- }
-
- public class TriggerGuard implements Guard {
- String eventTopic;
-
- public TriggerGuard(String topic) {
- this.eventTopic = topic;
- }
-
- public void checkGuard(Object object) throws SecurityException {
- SecurityManager sm = System.getSecurityManager();
- if (sm != null)
- sm.checkPermission(new TopicPermission(eventTopic, TopicPermission.SUBSCRIBE));
- }
-
- }
-}
diff --git a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/ErrorApplication.java b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/ErrorApplication.java
deleted file mode 100755
index ba58eaf30..000000000
--- a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/ErrorApplication.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.equinox.internal.app;
-
-import org.eclipse.equinox.app.IApplication;
-
-/*
- * Special case class only used to throw exceptions when an application
- * cannot be found.
- */
-public class ErrorApplication implements IApplication {
-
- static private Exception ERROR;
-
- public Object run(Object args) throws Exception {
- if (ERROR != null)
- throw ERROR;
- throw new IllegalStateException();
- }
-
- public void stop() {
- // do nothing
- }
-
- static void setError(Exception error) {
- ERROR = error;
- }
-}
diff --git a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/MainThreadApplication.java b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/MainThreadApplication.java
deleted file mode 100755
index d4a6e7da6..000000000
--- a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/MainThreadApplication.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.internal.app;
-
-import org.eclipse.equinox.app.IAppContext;
-import org.eclipse.equinox.app.IApplication;
-import org.eclipse.osgi.service.runnable.ApplicationRunnable;
-import org.eclipse.osgi.util.NLS;
-
-public class MainThreadApplication implements ApplicationRunnable {
- private static final String PROP_ECLIPSE_EXITCODE = "eclipse.exitcode"; //$NON-NLS-1$
- private Object application;
- private EclipseAppHandle appContext;
- private Exception launchException;
-
- public MainThreadApplication(EclipseAppHandle appContext) {
- this.appContext = appContext;
- try {
- application = appContext.getConfiguration().createExecutableExtension("run"); //$NON-NLS-1$
- } catch (Exception e) {
- // had an error creating the executable extension
- // save the exception to throw on the main thread (keeping legacy behavior)
- this.launchException = e;
- }
- }
-
- public Object run(Object context) throws Exception {
- // if the given arg is null then pass in the left over command line args.
- if (context == null)
- context = AppPersistenceUtil.getApplicationArgs();
- Object result;
- try {
- if (launchException != null)
- // this is a dummy handle used to throw an exception on the main thread.
- throw launchException;
- if (application instanceof IApplication) {
- result = ((IApplication) application).run(context);
- } else
- result = ContainerManager.execMethod(application, "run", Object.class, context); //$NON-NLS-1$
- } finally {
- application = null;
- // The application exited itself; notify the app context
- appContext.setAppStatus(IAppContext.STOPPED);
- }
- int exitCode = result instanceof Integer ? ((Integer) result).intValue() : 0;
- // use the long way to set the property to compile against eeminimum
- System.getProperties().setProperty(PROP_ECLIPSE_EXITCODE, Integer.toString(exitCode));
- if (Activator.DEBUG)
- System.out.println(NLS.bind(Messages.application_returned, (new String[] {appContext.getApplicationDescriptor().getApplicationId(), result == null ? "null" : result.toString()}))); //$NON-NLS-1$
- return result;
- }
-
- public void stop() {
- // we can only handle forced stops if this application is an IApplication
- if (application instanceof IApplication)
- ((IApplication) application).stop();
- }
-
- IApplication getApplication() {
- return (IApplication) ((application instanceof IApplication) ? application : null);
- }
-}
diff --git a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/MainThreadContainer.java b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/MainThreadContainer.java
deleted file mode 100755
index 203aa96fb..000000000
--- a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/MainThreadContainer.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.internal.app;
-
-import org.eclipse.equinox.app.*;
-import org.eclipse.osgi.service.runnable.ApplicationLauncher;
-import org.osgi.framework.ServiceReference;
-import org.osgi.util.tracker.ServiceTracker;
-import org.osgi.util.tracker.ServiceTrackerCustomizer;
-
-public class MainThreadContainer implements IContainer, ServiceTrackerCustomizer {
- // tracks the application launcher
- private ServiceTracker appLauncherTracker;
- // the application launcher used to launch applications on the main thread.
- private ApplicationLauncher appLauncher;
- // the default app to launch once we are ready
- private EclipseAppDescriptor defaultDesc;
-
- public MainThreadContainer() {
- appLauncherTracker = new ServiceTracker(AppPersistenceUtil.getContext(), ApplicationLauncher.class.getName(), this);
- appLauncherTracker.open();
- }
-
- public IApplication launch(IAppContext appContext) {
- // use the ApplicationLauncher provided by the framework
- // to ensure it is launched on the main thread
- if (appLauncher == null)
- throw new IllegalStateException();
- MainThreadApplication app = new MainThreadApplication((EclipseAppHandle) appContext);
- appLauncher.launch(app, appContext.getArguments() == null ? null : appContext.getArguments().get(ContainerManager.PROP_ECLIPSE_APPLICATION_ARGS));
- return app.getApplication();
- }
-
- public Object addingService(ServiceReference reference) {
- if (appLauncher != null)
- return null;
- appLauncher = (ApplicationLauncher) AppPersistenceUtil.getContext().getService(reference);
- if (defaultDesc != null)
- // launch the default application
- try {
- defaultDesc.launch(null);
- defaultDesc = null; // don't want to launch it more than once
- } catch (Exception e) {
- // TODO should log this!!
- }
- return appLauncher;
- }
-
- public void modifiedService(ServiceReference reference, Object service) {
- // do nothing
- }
-
- public synchronized void removedService(ServiceReference reference, Object service) {
- if (service == appLauncher) {
- appLauncher = null;
- AppPersistenceUtil.getContext().ungetService(reference);
- }
- }
-
- public void shutdown() {
- if (appLauncherTracker != null) {
- appLauncherTracker.close();
- appLauncherTracker = null;
- }
- }
-
- public void setDefaultApp(EclipseAppDescriptor defaultDesc) {
- this.defaultDesc = defaultDesc;
- }
-}
diff --git a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/Messages.java b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/Messages.java
deleted file mode 100755
index 61938d0ef..000000000
--- a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/Messages.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.internal.app;
-
-import org.eclipse.osgi.util.NLS;
-
-public class Messages extends NLS {
- private static final String BUNDLE_NAME = "org.eclipse.equinox.internal.app.messages"; //$NON-NLS-1$
-
- // application
- public static String application_invalidExtension;
- public static String application_noIdFound;
- public static String application_notFound;
- public static String application_returned;
-
- // product
- public static String provider_invalid;
- public static String provider_invalid_general;
- public static String product_notFound;
-
- // container
- public static String container_notFound;
-
- static {
- // load message values from bundle file
- reloadMessages();
- }
-
- public static void reloadMessages() {
- NLS.initializeMessages(BUNDLE_NAME, Messages.class);
- }
-
- public static String EclipseScheduledApplication_7;
-}
diff --git a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/SingletonContainer.java b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/SingletonContainer.java
deleted file mode 100755
index 8b61feee9..000000000
--- a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/SingletonContainer.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.internal.app;
-
-import org.eclipse.equinox.app.*;
-
-public class SingletonContainer implements IContainer {
- private EclipseAppHandle singletonHandle;
- private String type;
- private IContainer singletonContainer;
- private ContainerManager containerManager;
-
- public SingletonContainer(IContainer singletonContainer, String type, ContainerManager containerManager) {
- this.singletonContainer = singletonContainer;
- this.type = type;
- this.containerManager = containerManager;
- }
-
- public synchronized IApplication launch(IAppContext context) throws Exception {
- // attempt to lock this application type; an exception will be thrown if the type cannot be locked
- lock((EclipseAppHandle) context);
- return singletonContainer.launch(context);
- }
-
- public boolean isSingletonContainer() {
- return true;
- }
-
- synchronized boolean isLocked() {
- return singletonHandle != null;
- }
-
- synchronized void lock(EclipseAppHandle appHandle) {
- if (singletonHandle != null)
- throw new IllegalStateException("Only one application of type \"" + type + "\" is allowed to run at a time");
- singletonHandle = appHandle;
- refreshAppDescriptors();
- }
-
- synchronized void unlock() {
- singletonHandle = null;
- refreshAppDescriptors();
- }
-
- private void refreshAppDescriptors() {
- EclipseAppDescriptor[] singletonApps = containerManager.getAppDescriptorsByType(type);
- for (int i = 0; i < singletonApps.length; i++) {
- singletonApps[i].setSingletonMgr(this);
- singletonApps[i].refreshProperties();
- }
- }
-
- public void shutdown() {
- singletonContainer.shutdown();
- }
-
- IContainer getContainer() {
- return singletonContainer;
- }
-}
diff --git a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/messages.properties b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/messages.properties
deleted file mode 100755
index 8bd877f38..000000000
--- a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/messages.properties
+++ /dev/null
@@ -1,26 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2005 IBM Corporation 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:
-# IBM Corporation - initial API and implementation
-###############################################################################
-### Equinox AppContainer plugin messages
-
-### application
-application_invalidExtension = Invalid (empty) application extension \"{0}\".
-application_noIdFound = No application id has been found.
-application_notFound=Application \"{0}\" could not be found in the registry. The applications available are: {1}.
-application_returned=The application \"{0}\" returned with code: {1}.
-
-### product
-provider_invalid_general = Errors while processing the product providers.
-provider_invalid = Problem creating the provider registered by {0}.
-product_notFound = Product {0} could not be found.
-
-## container
-container_notFound = No container is available to launch the application \"{0}\" of type \"{1}\".
-EclipseScheduledApplication_7=Application has been unregistered
diff --git a/bundles/org.eclipse.equinox.app/src/org/osgi/service/application/ApplicationAdminPermission.java b/bundles/org.eclipse.equinox.app/src/org/osgi/service/application/ApplicationAdminPermission.java
deleted file mode 100755
index 4cbab14c9..000000000
--- a/bundles/org.eclipse.equinox.app/src/org/osgi/service/application/ApplicationAdminPermission.java
+++ /dev/null
@@ -1,403 +0,0 @@
-/*
- * $Header: /cvshome/build/org.osgi.service.application/src/org/osgi/service/application/ApplicationAdminPermission.java,v 1.31 2005/12/20 11:23:39 ckarai Exp $
- *
- * Copyright (c) OSGi Alliance (2004, 2005). 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.
- */
-
-package org.osgi.service.application;
-
-import java.security.Permission;
-import java.util.Hashtable;
-import java.util.StringTokenizer;
-import java.util.Vector;
-
-import org.osgi.framework.Filter;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.InvalidSyntaxException;
-
-/**
- * This class implements permissions for manipulating applications and
- * their instances.
- * <P>
- * ApplicationAdminPermission can be targeted to applications that matches the
- * specified filter.
- * <P>
- * ApplicationAdminPermission may be granted for different actions:
- * <code>lifecycle</code>, <code>schedule</code> and <code>lock</code>.
- * The permission <code>schedule</code> implies the permission
- * <code>lifecycle</code>.
- */
-public class ApplicationAdminPermission extends Permission {
- private static final long serialVersionUID = 1L;
-
- /**
- * Allows the lifecycle management of the target applications.
- */
- public static final String LIFECYCLE_ACTION = "lifecycle";
-
- /**
- * Allows scheduling of the target applications. The permission to
- * schedule an application implies that the scheduler can also
- * manage the lifecycle of that application i.e. <code>schedule</code>
- * implies <code>lifecycle</code>
- */
- public static final String SCHEDULE_ACTION = "schedule";
-
- /**
- * Allows setting/unsetting the locking state of the target applications.
- */
- public static final String LOCK_ACTION = "lock";
-
- private ApplicationDescriptor applicationDescriptor;
-
- /**
- * Constructs an ApplicationAdminPermission. The <code>filter</code>
- * specifies the target application. The <code>filter</code> is an
- * LDAP-style filter, the recognized properties are <code>signer</code>
- * and <code>pid</code>. The pattern specified in the <code>signer</code>
- * is matched with the Distinguished Name chain used to sign the application.
- * Wildcards in a DN are not matched according to the filter string rules,
- * but according to the rules defined for a DN chain. The attribute
- * <code>pid</code> is matched with the PID of the application according to
- * the filter string rules.
- * <p>
- * If the <code>filter</code> is <code>null</code> then it matches
- * <code>"*"</code>. If
- * <code>actions</code> is <code>"*"</code> then it identifies all the
- * possible actions.
- *
- * @param filter
- * filter to identify application. The value <code>null</code>
- * is equivalent to <code>"*"</code> and it indicates "all application".
- * @param actions
- * comma-separated list of the desired actions granted on the
- * applications or "*" means all the actions. It must not be
- * <code>null</code>. The order of the actions in the list is
- * not significant.
- * @throws InvalidSyntaxException
- * is thrown if the specified <code>filter</code> is not syntactically
- * correct.
- *
- * @exception NullPointerException
- * is thrown if the actions parameter is <code>null</code>
- *
- * @see ApplicationDescriptor
- * @see org.osgi.framework.AdminPermission
- */
- public ApplicationAdminPermission(String filter, String actions) throws InvalidSyntaxException {
- super(filter == null ? "*" : filter);
-
- if( filter == null )
- filter = "*";
-
- if( actions == null )
- throw new NullPointerException( "Action string cannot be null!" );
-
- this.applicationDescriptor = null;
- this.filter = (filter == null ? "*" : filter);
- this.actions = actions;
-
- if( !filter.equals( "*" ) && !filter.equals( "<<SELF>>" ) )
- FrameworkUtil.createFilter( this.filter ); // check if the filter is valid
- init();
- }
-
- /**
- * This contructor should be used when creating <code>ApplicationAdminPermission</code>
- * instance for <code>checkPermission</code> call.
- * @param application the tareget of the operation, it must not be <code>null</code>
- * @param actions the required operation. it must not be <code>null</code>
- * @throws NullPointerException if any of the arguments is null.
- */
- public ApplicationAdminPermission(ApplicationDescriptor application, String actions) {
- super(application.getApplicationId());
-
- if( application == null || actions == null )
- throw new NullPointerException( "ApplicationDescriptor and action string cannot be null!" );
-
- this.filter = application.getApplicationId();
- this.applicationDescriptor = application;
- this.actions = actions;
-
- init();
- }
-
- /**
- * This method can be used in the {@link java.security.ProtectionDomain}
- * implementation in the <code>implies</code> method to insert the
- * application ID of the current application into the permission being
- * checked. This enables the evaluation of the
- * <code>&lt;&lt;SELF&gt;&gt;</code> pseudo targets.
- * @param applicationId the ID of the current application.
- * @return the permission updated with the ID of the current application
- */
- public ApplicationAdminPermission setCurrentApplicationId(String applicationId) {
- ApplicationAdminPermission newPerm = null;
-
- if( this.applicationDescriptor == null ) {
- try {
- newPerm = new ApplicationAdminPermission( this.filter, this.actions );
- }catch( InvalidSyntaxException e ) {
- throw new RuntimeException( "Internal error" ); /* this can never happen */
- }
- }
- else
- newPerm = new ApplicationAdminPermission( this.applicationDescriptor, this.actions );
-
- newPerm.applicationID = applicationId;
-
- return newPerm;
- }
-
- /**
- * Checks if the specified <code>permission</code> is implied by this permission.
- * The method returns true under the following conditions:
- * <UL>
- * <LI> This permission was created by specifying a filter (see {@link #ApplicationAdminPermission(String, String)})
- * <LI> The implied <code>otherPermission</code> was created for a particular {@link ApplicationDescriptor}
- * (see {@link #ApplicationAdminPermission(ApplicationDescriptor, String)})
- * <LI> The <code>filter</code> of this permission mathes the <code>ApplicationDescriptor</code> specified
- * in the <code>otherPermission</code>. If the filter in this permission is the
- * <code>&lt;&lt;SELF&gt;&gt;</code> pseudo target, then the currentApplicationId set in the
- * <code>otherPermission</code> is compared to the application Id of the target
- * <code>ApplicationDescriptor</code>.
- * <LI> The list of permitted actions in this permission contains all actions required in the
- * <code>otherPermission</code>
- * </UL>
- * Otherwise the method returns false.
- * @param otherPermission the implied permission
- * @return true if this permission implies the <code>otherPermission</code>, false otherwise.
- */
- public boolean implies(Permission otherPermission) {
- if( otherPermission == null )
- return false;
-
- if(!(otherPermission instanceof ApplicationAdminPermission))
- return false;
-
- ApplicationAdminPermission other = (ApplicationAdminPermission) otherPermission;
-
- if( !filter.equals("*") ) {
- if( other.applicationDescriptor == null )
- return false;
-
- if( filter.equals( "<<SELF>>") ) {
- if( other.applicationID == null )
- return false; /* it cannot be, this might be a bug */
-
- if( !other.applicationID.equals( other.applicationDescriptor.getApplicationId() ) )
- return false;
- }
- else {
- Hashtable props = new Hashtable();
- props.put( "pid", other.applicationDescriptor.getApplicationId() );
- props.put( "signer", new SignerWrapper( other.applicationDescriptor ) );
-
- Filter flt = getFilter();
- if( flt == null )
- return false;
-
- if( !flt.match( props ) )
- return false;
- }
- }
-
- if( !actionsVector.containsAll( other.actionsVector ) )
- return false;
-
- return true;
- }
-
- public boolean equals(Object with) {
- if( with == null || !(with instanceof ApplicationAdminPermission) )
- return false;
-
- ApplicationAdminPermission other = (ApplicationAdminPermission)with;
-
- // Compare actions:
- if( other.actionsVector.size() != actionsVector.size() )
- return false;
-
- for( int i=0; i != actionsVector.size(); i++ )
- if( !other.actionsVector.contains( actionsVector.get( i ) ) )
- return false;
-
-
- return equal(this.filter, other.filter ) && equal(this.applicationDescriptor, other.applicationDescriptor)
- && equal(this.applicationID, other.applicationID);
- }
-
- /**
- * Compares parameters for equality. If both object are null, they are considered
- * equal.
- * @param a object to compare
- * @param b other object to compare
- * @return true if both objects are equal or both are null
- */
- private static boolean equal(Object a, Object b) {
- // This equation is true if both references are null or both point
- // to the same object. In both cases they are considered as equal.
- if( a == b ) {
- return true;
- }
-
- return a.equals(b);
- }
-
- public int hashCode() {
- int hc = 0;
- for( int i=0; i != actionsVector.size(); i++ )
- hc ^= ((String)actionsVector.get( i )).hashCode();
- hc ^= (null == this.filter )? 0 : this.filter.hashCode();
- hc ^= (null == this.applicationDescriptor) ? 0 : this.applicationDescriptor.hashCode();
- hc ^= (null == this.applicationID) ? 0 : this.applicationID.hashCode();
- return hc;
- }
-
- /**
- * Returns the actions of this permission.
- * @return the actions specified when this permission was created
- */
- public String getActions() {
- return actions;
- }
-
- private String applicationID;
-
- private static final Vector ACTIONS = new Vector();
- private Vector actionsVector;
- private final String filter;
- private final String actions;
- private Filter appliedFilter = null;
-
- static {
- ACTIONS.add(LIFECYCLE_ACTION);
- ACTIONS.add(SCHEDULE_ACTION);
- ACTIONS.add(LOCK_ACTION);
- }
-
- private static Vector actionsVector(String actions) {
- Vector v = new Vector();
- StringTokenizer t = new StringTokenizer(actions.toUpperCase(), ",");
- while (t.hasMoreTokens()) {
- String action = t.nextToken().trim();
- v.add(action.toLowerCase());
- }
-
- if( v.contains( SCHEDULE_ACTION ) && !v.contains( LIFECYCLE_ACTION ) )
- v.add( LIFECYCLE_ACTION );
-
- return v;
- }
-
-
- private static class SignerWrapper extends Object {
- private String pattern;
- private ApplicationDescriptor appDesc;
-
- public SignerWrapper(String pattern) {
- this.pattern = pattern;
- }
-
- SignerWrapper(ApplicationDescriptor appDesc) {
- this.appDesc = appDesc;
- }
-
- public boolean equals(Object o) {
- if (!(o instanceof SignerWrapper))
- return false;
- SignerWrapper other = (SignerWrapper) o;
- ApplicationDescriptor matchAppDesc = (ApplicationDescriptor) (appDesc != null ? appDesc : other.appDesc);
- String matchPattern = appDesc != null ? other.pattern : pattern;
- return matchAppDesc.matchDNChain(matchPattern);
- }
- }
-
- private void init() {
- actionsVector = actionsVector( actions );
-
- if ( actions.equals("*") )
- actionsVector = actionsVector( LIFECYCLE_ACTION + "," + SCHEDULE_ACTION + "," + LOCK_ACTION );
- else if (!ACTIONS.containsAll(actionsVector))
- throw new IllegalArgumentException("Illegal action!");
-
- applicationID = null;
- }
-
- private Filter getFilter() {
- String transformedFilter = filter;
-
- if (appliedFilter == null) {
- try {
- int pos = filter.indexOf("signer"); //$NON-NLS-1$
- if (pos != -1){
-
- //there may be a signer attribute
- StringBuffer filterBuf = new StringBuffer(filter);
- int numAsteriskFound = 0; //use as offset to replace in buffer
-
- int walkbackPos; //temp pos
-
- //find occurences of (signer= and escape out *'s
- while (pos != -1) {
-
- //walk back and look for '(' to see if this is an attr
- walkbackPos = pos-1;
-
- //consume whitespace
- while(walkbackPos >= 0 && Character.isWhitespace(filter.charAt(walkbackPos))) {
- walkbackPos--;
- }
- if (walkbackPos <0) {
- //filter is invalid - FilterImpl will throw error
- break;
- }
-
- //check to see if we have unescaped '('
- if (filter.charAt(walkbackPos) != '(' || (walkbackPos > 0 && filter.charAt(walkbackPos-1) == '\\')) {
- //'(' was escaped or not there
- pos = filter.indexOf("signer",pos+6); //$NON-NLS-1$
- continue;
- }
- pos+=6; //skip over 'signer'
-
- //found signer - consume whitespace before '='
- while (Character.isWhitespace(filter.charAt(pos))) {
- pos++;
- }
-
- //look for '='
- if (filter.charAt(pos) != '=') {
- //attr was signerx - keep looking
- pos = filter.indexOf("signer",pos); //$NON-NLS-1$
- continue;
- }
- pos++; //skip over '='
-
- //found signer value - escape '*'s
- while (!(filter.charAt(pos) == ')' && filter.charAt(pos-1) != '\\')) {
- if (filter.charAt(pos) == '*') {
- filterBuf.insert(pos+numAsteriskFound,'\\');
- numAsteriskFound++;
- }
- pos++;
- }
-
- //end of signer value - look for more?
- pos = filter.indexOf("signer",pos); //$NON-NLS-1$
- } //end while (pos != -1)
- transformedFilter = filterBuf.toString();
- } //end if (pos != -1)
-
- appliedFilter = FrameworkUtil.createFilter( transformedFilter );
- } catch (InvalidSyntaxException e) {
- //we will return null
- }
- }
- return appliedFilter;
- }
-}
diff --git a/bundles/org.eclipse.equinox.app/src/org/osgi/service/application/ApplicationDescriptor.java b/bundles/org.eclipse.equinox.app/src/org/osgi/service/application/ApplicationDescriptor.java
deleted file mode 100755
index 4b60d7305..000000000
--- a/bundles/org.eclipse.equinox.app/src/org/osgi/service/application/ApplicationDescriptor.java
+++ /dev/null
@@ -1,501 +0,0 @@
-/*
- * $Header: /cvsroot/eclipse/org.eclipse.equinox.app/src/org/osgi/service/application/ApplicationDescriptor.java,v 1.3 2006/01/16 19:45:25 twatson Exp $
- *
- * Copyright (c) OSGi Alliance (2004, 2005). 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.
- */
-
-package org.osgi.service.application;
-
-import java.util.Iterator;
-import java.util.Map;
-import org.eclipse.equinox.internal.app.AppPersistenceUtil;
-import org.osgi.framework.Constants;
-import org.osgi.framework.InvalidSyntaxException;
-
-/**
- * An OSGi service that represents an installed application and stores
- * information about it. The application descriptor can be used for instance
- * creation.
- */
-
-public abstract class ApplicationDescriptor {
-
- /**
- * The property key for the localized name of the application.
- */
- public static final String APPLICATION_NAME = "application.name";
-
- /**
- * The property key for the localized icon of the application.
- */
- public static final String APPLICATION_ICON = "application.icon";
-
- /**
- * The property key for the unique identifier (PID) of the application.
- */
- public static final String APPLICATION_PID = Constants.SERVICE_PID;
-
- /**
- * The property key for the version of the application.
- */
- public static final String APPLICATION_VERSION = "application.version";
-
- /**
- * The property key for the name of the application vendor.
- */
- public static final String APPLICATION_VENDOR = Constants.SERVICE_VENDOR;
-
-
- /**
- * The property key for the visibility property of the application.
- */
- public static final String APPLICATION_VISIBLE = "application.visible";
-
- /**
- * The property key for the launchable property of the application.
- */
- public static final String APPLICATION_LAUNCHABLE = "application.launchable";
-
- /**
- * The property key for the locked property of the application.
- */
- public static final String APPLICATION_LOCKED = "application.locked";
-
- /**
- * The property key for the localized description of the application.
- */
- public static final String APPLICATION_DESCRIPTION = "application.description";
-
- /**
- * The property key for the localized documentation of the application.
- */
- public static final String APPLICATION_DOCUMENTATION = "application.documentation";
-
- /**
- * The property key for the localized copyright notice of the application.
- */
- public static final String APPLICATION_COPYRIGHT = "application.copyright";
-
- /**
- * The property key for the localized license of the application.
- */
- public static final String APPLICATION_LICENSE = "application.license";
-
- /**
- * The property key for the application container of the application.
- */
- public static final String APPLICATION_CONTAINER = "application.container";
-
- /**
- * The property key for the location of the application.
- */
- public static final String APPLICATION_LOCATION = "application.location";
-
-
- /**
- * Constructs the <code>ApplicationDescriptor</code>.
- *
- * @param applicationId
- * The identifier of the application. Its value is also available
- * as the <code>service.pid</code> service property of this
- * <code>ApplicationDescriptor</code> service. This parameter must not
- * be <code>null</code>.
- * @throws NullPointerException if the specified <code>applicationId</code> is null.
- */
- protected ApplicationDescriptor(String applicationId) {
- if(null == applicationId ) {
- throw new NullPointerException("Application ID must not be null!");
- }
-
- this.pid = applicationId;
- locked[0] = isLocked();
- }
-
- /**
- * Returns the identifier of the represented application.
- *
- * @return the identifier of the represented application
- */
- public final String getApplicationId() {
- return pid;
- }
-
- /**
- * This method verifies whether the specified <code>pattern</code>
- * matches the Distinguished Names of any of the certificate chains
- * used to authenticate this application.
- * <P>
- * The <code>pattern</code> must adhere to the
- * syntax defined in {@link org.osgi.service.application.ApplicationAdminPermission}
- * for signer attributes.
- * <p>
- * This method is used by {@link ApplicationAdminPermission#implies(java.security.Permission)} method
- * to match target <code>ApplicationDescriptor</code> and filter.
- *
- * @param pattern a pattern for a chain of Distinguished Names. It must not be null.
- * @return <code>true</code> if the specified pattern matches at least
- * one of the certificate chains used to authenticate this application
- * @throws NullPointerException if the specified <code>pattern</code> is null.
- */
- public abstract boolean matchDNChain( String pattern );
-
- /**
- * Returns the properties of the application descriptor as key-value pairs.
- * The return value contains the locale aware and unaware properties as
- * well. The returned <code>Map</code> will include the service
- * properties of this <code>ApplicationDescriptor</code> as well.
- * <p>
- * This method will call the <code>getPropertiesSpecific</code> method
- * to enable the container implementation to insert application model and/or
- * container implementation specific properties.
- * <P>
- * The returned {@link java.util.Map} will contain the standard OSGi service
- * properties as well
- * (e.g. service.id, service.vendor etc.) and specialized application
- * descriptors may offer further service properties. The returned Map contains
- * a snapshot of the properties. It will not reflect further changes in the
- * property values nor will the update of the Map change the corresponding
- * service property.
- *
- * @param locale
- * the locale string, it may be null, the value null means the
- * default locale. If the provided locale is the empty String
- * (<code>""</code>)then raw (non-localized) values are returned.
- *
- * @return copy of the service properties of this application descriptor service,
- * according to the specified locale. If locale is null then the
- * default locale's properties will be returned. (Since service
- * properties are always exist it cannot return null.)
- *
- * @throws IllegalStateException
- * if the application descriptor is unregistered
- */
- public final Map getProperties(String locale) {
- Map props = getPropertiesSpecific( locale );
- Boolean containerLocked = (Boolean) props.remove( APPLICATION_LOCKED );
- synchronized (locked) {
- if (containerLocked != null && containerLocked.booleanValue() != locked[0]) {
- if (locked[0])
- lockSpecific();
- else
- unlockSpecific();
- }
- }
- props.put( APPLICATION_LOCKED, new Boolean( locked[0] ) );
- return props;
- }
-
- /**
- * Container implementations can provide application model specific
- * and/or container implementation specific properties via this
- * method.
- *
- * Localizable properties must be returned localized if the provided
- * <code>locale</code> argument is not the empty String. The value
- * <code>null</code> indicates to use the default locale, for other
- * values the specified locale should be used.
- *
- * The returned {@link java.util.Map} must contain the standard OSGi service
- * properties as well
- * (e.g. service.id, service.vendor etc.) and specialized application
- * descriptors may offer further service properties.
- * The returned <code>Map</code>
- * contains a snapshot of the properties. It will not reflect further changes in the
- * property values nor will the update of the Map change the corresponding
- * service property.
-
- * @param locale the locale to be used for localizing the properties.
- * If <code>null</code> the default locale should be used. If it is
- * the empty String (<code>""</code>) then raw (non-localized) values
- * should be returned.
- *
- * @return the application model specific and/or container implementation
- * specific properties of this application descriptor.
- *
- * @throws IllegalStateException
- * if the application descriptor is unregistered
- */
- protected abstract Map getPropertiesSpecific(String locale);
-
- /**
- * Launches a new instance of an application. The <code>args</code> parameter specifies
- * the startup parameters for the instance to be launched, it may be null.
- * <p>
- * The following steps are made:
- * <UL>
- * <LI>Check for the appropriate permission.
- * <LI>Check the locking state of the application. If locked then return
- * null otherwise continue.
- * <LI>Calls the <code>launchSpecific()</code> method to create and start an application
- * instance.
- * <LI>Returns the <code>ApplicationHandle</code> returned by the
- * launchSpecific()
- * </UL>
- * The caller has to have ApplicationAdminPermission(applicationPID,
- * "launch") in order to be able to perform this operation.
- * <P>
- * The <code>Map</code> argument of the launch method contains startup
- * arguments for the
- * application. The keys used in the Map must be non-null, non-empty <code>String<code>
- * objects. They can be standard or application
- * specific. OSGi defines the <code>org.osgi.triggeringevent</code>
- * key to be used to
- * pass the triggering event to a scheduled application, however
- * in the future it is possible that other well-known keys will be defined.
- * To avoid unwanted clashes of keys, the following rules should be applied:
- * <ul>
- * <li>The keys starting with the dash (-) character are application
- * specific, no well-known meaning should be associated with them.</li>
- * <li>Well-known keys should follow the reverse domain name based naming.
- * In particular, the keys standardized in OSGi should start with
- * <code>org.osgi.</code>.</li>
- * </ul>
- * <P>
- * The method is synchonous, it return only when the application instance was
- * successfully started or the attempt to start it failed.
- * <P>
- * This method never returns <code>null</code>. If launching an application fails,
- * the appropriate exception is thrown.
- *
- * @param arguments
- * Arguments for the newly launched application, may be null
- *
- * @return the registered ApplicationHandle, which represents the newly
- * launched application instance. Never returns <code>null</code>.
- *
- * @throws SecurityException
- * if the caller doesn't have "lifecycle"
- * ApplicationAdminPermission for the application.
- * @throws ApplicationException
- * if starting the application failed
- * @throws IllegalStateException
- * if the application descriptor is unregistered
- * @throws IllegalArgumentException
- * if the specified <code>Map</code> contains invalid keys
- * (null objects, empty <code>String</code> or a key that is not
- * <code>String</code>)
- */
- public final ApplicationHandle launch(Map arguments)
- throws ApplicationException {
- SecurityManager sm = System.getSecurityManager();
- if (sm!= null)
- sm.checkPermission(new ApplicationAdminPermission(this, ApplicationAdminPermission.LIFECYCLE_ACTION));
- synchronized (locked) {
- if (locked[0])
- throw new ApplicationException(ApplicationException.APPLICATION_LOCKED, "Application is locked, can't launch!");
- }
- if( !isLaunchableSpecific() )
- throw new ApplicationException(ApplicationException.APPLICATION_NOT_LAUNCHABLE,
- "Cannot launch the application!");
- checkArgs(arguments);
- try {
- return launchSpecific(arguments);
- } catch(IllegalStateException ise) {
- throw ise;
- } catch(SecurityException se) {
- throw se;
- } catch( ApplicationException ae) {
- throw ae;
- } catch(Exception t) {
- throw new ApplicationException(ApplicationException.APPLICATION_INTERNAL_ERROR, t);
- }
- }
-
- /**
- * Called by launch() to create and start a new instance in an application
- * model specific way. It also creates and registeres the application handle
- * to represent the newly created and started instance and registeres it.
- * The method is synchonous, it return only when the application instance was
- * successfully started or the attempt to start it failed.
- * <P>
- * This method must not return <code>null</code>. If launching the application
- * failed, and exception must be thrown.
- *
- * @param arguments
- * the startup parameters of the new application instance, may be
- * null
- *
- * @return the registered application model
- * specific application handle for the newly created and started
- * instance.
- *
- * @throws IllegalStateException
- * if the application descriptor is unregistered
- * @throws Exception
- * if any problem occures.
- */
- protected abstract ApplicationHandle launchSpecific(Map arguments)
- throws Exception;
-
- /**
- * This method is called by launch() to verify that according to the
- * container, the application is launchable.
- *
- * @return true, if the application is launchable according to the
- * container, false otherwise.
- *
- * @throws IllegalStateException
- * if the application descriptor is unregistered
- */
- protected abstract boolean isLaunchableSpecific();
-
- /**
- * Schedules the application at a specified event. Schedule information
- * should not get lost even if the framework or the device restarts so it
- * should be stored in a persistent storage. The method registers a
- * {@link ScheduledApplication} service in Service Registry, representing
- * the created scheduling.
- * <p>
- * The <code>Map</code> argument of the method contains startup
- * arguments for the application. The keys used in the Map must be non-null,
- * non-empty <code>String<code> objects.
- *
- * @param arguments
- * the startup arguments for the scheduled application, may be
- * null
- * @param topic
- * specifies the topic of the triggering event, it may contain a
- * trailing asterisk as wildcard, the empty string is treated as
- * "*", must not be null
- * @param eventFilter
- * specifies and LDAP filter to filter on the properties of the
- * triggering event, may be null
- * @param recurring
- * if the recurring parameter is false then the application will
- * be launched only once, when the event firstly occurs. If the
- * parameter is true then scheduling will take place for every
- * event occurrence; i.e. it is a recurring schedule
- *
- * @return the registered scheduled application service
- *
- * @throws NullPointerException
- * if the topic is <code>null</code>
- * @throws InvalidSyntaxException
- * if the specified <code>eventFilter</code> is not syntactically correct
- * @throws SecurityException
- * if the caller doesn't have "schedule"
- * ApplicationAdminPermission for the application.
- * @throws IllegalStateException
- * if the application descriptor is unregistered
- * @throws IllegalArgumentException
- * if the specified <code>Map</code> contains invalid keys
- * (null objects, empty <code>String</code> or a key that is not
- * <code>String</code>)
- */
- public final ScheduledApplication schedule(Map arguments, String topic,
- String eventFilter, boolean recurring) throws InvalidSyntaxException {
- checkArgs(arguments);
- isLaunchableSpecific(); // checks if the ApplicationDescriptor was already unregistered
- return AppPersistenceUtil.addScheduledApp(this, arguments, topic, eventFilter, recurring);
- }
-
- /**
- * Sets the lock state of the application. If an application is locked then
- * launching a new instance is not possible. It does not affect the already
- * launched instances.
- *
- * @throws SecurityException
- * if the caller doesn't have "lock" ApplicationAdminPermission
- * for the application.
- * @throws IllegalStateException
- * if the application descriptor is unregistered
- */
- public final void lock() {
- SecurityManager sm = System.getSecurityManager();
- if (sm != null)
- sm.checkPermission(new ApplicationAdminPermission(this, ApplicationAdminPermission.LOCK_ACTION));
- synchronized (locked) {
- if (locked[0])
- return;
- locked[0] = true;
- lockSpecific();
- saveLock(true);
- }
- }
-
- /**
- * This method is used to notify the container implementation that the
- * corresponding application has been locked and it should update the
- * <code>application.locked</code> service property accordingly.
- * @throws IllegalStateException
- * if the application descriptor is unregistered
- */
- protected abstract void lockSpecific();
-
- /**
- * Unsets the lock state of the application.
- *
- * @throws SecurityException
- * if the caller doesn't have "lock" ApplicationAdminPermission
- * for the application.
- * @throws IllegalStateException
- * if the application descriptor is unregistered
- */
- public final void unlock() {
- SecurityManager sm = System.getSecurityManager();
- if (sm != null)
- sm.checkPermission(new ApplicationAdminPermission(this, ApplicationAdminPermission.LOCK_ACTION));
- synchronized (locked) {
- if (!locked[0])
- return;
- locked[0] = false;
- unlockSpecific();
- saveLock(false);
- }
- }
-
- /**
- * This method is used to notify the container implementation that the
- * corresponding application has been unlocked and it should update the
- * <code>application.locked</code> service property accordingly.
-
- * @throws IllegalStateException
- * if the application descriptor is unregistered
- */
- protected abstract void unlockSpecific();
-
- /**
- * @skip
- */
- public interface Delegate {
- void setApplicationDescriptor(ApplicationDescriptor d, String pid );
-
- boolean isLocked();
-
- void lock();
-
- void unlock();
-
- ScheduledApplication schedule(Map args, String topic, String filter,
- boolean recurs) throws InvalidSyntaxException;
-
- void launch(Map arguments) throws ApplicationException;
- }
-
- private void saveLock(boolean locked) {
- AppPersistenceUtil.saveLock(this, locked);
- }
-
- private boolean isLocked() {
- return AppPersistenceUtil.isLocked(this);
- }
-
- private void checkArgs(Map arguments) {
- if (arguments == null)
- return;
- for (Iterator keys = arguments.keySet().iterator(); keys.hasNext();) {
- Object key = keys.next();
- if (!(key instanceof String))
- throw new IllegalArgumentException("Invalid key type: " + key == null ? "<null>" : key.getClass().getName());
- if ("".equals(key))
- throw new IllegalArgumentException("Empty string is an invalid key");
- }
- }
-
- String pid;
- private boolean[] locked = {false};
-}
diff --git a/bundles/org.eclipse.equinox.app/src/org/osgi/service/application/ApplicationException.java b/bundles/org.eclipse.equinox.app/src/org/osgi/service/application/ApplicationException.java
deleted file mode 100755
index d79f861d7..000000000
--- a/bundles/org.eclipse.equinox.app/src/org/osgi/service/application/ApplicationException.java
+++ /dev/null
@@ -1,104 +0,0 @@
-package org.osgi.service.application;
-
-/**
- * This exception is used to indicate problems related to application
- * lifecycle management.
- *
- * <code>ApplicationException</code> object is created by the Application Admin to denote
- * an exception condition in the lifecycle of an application.
- * <code>ApplicationException</code>s should not be created by developers.
- * <br/>
- * <code>ApplicationException</code>s are associated with an error code. This code
- * describes the type of problem reported in this exception. The possible codes are:
- * <ul>
- * <li> {@link #APPLICATION_LOCKED} - The application couldn't be launched because it is locked.</li>
- * <li> {@link #APPLICAITON_NOT_LAUNCHABLE} - The application is not in launchable state.</li>
- * <li> {@link #APPLICATION_INTERNAL_ERROR} - An exception was thrown by the application or its
- * container during launch.</li>
- * </ul>
- *
- */
-public class ApplicationException extends Exception {
- private static final long serialVersionUID = -7173190453622508207L;
- private final Throwable cause;
- private final int errorCode;
-
- /**
- * The application couldn't be launched because it is locked.
- */
- public static final int APPLICATION_LOCKED = 0x01;
-
- /**
- * The application is not in launchable state, it's
- * {@link ApplicationDescriptor#APPLICATION_LAUNCHABLE}
- * attribute is false.
- */
- public static final int APPLICATION_NOT_LAUNCHABLE = 0x02;
-
- /**
- * An exception was thrown by the application or the corresponding
- * container during launch. The exception is available in {@link #getCause()}.
- */
- public static final int APPLICATION_INTERNAL_ERROR = 0x03;
-
- /**
- * Creates an <code>ApplicationException</code> with the specified error code.
- * @param errorCode The code of the error
- */
- public ApplicationException(int errorCode) {
- this(errorCode,(Throwable) null);
- }
-
- /**
- * Creates a <code>ApplicationException</code> that wraps another exception.
- *
- * @param errorCode The code of the error
- * @param cause The cause of this exception.
- */
- public ApplicationException(int errorCode, Throwable cause) {
- super();
- this.cause = cause;
- this.errorCode = errorCode;
- }
-
- /**
- * Creates an <code>ApplicationException</code> with the specified error code.
- * @param errorCode The code of the error
- * @param message The associated message
- */
- public ApplicationException(int errorCode, String message) {
- this(errorCode, message,null);
- }
-
- /**
- * Creates a <code>ApplicationException</code> that wraps another exception.
- *
- * @param errorCode The code of the error
- * @param message The associated message.
- * @param cause The cause of this exception.
- */
- public ApplicationException(int errorCode, String message, Throwable cause) {
- super(message);
- this.cause = cause;
- this.errorCode = errorCode;
- }
-
- /**
- * Returns the cause of this exception or <code>null</code> if no cause
- * was specified when this exception was created.
- *
- * @return The cause of this exception or <code>null</code> if no cause
- * was specified.
- */
- public Throwable getCause() {
- return cause;
- }
-
- /**
- * Returns the error code associcated with this exception.
- * @return The error code of this exception.
- */
- public int getErrorCode() {
- return errorCode;
- }
-}
diff --git a/bundles/org.eclipse.equinox.app/src/org/osgi/service/application/ApplicationHandle.java b/bundles/org.eclipse.equinox.app/src/org/osgi/service/application/ApplicationHandle.java
deleted file mode 100755
index 502a2e6c9..000000000
--- a/bundles/org.eclipse.equinox.app/src/org/osgi/service/application/ApplicationHandle.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * $Header: /cvsroot/eclipse/org.eclipse.equinox.app/src/org/osgi/service/application/ApplicationHandle.java,v 1.1 2005/12/14 22:17:04 twatson Exp $
- *
- * Copyright (c) OSGi Alliance (2004, 2005). 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.
- */
-
-package org.osgi.service.application;
-
-import org.osgi.framework.Constants;
-
-/**
- * ApplicationHandle is an OSGi service interface which represents an instance
- * of an application. It provides the functionality to query and manipulate the
- * lifecycle state of the represented application instance. It defines constants
- * for the lifecycle states.
- */
-public abstract class ApplicationHandle {
-
- /**
- * The property key for the unique identifier (PID) of the application
- * instance.
- */
- public static final String APPLICATION_PID = Constants.SERVICE_PID;
-
- /**
- * The property key for the pid of the corresponding application descriptor.
- */
- public final static String APPLICATION_DESCRIPTOR = "application.descriptor";
-
- /**
- * The property key for the state of this appliction instance.
- */
- public final static String APPLICATION_STATE = "application.state";
-
- /**
- * The application instance is running. This is the initial state of a newly
- * created application instance.
- */
- public final static String RUNNING = "RUNNING";
-
- /**
- * The application instance is being stopped. This is the state of the
- * application instance during the execution of the <code>destroy()</code>
- * method.
- */
- public final static String STOPPING = "STOPPING";
-
- private final String instanceId;
-
- /**
- * Application instance identifier is specified by the container when the
- * instance is created. The instance identifier must remain static for the
- * lifetime of the instance, it must remain the same even across framework
- * restarts for the same application instance. This value must be the same
- * as the <code>service.pid</code> service property of this application
- * handle.
- * <p>
- * The instance identifier should follow the following scheme:
- * &lt;<i>application descriptor PID</i>&gt;.&lt;<i>index</i>&gt;
- * where &lt;<i>application descriptor PID</i>&gt; is the PID of the
- * corresponding <code>ApplicationDescriptor</code> and &lt;<i>index</i>&gt;
- * is a unique integer index assigned by the application container.
- * Even after destroying the application index the same index value should not
- * be reused in a reasonably long timeframe.
- *
- * @param instanceId the instance identifier of the represented application
- * instance. It must not be null.
- *
- * @param descriptor the <code>ApplicationDescriptor</code> of the represented
- * application instance. It must not be null.
- *
- * @throws NullPointerException if any of the arguments is null.
- */
- protected ApplicationHandle(String instanceId, ApplicationDescriptor descriptor ) {
- if( (null == instanceId) || (null == descriptor) ) {
- throw new NullPointerException("Parameters must not be null!");
- }
-
- this.instanceId = instanceId;
- this.descriptor = descriptor;
- }
-
- /**
- * Retrieves the <code>ApplicationDescriptor</code> to which this
- * <code>ApplicationHandle</code> belongs.
- *
- * @return The corresponding <code>ApplicationDescriptor</code>
- */
- public final ApplicationDescriptor getApplicationDescriptor() {
- return descriptor;
- }
-
- /**
- * Get the state of the application instance.
- *
- * @return the state of the application.
- *
- * @throws IllegalStateException
- * if the application handle is unregistered
- */
- public abstract String getState();
-
- /**
- * Returns the unique identifier of this instance. This value is also
- * available as a service property of this application handle's service.pid.
- *
- * @return the unique identifier of the instance
- */
- public final String getInstanceId() {
- return instanceId;
- }
-
- /**
- * The application instance's lifecycle state can be influenced by this
- * method. It lets the application instance perform operations to stop
- * the application safely, e.g. saving its state to a permanent storage.
- * <p>
- * The method must check if the lifecycle transition is valid; a STOPPING
- * application cannot be stopped. If it is invalid then the method must
- * exit. Otherwise the lifecycle state of the application instance must be
- * set to STOPPING. Then the destroySpecific() method must be called to
- * perform any application model specific steps for safe stopping of the
- * represented application instance.
- * <p>
- * At the end the <code>ApplicationHandle</code> must be unregistered.
- * This method should free all the resources related to this
- * <code>ApplicationHandle</code>.
- * <p>
- * When this method is completed the application instance has already made
- * its operations for safe stopping, the ApplicationHandle has been
- * unregistered and its related resources has been freed. Further calls on
- * this application should not be made because they may have unexpected
- * results.
- *
- * @throws SecurityException
- * if the caller doesn't have "lifecycle"
- * <code>ApplicationAdminPermission</code> for the corresponding application.
- *
- * @throws IllegalStateException
- * if the application handle is unregistered
- */
- public final void destroy() {
- if (STOPPING.equals(getState()))
- return;
- SecurityManager sm = System.getSecurityManager();
- if (sm != null)
- sm.checkPermission(new ApplicationAdminPermission(getApplicationDescriptor(), ApplicationAdminPermission.LIFECYCLE_ACTION));
- destroySpecific();
- }
-
- /**
- * Called by the destroy() method to perform application model specific
- * steps to stop and destroy an application instance safely.
- *
- * @throws IllegalStateException
- * if the application handle is unregistered
- */
- protected abstract void destroySpecific();
-
- ApplicationDescriptor descriptor;
-
- /**
- * @skip
- *
- */
- public interface Delegate {
- void setApplicationHandle(ApplicationHandle d, ApplicationDescriptor.Delegate descriptor );
- void destroy();
- }
-}
diff --git a/bundles/org.eclipse.equinox.app/src/org/osgi/service/application/ScheduledApplication.java b/bundles/org.eclipse.equinox.app/src/org/osgi/service/application/ScheduledApplication.java
deleted file mode 100755
index d08d47a1d..000000000
--- a/bundles/org.eclipse.equinox.app/src/org/osgi/service/application/ScheduledApplication.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * $Header: /cvshome/build/org.osgi.service.application/src/org/osgi/service/application/ScheduledApplication.java,v 1.13 2005/08/29 09:24:34 ckarai Exp $
- *
- * Copyright (c) OSGi Alliance (2004, 2005). 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.
- */
-
-package org.osgi.service.application;
-
-import java.util.Map;
-
-/**
- * It is allowed to schedule an application based on a specific event.
- * ScheduledApplication service keeps the scheduling information. When the
- * specified event is fired a new instance must be launched. Note that launching
- * operation may fail because e.g. the application is locked.
- */
-public interface ScheduledApplication {
-
- /**
- * Queries the topic of the triggering event. The topic may contain a
- * trailing asterisk as wildcard.
- *
- * @return the topic of the triggering event
- *
- * @throws IllegalStateException
- * if the scheduled application service is unregistered
- */
- public String getTopic();
-
- /**
- * Queries the event filter for the triggering event.
- *
- * @return the event filter for triggering event
- *
- * @throws IllegalStateException
- * if the scheduled application service is unregistered
- */
- public String getEventFilter();
-
- /**
- * Queries if the scheduling is recurring.
- *
- * @return true if the scheduling is recurring, otherwise returns false
- *
- * @throws IllegalStateException
- * if the scheduled application service is unregistered
- */
- public boolean isRecurring();
-
- /**
- * Retrieves the ApplicationDescriptor which represents the application and
- * necessary for launching.
- *
- * @return the application descriptor that
- * represents the scheduled application
- *
- * @throws IllegalStateException
- * if the scheduled application service is unregistered
- */
- public ApplicationDescriptor getApplicationDescriptor();
-
- /**
- * Queries the startup arguments specified when the application was
- * scheduled. The method returns a copy of the arguments, it is not possible
- * to modify the arguments after scheduling.
- *
- * @return the startup arguments of the scheduled application. It may be
- * null if null argument was specified.
- *
- * @throws IllegalStateException
- * if the scheduled application service is unregistered
- */
- public Map getArguments();
-
- /**
- * Cancels this schedule of the application.
- *
- * @throws SecurityException
- * if the caller doesn't have "schedule"
- * ApplicationAdminPermission for the scheduled application.
- * @throws IllegalStateException
- * if the scheduled application service is unregistered
- */
- public void remove();
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.common/.classpath b/bundles/org.eclipse.equinox.common/.classpath
deleted file mode 100644
index 751c8f2e5..000000000
--- a/bundles/org.eclipse.equinox.common/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/bundles/org.eclipse.equinox.common/.cvsignore b/bundles/org.eclipse.equinox.common/.cvsignore
deleted file mode 100644
index ba077a403..000000000
--- a/bundles/org.eclipse.equinox.common/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
diff --git a/bundles/org.eclipse.equinox.common/.project b/bundles/org.eclipse.equinox.common/.project
deleted file mode 100644
index 2289dee11..000000000
--- a/bundles/org.eclipse.equinox.common/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.equinox.common</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/bundles/org.eclipse.equinox.common/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.common/META-INF/MANIFEST.MF
deleted file mode 100644
index 36368a798..000000000
--- a/bundles/org.eclipse.equinox.common/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,18 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %pluginName
-Bundle-SymbolicName: org.eclipse.equinox.common; singleton:=true
-Bundle-Version: 1.0.0.qualifier
-Bundle-Localization: plugin
-Export-Package: org.eclipse.core.internal.runtime;x-friends:="org.eclipse.core.contenttype,org.eclipse.core.jobs,org.eclipse.equinox.preferences,org.eclipse.equinox.registry,org.eclipse.core.runtime,org.eclipse.core.runtime.compatibility",
- org.eclipse.core.runtime
-Bundle-Vendor: %providerName
-Bundle-Activator: org.eclipse.core.internal.runtime.Activator
-Import-Package: org.eclipse.osgi.framework.log,
- org.eclipse.osgi.service.datalocation,
- org.eclipse.osgi.service.localization,
- org.eclipse.osgi.service.urlconversion,
- org.eclipse.osgi.util,
- org.osgi.framework,
- org.osgi.service.packageadmin,
- org.osgi.util.tracker
diff --git a/bundles/org.eclipse.equinox.common/about.html b/bundles/org.eclipse.equinox.common/about.html
deleted file mode 100644
index cdc1e5004..000000000
--- a/bundles/org.eclipse.equinox.common/about.html
+++ /dev/null
@@ -1,24 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<html>
-<head>
-<title>About</title>
-<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-</head>
-<body lang="EN-US">
-<h2>About This Content</h2>
-
-<p>September 26, 2005</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" target="_blank">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.</p>
-
-<small>Java and all Java-based trademarks and logos are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries.</small>
-
-</body>
-</html>
diff --git a/bundles/org.eclipse.equinox.common/build.properties b/bundles/org.eclipse.equinox.common/build.properties
deleted file mode 100644
index c1e8ad782..000000000
--- a/bundles/org.eclipse.equinox.common/build.properties
+++ /dev/null
@@ -1,17 +0,0 @@
-###############################################################################
-# Copyright (c) 2005 IBM Corporation 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:
-# IBM Corporation - initial API and implementation
-###############################################################################
-source.. = src/
-output.. = bin/
-bin.includes = META-INF/,\
- .,\
- plugin.properties,\
- about.html
-src.includes = about.html
diff --git a/bundles/org.eclipse.equinox.common/plugin.properties b/bundles/org.eclipse.equinox.common/plugin.properties
deleted file mode 100644
index 9badd2f46..000000000
--- a/bundles/org.eclipse.equinox.common/plugin.properties
+++ /dev/null
@@ -1,12 +0,0 @@
-###############################################################################
-# Copyright (c) 2005 IBM Corporation 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:
-# IBM Corporation - initial API and implementation
-###############################################################################
-pluginName = Common Eclipse Runtime
-providerName = Eclipse.org
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/Activator.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/Activator.java
deleted file mode 100644
index 95908bd4a..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/Activator.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.runtime;
-
-import java.net.URL;
-import java.util.*;
-import org.eclipse.osgi.service.urlconversion.URLConverter;
-import org.osgi.framework.*;
-import org.osgi.util.tracker.ServiceTracker;
-
-/**
- * The Common runtime plugin class.
- *
- * This class can only be used if OSGi plugin is available.
- */
-public class Activator implements BundleActivator {
-
- /**
- * Table to keep track of all the URL converter services.
- */
- private static Map urlTrackers = new HashMap();
-
- /**
- * The bundle context associated this plug-in
- */
- private static BundleContext bundleContext;
-
- /**
- * This method is called upon plug-in activation
- */
- public void start(BundleContext context) throws Exception {
- bundleContext = context;
- }
-
- /**
- * This method is called when the plug-in is stopped
- */
- public void stop(BundleContext context) throws Exception {
- CommonOSGiUtils.getDefault().closeServices();
- closeURLTrackerServices();
- bundleContext = null;
- }
-
- static BundleContext getContext() {
- return bundleContext;
- }
-
- /*
- * Let go of all the services that we aquired and kept track of.
- */
- private static void closeURLTrackerServices() {
- synchronized (urlTrackers) {
- if (!urlTrackers.isEmpty()) {
- for (Iterator iter = urlTrackers.keySet().iterator(); iter.hasNext();) {
- String key = (String) iter.next();
- ServiceTracker tracker = (ServiceTracker) urlTrackers.get(key);
- tracker.close();
- }
- urlTrackers = new HashMap();
- }
- }
- }
-
- /*
- * Return the URL Converter for the given URL. Return null if we can't
- * find one.
- */
- public static URLConverter getURLConverter(URL url) {
- String protocol = url.getProtocol();
- synchronized (urlTrackers) {
- ServiceTracker tracker = (ServiceTracker) urlTrackers.get(protocol);
- if (tracker == null) {
- // get the right service based on the protocol
- String FILTER_PREFIX = "(&(objectClass=" + URLConverter.class.getName() + ")(protocol="; //$NON-NLS-1$ //$NON-NLS-2$
- String FILTER_POSTFIX = "))"; //$NON-NLS-1$
- Filter filter = null;
- try {
- filter = getContext().createFilter(FILTER_PREFIX + protocol + FILTER_POSTFIX);
- } catch (InvalidSyntaxException e) {
- return null;
- }
- tracker = new ServiceTracker(getContext(), filter, null);
- tracker.open();
- // cache it in the registry
- urlTrackers.put(protocol, tracker);
- }
- return (URLConverter) tracker.getService();
- }
- }
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/AdapterManager.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/AdapterManager.java
deleted file mode 100644
index 55e9a0213..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/AdapterManager.java
+++ /dev/null
@@ -1,353 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.runtime;
-
-import java.util.*;
-import org.eclipse.core.runtime.IAdapterFactory;
-import org.eclipse.core.runtime.IAdapterManager;
-
-/**
- * This class is the standard implementation of <code>IAdapterManager</code>. It provides
- * fast lookup of property values with the following semantics:
- * <ul>
- * <li>At most one factory will be invoked per property lookup
- * <li>If multiple installed factories provide the same adapter, only the first found in
- * the search order will be invoked.
- * <li>The search order from a class with the definition <br>
- * <code>class X extends Y implements A, B</code><br> is as follows: <il>
- * <li>the target's class: X
- * <li>X's superclasses in order to <code>Object</code>
- * <li>a breadth-first traversal of the target class's interfaces in the order returned by
- * <code>getInterfaces</code> (in the example, A and its superinterfaces then B and its
- * superinterfaces) </il>
- * </ul>
- *
- * @see IAdapterFactory
- * @see IAdapterManager
- */
-public final class AdapterManager implements IAdapterManager {
- /**
- * Cache of adapters for a given adaptable class. Maps String -> Map
- * (adaptable class name -> (adapter class name -> factory instance))
- */
- protected HashMap adapterLookup;
- /**
- * Cache of classes for a given type name. Avoids too many loadClass calls.
- * (factory -> (type name -> clazz))
- */
- protected HashMap classLookup;
- /**
- * Cache of class lookup order. This avoids having to compute often, and
- * provides clients with quick lookup for instanceOf checks based on type name.
- */
- protected HashMap classSearchOrderLookup;
- /**
- * Map of factories, keyed by <code>String</code>, fully qualified class name of
- * the adaptable class that the factory provides adapters for. Value is a <code>List</code>
- * of <code>IAdapterFactory</code>.
- */
- protected final HashMap factories;
-
- private static final AdapterManager singleton = new AdapterManager();
-
- public static AdapterManager getDefault() {
- return singleton;
- }
-
- /**
- * Private constructor to block instance creation.
- */
- private AdapterManager() {
- factories = new HashMap(5);
- adapterLookup = null;
- }
-
- /**
- * Given a type name, add all of the factories that respond to those types into
- * the given table. Each entry will be keyed by the adapter class name (supplied in
- * IAdapterFactory.getAdapterList).
- */
- private void addFactoriesFor(String typeName, Map table) {
- List factoryList = (List) factories.get(typeName);
- if (factoryList == null)
- return;
- for (int i = 0, imax = factoryList.size(); i < imax; i++) {
- IAdapterFactory factory = (IAdapterFactory) factoryList.get(i);
- if (factory instanceof IAdapterFactoryExt) {
- String[] adapters = ((IAdapterFactoryExt) factory).getAdapterNames();
- for (int j = 0; j < adapters.length; j++) {
- if (table.get(adapters[j]) == null)
- table.put(adapters[j], factory);
- }
- } else {
- Class[] adapters = factory.getAdapterList();
- for (int j = 0; j < adapters.length; j++) {
- String adapterName = adapters[j].getName();
- if (table.get(adapterName) == null)
- table.put(adapterName, factory);
- }
- }
- }
- }
-
- private void cacheClassLookup(IAdapterFactory factory, Class clazz) {
- //cache reference to lookup to protect against concurrent flush
- HashMap lookup = classLookup;
- if (lookup == null)
- classLookup = lookup = new HashMap(4);
- HashMap classes = (HashMap) lookup.get(factory);
- if (classes == null) {
- classes = new HashMap(4);
- lookup.put(factory, classes);
- }
- classes.put(clazz.getName(), clazz);
- }
-
- private Class cachedClassForName(IAdapterFactory factory, String typeName) {
- Class clazz = null;
- //cache reference to lookup to protect against concurrent flush
- HashMap lookup = classLookup;
- if (lookup != null) {
- HashMap classes = (HashMap) lookup.get(factory);
- if (classes != null) {
- clazz = (Class) classes.get(typeName);
- }
- }
- return clazz;
- }
-
- /**
- * Returns the class with the given fully qualified name, or null
- * if that class does not exist or belongs to a plug-in that has not
- * yet been loaded.
- */
- private Class classForName(IAdapterFactory factory, String typeName) {
- Class clazz = cachedClassForName(factory, typeName);
- if (clazz == null) {
- try {
- if (factory instanceof IAdapterFactoryExt)
- factory = ((IAdapterFactoryExt) factory).loadFactory(false);
- if (factory != null) {
- clazz = factory.getClass().getClassLoader().loadClass(typeName);
- cacheClassLookup(factory, clazz);
- }
- } catch (ClassNotFoundException e) {
- // class not yet loaded
- }
- }
- return clazz;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.IAdapterManager#getAdapterTypes(java.lang.Class)
- */
- public String[] computeAdapterTypes(Class adaptable) {
- Set types = getFactories(adaptable).keySet();
- return (String[]) types.toArray(new String[types.size()]);
- }
-
- /**
- * Computes the adapters that the provided class can adapt to, along
- * with the factory object that can perform that transformation. Returns
- * a table of adapter class name to factory object.
- * @param adaptable
- */
- private Map getFactories(Class adaptable) {
- //cache reference to lookup to protect against concurrent flush
- HashMap lookup = adapterLookup;
- if (lookup == null)
- adapterLookup = lookup = new HashMap(30);
- Map table = (Map) lookup.get(adaptable.getName());
- if (table == null) {
- // calculate adapters for the class
- table = new HashMap(4);
- Class[] classes = computeClassOrder(adaptable);
- for (int i = 0; i < classes.length; i++)
- addFactoriesFor(classes[i].getName(), table);
- // cache the table
- lookup.put(adaptable.getName(), table);
- }
- return table;
- }
-
- public Class[] computeClassOrder(Class adaptable) {
- List classes = null;
- //cache reference to lookup to protect against concurrent flush
- HashMap lookup = classSearchOrderLookup;
- if (lookup != null)
- classes = (List) lookup.get(adaptable);
- // compute class order only if it hasn't been cached before
- if (classes == null) {
- classes = new ArrayList();
- computeClassOrder(adaptable, classes);
- if (lookup == null)
- classSearchOrderLookup = lookup = new HashMap();
- lookup.put(adaptable, classes);
- }
- return (Class[]) classes.toArray(new Class[classes.size()]);
- }
-
- /**
- * Builds and returns a table of adapters for the given adaptable type.
- * The table is keyed by adapter class name. The
- * value is the <b>sole<b> factory that defines that adapter. Note that
- * if multiple adapters technically define the same property, only the
- * first found in the search order is considered.
- *
- * Note that it is important to maintain a consistent class and interface
- * lookup order. See the class comment for more details.
- */
- private void computeClassOrder(Class adaptable, Collection classes) {
- Class clazz = adaptable;
- Set seen = new HashSet(4);
- while (clazz != null) {
- classes.add(clazz);
- computeInterfaceOrder(clazz.getInterfaces(), classes, seen);
- clazz = clazz.getSuperclass();
- }
- }
-
- private void computeInterfaceOrder(Class[] interfaces, Collection classes, Set seen) {
- List newInterfaces = new ArrayList(interfaces.length);
- for (int i = 0; i < interfaces.length; i++) {
- Class interfac = interfaces[i];
- if (seen.add(interfac)) {
- //note we cannot recurse here without changing the resulting interface order
- classes.add(interfac);
- newInterfaces.add(interfac);
- }
- }
- for (Iterator it = newInterfaces.iterator(); it.hasNext();)
- computeInterfaceOrder(((Class) it.next()).getInterfaces(), classes, seen);
- }
-
- /**
- * Flushes the cache of adapter search paths. This is generally required whenever an
- * adapter is added or removed.
- * <p>
- * It is likely easier to just toss the whole cache rather than trying to be smart
- * and remove only those entries affected.
- * </p>
- */
- public synchronized void flushLookup() {
- adapterLookup = null;
- classLookup = null;
- classSearchOrderLookup = null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.IAdapterManager#getAdapter(java.lang.Object, java.lang.Class)
- */
- public Object getAdapter(Object adaptable, Class adapterType) {
- IAdapterFactory factory = (IAdapterFactory) getFactories(adaptable.getClass()).get(adapterType.getName());
- Object result = null;
- if (factory != null)
- result = factory.getAdapter(adaptable, adapterType);
- if (result == null && adapterType.isInstance(adaptable))
- return adaptable;
- return result;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.IAdapterManager#getAdapter(java.lang.Object, java.lang.Class)
- */
- public Object getAdapter(Object adaptable, String adapterType) {
- return getAdapter(adaptable, adapterType, false);
- }
-
- /**
- * Returns an adapter of the given type for the provided adapter.
- * @param adaptable the object to adapt
- * @param adapterType the type to adapt the object to
- * @param force <code>true</code> if the plug-in providing the
- * factory should be activated if necessary. <code>false</code>
- * if no plugin activations are desired.
- */
- private Object getAdapter(Object adaptable, String adapterType, boolean force) {
- IAdapterFactory factory = (IAdapterFactory) getFactories(adaptable.getClass()).get(adapterType);
- if (force && factory instanceof IAdapterFactoryExt)
- factory = ((IAdapterFactoryExt) factory).loadFactory(true);
- Object result = null;
- if (factory != null) {
- Class clazz = classForName(factory, adapterType);
- if (clazz != null)
- result = factory.getAdapter(adaptable, clazz);
- }
- if (result == null && adaptable.getClass().getName().equals(adapterType))
- return adaptable;
- return result;
- }
-
- public boolean hasAdapter(Object adaptable, String adapterTypeName) {
- return getFactories(adaptable.getClass()).get(adapterTypeName) != null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.IAdapterManager#loadAdapter(java.lang.Object, java.lang.String)
- */
- public Object loadAdapter(Object adaptable, String adapterTypeName) {
- return getAdapter(adaptable, adapterTypeName, true);
- }
-
- /*
- * @see IAdapterManager#registerAdapters
- */
- public synchronized void registerAdapters(IAdapterFactory factory, Class adaptable) {
- registerFactory(factory, adaptable.getName());
- flushLookup();
- }
-
- /*
- * @see IAdapterManager#registerAdapters
- */
- public void registerFactory(IAdapterFactory factory, String adaptableType) {
- List list = (List) factories.get(adaptableType);
- if (list == null) {
- list = new ArrayList(5);
- factories.put(adaptableType, list);
- }
- list.add(factory);
- }
-
- /*
- * @see IAdapterManager#unregisterAdapters
- */
- public synchronized void unregisterAdapters(IAdapterFactory factory) {
- for (Iterator it = factories.values().iterator(); it.hasNext();)
- ((List) it.next()).remove(factory);
- flushLookup();
- }
-
- /*
- * @see IAdapterManager#unregisterAdapters
- */
- public synchronized void unregisterAdapters(IAdapterFactory factory, Class adaptable) {
- List factoryList = (List) factories.get(adaptable.getName());
- if (factoryList == null)
- return;
- factoryList.remove(factory);
- flushLookup();
- }
-
- /*
- * Shuts down the adapter manager by removing all factories
- * and removing the registry change listener. Should only be
- * invoked during platform shutdown.
- */
- public synchronized void unregisterAllAdapters() {
- factories.clear();
- flushLookup();
- }
-
- public HashMap getFactories() {
- return factories;
- }
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/CommonMessages.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/CommonMessages.java
deleted file mode 100644
index af00d3d77..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/CommonMessages.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2005 IBM Corporation 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:
- * IBM - Initial API and implementation
- **********************************************************************/
-package org.eclipse.core.internal.runtime;
-
-import org.eclipse.osgi.util.NLS;
-
-// Common runtime plugin message catalog
-public class CommonMessages extends NLS {
- private static final String BUNDLE_NAME = "org.eclipse.core.internal.runtime.commonMessages"; //$NON-NLS-1$
-
- public static String ok;
-
- // metadata
- public static String meta_couldNotCreate;
- public static String meta_instanceDataUnspecified;
- public static String meta_noDataModeSpecified;
- public static String meta_notDir;
- public static String meta_readonly;
- public static String meta_pluginProblems;
-
- // parsing/resolve
- public static String parse_doubleSeparatorVersion;
- public static String parse_emptyPluginVersion;
- public static String parse_fourElementPluginVersion;
- public static String parse_numericMajorComponent;
- public static String parse_numericMinorComponent;
- public static String parse_numericServiceComponent;
- public static String parse_oneElementPluginVersion;
-
- public static String parse_postiveMajor;
- public static String parse_postiveMinor;
- public static String parse_postiveService;
- public static String parse_separatorEndVersion;
- public static String parse_separatorStartVersion;
-
- // FileMananger messages
- public static String fileManager_cannotLock;
- public static String fileManager_couldNotSave;
- public static String fileManager_updateFailed;
- public static String fileManager_illegalInReadOnlyMode;
- public static String fileManager_notOpen;
-
- static {
- // load message values from bundle file
- reloadMessages();
- }
-
- public static void reloadMessages() {
- NLS.initializeMessages(BUNDLE_NAME, CommonMessages.class);
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/CommonOSGiUtils.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/CommonOSGiUtils.java
deleted file mode 100644
index b4aae6b15..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/CommonOSGiUtils.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.runtime;
-
-import java.util.Date;
-import java.util.ResourceBundle;
-import org.eclipse.osgi.framework.log.FrameworkLog;
-import org.eclipse.osgi.service.datalocation.Location;
-import org.eclipse.osgi.service.localization.BundleLocalization;
-import org.osgi.framework.*;
-import org.osgi.service.packageadmin.PackageAdmin;
-import org.osgi.util.tracker.ServiceTracker;
-
-/**
- * The class contains a set of helper methods for the runtime content plugin.
- * The following utility methods are supplied:
- * - provides framework log
- * - provides some bundle discovery funtionality
- * - provides some location services
- *
- * The closeServices() method should be called before the plugin is stopped.
- *
- * This class can only be used if OSGi plugin is available.
- *
- * @since org.eclipse.equinox.common 1.0
- */
-public class CommonOSGiUtils {
- private ServiceTracker logTracker = null;
- private ServiceTracker bundleTracker = null;
- private ServiceTracker instanceLocationTracker = null;
- private ServiceTracker localizationTracker = null;
-
- // OSGI system properties. Copied from EclipseStarter
- public static final String PROP_INSTANCE_AREA = "osgi.instance.area"; //$NON-NLS-1$
-
- private static final CommonOSGiUtils singleton = new CommonOSGiUtils();
-
- public static CommonOSGiUtils getDefault() {
- return singleton;
- }
-
- /**
- * Private constructor to block instance creation.
- */
- private CommonOSGiUtils() {
- super();
- initServices();
- }
-
- /**
- * Print a debug message to the console.
- * Pre-pend the message with the current date and the name of the current thread.
- */
- public static void message(String message) {
- StringBuffer buffer = new StringBuffer();
- buffer.append(new Date(System.currentTimeMillis()));
- buffer.append(" - ["); //$NON-NLS-1$
- buffer.append(Thread.currentThread().getName());
- buffer.append("] "); //$NON-NLS-1$
- buffer.append(message);
- System.out.println(buffer.toString());
- }
-
- private void initServices() {
- BundleContext context = Activator.getContext();
- if (context == null) {
- message("CommonOSGiUtils called before plugin started"); //$NON-NLS-1$
- return;
- }
-
- logTracker = new ServiceTracker(context, FrameworkLog.class.getName(), null);
- logTracker.open();
-
- bundleTracker = new ServiceTracker(context, PackageAdmin.class.getName(), null);
- bundleTracker.open();
-
- // locations
-
- final String FILTER_PREFIX = "(&(objectClass=org.eclipse.osgi.service.datalocation.Location)(type="; //$NON-NLS-1$
- Filter filter = null;
- try {
- filter = context.createFilter(FILTER_PREFIX + PROP_INSTANCE_AREA + "))"); //$NON-NLS-1$
- } catch (InvalidSyntaxException e) {
- // ignore this. It should never happen as we have tested the above format.
- }
- instanceLocationTracker = new ServiceTracker(context, filter, null);
- instanceLocationTracker.open();
- }
-
- void closeServices() {
- if (localizationTracker != null) {
- localizationTracker.close();
- localizationTracker = null;
- }
- if (logTracker != null) {
- logTracker.close();
- logTracker = null;
- }
- if (bundleTracker != null) {
- bundleTracker.close();
- bundleTracker = null;
- }
- if (instanceLocationTracker != null) {
- instanceLocationTracker.close();
- instanceLocationTracker = null;
- }
- }
-
- public FrameworkLog getFrameworkLog() {
- if (logTracker != null)
- return (FrameworkLog) logTracker.getService();
- message("Log tracker is not set"); //$NON-NLS-1$
- return null;
- }
-
- public Bundle[] getFragments(Bundle bundle) {
- if (bundleTracker == null) {
- message("Bundle tracker is not set"); //$NON-NLS-1$
- return null;
- }
- PackageAdmin packageAdmin = (PackageAdmin) bundleTracker.getService();
- if (packageAdmin == null)
- return null;
- return packageAdmin.getFragments(bundle);
- }
-
- public Location getInstanceLocation() {
- if (instanceLocationTracker != null)
- return (Location) instanceLocationTracker.getService();
- else
- return null;
- }
-
- public ResourceBundle getLocalization(Bundle bundle, String locale) {
- if (localizationTracker == null) {
- BundleContext context = Activator.getContext();
- if (context == null) {
- message("ResourceTranslator called before plugin is started"); //$NON-NLS-1$
- return null;
- }
- localizationTracker = new ServiceTracker(context, BundleLocalization.class.getName(), null);
- localizationTracker.open();
- }
- BundleLocalization location = (BundleLocalization) localizationTracker.getService();
- if (location != null)
- return location.getLocalization(bundle, locale);
-
- return null;
- }
-
- /**
- * Returns the bundle id of the bundle that contains the provided object, or
- * <code>null</code> if the bundle could not be determined.
- */
- public String getBundleId(Object object) {
- if (object == null)
- return null;
- if (bundleTracker == null) {
- message("Bundle tracker is not set"); //$NON-NLS-1$
- return null;
- }
- PackageAdmin packageAdmin = (PackageAdmin) bundleTracker.getService();
- if (packageAdmin == null)
- return null;
-
- Bundle source = packageAdmin.getBundle(object.getClass());
- if (source != null && source.getSymbolicName() != null)
- return source.getSymbolicName();
- return null;
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/DataArea.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/DataArea.java
deleted file mode 100644
index 6eaf5f6bd..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/DataArea.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.runtime;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-import org.eclipse.core.runtime.*;
-import org.eclipse.osgi.service.datalocation.Location;
-import org.eclipse.osgi.util.NLS;
-import org.osgi.framework.Bundle;
-
-/**
- * This class can only be used if OSGi plugin is available
- */
-public class DataArea {
- /* package */static final String F_META_AREA = ".metadata"; //$NON-NLS-1$
- /* package */static final String F_PLUGIN_DATA = ".plugins"; //$NON-NLS-1$
- /* package */static final String F_LOG = ".log"; //$NON-NLS-1$
- /**
- * Internal name of the preference storage file (value <code>"pref_store.ini"</code>) in this plug-in's (read-write) state area.
- */
- /* package */static final String PREFERENCES_FILE_NAME = "pref_store.ini"; //$NON-NLS-1$
-
- private IPath location; //The location of the instance data
- private boolean initialized = false;
-
- protected void assertLocationInitialized() throws IllegalStateException {
- if (location != null && initialized)
- return;
- Location service = CommonOSGiUtils.getDefault().getInstanceLocation();
- if (service == null)
- throw new IllegalStateException(CommonMessages.meta_noDataModeSpecified);
- try {
- URL url = service.getURL();
- if (url == null)
- throw new IllegalStateException(CommonMessages.meta_instanceDataUnspecified);
- // TODO assume the URL is a file:
- // Use the new File technique to ensure that the resultant string is
- // in the right format (e.g., leading / removed from /c:/foo etc)
- location = new Path(new File(url.getFile()).toString());
- initializeLocation();
- } catch (CoreException e) {
- throw new IllegalStateException(e.getMessage());
- }
- }
-
- public IPath getMetadataLocation() throws IllegalStateException {
- assertLocationInitialized();
- return location.append(F_META_AREA);
- }
-
- public IPath getInstanceDataLocation() throws IllegalStateException {
- assertLocationInitialized();
- return location;
- }
-
- public IPath getLogLocation() throws IllegalStateException {
- return new Path(CommonOSGiUtils.getDefault().getFrameworkLog().getFile().getAbsolutePath());
- }
-
- /**
- * Returns the read/write location in which the given bundle can manage private state.
- */
- public IPath getStateLocation(Bundle bundle) throws IllegalStateException {
- assertLocationInitialized();
- return getStateLocation(bundle.getSymbolicName());
- }
-
- public IPath getStateLocation(String bundleName) throws IllegalStateException {
- assertLocationInitialized();
- return getMetadataLocation().append(F_PLUGIN_DATA).append(bundleName);
- }
-
- public IPath getPreferenceLocation(String bundleName, boolean create) throws IllegalStateException {
- IPath result = getStateLocation(bundleName);
- if (create)
- result.toFile().mkdirs();
- return result.append(PREFERENCES_FILE_NAME);
- }
-
- private void initializeLocation() throws CoreException {
- // check if the location can be created
- if (location.toFile().exists()) {
- if (!location.toFile().isDirectory()) {
- String message = NLS.bind(CommonMessages.meta_notDir, location);
- throw new CoreException(new Status(IStatus.ERROR, IRuntimeConstants.PI_RUNTIME, IRuntimeConstants.FAILED_WRITE_METADATA, message, null));
- }
- }
- //try infer the device if there isn't one (windows)
- if (location.getDevice() == null)
- location = new Path(location.toFile().getAbsolutePath());
- createLocation();
- initialized = true;
- }
-
- private void createLocation() throws CoreException {
- // append on the metadata location so that the whole structure is created.
- File file = location.append(F_META_AREA).toFile();
- try {
- file.mkdirs();
- } catch (Exception e) {
- String message = NLS.bind(CommonMessages.meta_couldNotCreate, file.getAbsolutePath());
- throw new CoreException(new Status(IStatus.ERROR, IRuntimeConstants.PI_RUNTIME, IRuntimeConstants.FAILED_WRITE_METADATA, message, e));
- }
- if (!file.canWrite()) {
- String message = NLS.bind(CommonMessages.meta_readonly, file.getAbsolutePath());
- throw new CoreException(new Status(IStatus.ERROR, IRuntimeConstants.PI_RUNTIME, IRuntimeConstants.FAILED_WRITE_METADATA, message, null));
- }
- // set the log file location now that we created the data area
- IPath path = location.append(F_META_AREA).append(F_LOG);
- try {
- CommonOSGiUtils.getDefault().getFrameworkLog().setFile(path.toFile(), true);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/DevClassPathHelper.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/DevClassPathHelper.java
deleted file mode 100644
index de1e0222b..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/DevClassPathHelper.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.runtime;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.*;
-
-public class DevClassPathHelper {
-
- // command line options
- public static final String PROP_DEV = "osgi.dev"; //$NON-NLS-1$
-
- static protected boolean inDevelopmentMode = false;
- static protected String[] devDefaultClasspath;
- static protected Properties devProperties = null;
-
- static {
- // Check the osgi.dev property to see if dev classpath entries have been defined.
- String osgiDev = Activator.getContext() == null ? System.getProperty(PROP_DEV) : Activator.getContext().getProperty(PROP_DEV);
- if (osgiDev != null) {
- try {
- inDevelopmentMode = true;
- URL location = new URL(osgiDev);
- devProperties = load(location);
- if (devProperties != null)
- devDefaultClasspath = getArrayFromList(devProperties.getProperty("*")); //$NON-NLS-1$
- } catch (MalformedURLException e) {
- devDefaultClasspath = getArrayFromList(osgiDev);
- }
- }
- }
-
- public static String[] getDevClassPath(String id) {
- String[] result = null;
- if (id != null && devProperties != null) {
- String entry = devProperties.getProperty(id);
- if (entry != null)
- result = getArrayFromList(entry);
- }
- if (result == null)
- result = devDefaultClasspath;
- return result;
- }
-
- /**
- * Returns the result of converting a list of comma-separated tokens into an array
- *
- * @return the array of string tokens
- * @param prop the initial comma-separated string
- */
- public static String[] getArrayFromList(String prop) {
- if (prop == null || prop.trim().equals("")) //$NON-NLS-1$
- return new String[0];
- Vector list = new Vector();
- StringTokenizer tokens = new StringTokenizer(prop, ","); //$NON-NLS-1$
- while (tokens.hasMoreTokens()) {
- String token = tokens.nextToken().trim();
- if (!token.equals("")) //$NON-NLS-1$
- list.addElement(token);
- }
- return list.isEmpty() ? new String[0] : (String[]) list.toArray(new String[list.size()]);
- }
-
- public static boolean inDevelopmentMode() {
- return inDevelopmentMode;
- }
-
- /*
- * Load the given properties file
- */
- private static Properties load(URL url) {
- Properties props = new Properties();
- try {
- InputStream is = null;
- try {
- is = url.openStream();
- props.load(is);
- } finally {
- if (is != null)
- is.close();
- }
- } catch (IOException e) {
- // TODO consider logging here
- }
- return props;
- }
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/FindSupport.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/FindSupport.java
deleted file mode 100644
index caa5aaf2d..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/FindSupport.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.runtime;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Map;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.osgi.framework.Bundle;
-
-// This class provides implements the find* methods exposed on Platform.
-// It does the lookup in bundles and fragments and does the variable replacement.
-// Can only be used if OSGi is available.
-public class FindSupport {
- // OSGI system properties
- public static final String PROP_NL = "osgi.nl"; //$NON-NLS-1$
- public static final String PROP_OS = "osgi.os"; //$NON-NLS-1$
- public static final String PROP_WS = "osgi.ws"; //$NON-NLS-1$
- public static final String PROP_ARCH = "osgi.arch"; //$NON-NLS-1$
-
- private static String[] NL_JAR_VARIANTS = buildNLVariants(Activator.getContext() == null ? System.getProperty(PROP_NL) : Activator.getContext().getProperty(PROP_NL));
-
- private static String[] buildNLVariants(String nl) {
- ArrayList result = new ArrayList();
- IPath base = new Path("nl"); //$NON-NLS-1$
-
- IPath path = new Path(nl.replace('_', '/'));
- while (path.segmentCount() > 0) {
- result.add(base.append(path).toString());
- // for backwards compatibility only, don't replace the slashes
- if (path.segmentCount() > 1)
- result.add(base.append(path.toString().replace('/', '_')).toString());
- path = path.removeLastSegments(1);
- }
-
- return (String[]) result.toArray(new String[result.size()]);
- }
-
- /**
- * See doc on @link Platform#find(Bundle, IPath) Platform#find(Bundle, IPath)
- */
- public static URL find(Bundle bundle, IPath path) {
- return find(bundle, path, null);
- }
-
- /**
- * See doc on @link Platform#find(Bundle, IPath, Map) Platform#find(Bundle, IPath, Map)
- */
- public static URL find(Bundle b, IPath path, Map override) {
- if (path == null)
- return null;
-
- URL result = null;
-
- // Check for the empty or root case first
- if (path.isEmpty() || path.isRoot()) {
- // Watch for the root case. It will produce a new
- // URL which is only the root directory (and not the
- // root of this plugin).
- result = findInPlugin(b, Path.EMPTY);
- if (result == null)
- result = findInFragments(b, Path.EMPTY);
- return result;
- }
-
- // Now check for paths without variable substitution
- String first = path.segment(0);
- if (first.charAt(0) != '$') {
- result = findInPlugin(b, path);
- if (result == null)
- result = findInFragments(b, path);
- return result;
- }
-
- // Worry about variable substitution
- IPath rest = path.removeFirstSegments(1);
- if (first.equalsIgnoreCase("$nl$")) //$NON-NLS-1$
- return findNL(b, rest, override);
- if (first.equalsIgnoreCase("$os$")) //$NON-NLS-1$
- return findOS(b, rest, override);
- if (first.equalsIgnoreCase("$ws$")) //$NON-NLS-1$
- return findWS(b, rest, override);
- if (first.equalsIgnoreCase("$files$")) //$NON-NLS-1$
- return null;
-
- return null;
- }
-
- private static URL findOS(Bundle b, IPath path, Map override) {
- String os = null;
- if (override != null)
- try {
- // check for override
- os = (String) override.get("$os$"); //$NON-NLS-1$
- } catch (ClassCastException e) {
- // just in case
- }
- if (os == null)
- // use default
- os = Activator.getContext().getProperty(PROP_OS);
- if (os.length() == 0)
- return null;
-
- // Now do the same for osarch
- String osArch = null;
- if (override != null)
- try {
- // check for override
- osArch = (String) override.get("$arch$"); //$NON-NLS-1$
- } catch (ClassCastException e) {
- // just in case
- }
- if (osArch == null)
- // use default
- osArch = Activator.getContext().getProperty(PROP_ARCH);
- if (osArch.length() == 0)
- return null;
-
- URL result = null;
- IPath base = new Path("os").append(os).append(osArch); //$NON-NLS-1$
- // Keep doing this until all you have left is "os" as a path
- while (base.segmentCount() != 1) {
- IPath filePath = base.append(path);
- result = findInPlugin(b, filePath);
- if (result != null)
- return result;
- result = findInFragments(b, filePath);
- if (result != null)
- return result;
- base = base.removeLastSegments(1);
- }
- // If we get to this point, we haven't found it yet.
- // Look in the plugin and fragment root directories
- result = findInPlugin(b, path);
- if (result != null)
- return result;
- return findInFragments(b, path);
- }
-
- private static URL findWS(Bundle b, IPath path, Map override) {
- String ws = null;
- if (override != null)
- try {
- // check for override
- ws = (String) override.get("$ws$"); //$NON-NLS-1$
- } catch (ClassCastException e) {
- // just in case
- }
- if (ws == null)
- // use default
- ws = Activator.getContext().getProperty(PROP_WS);
- IPath filePath = new Path("ws").append(ws).append(path); //$NON-NLS-1$
- // We know that there is only one segment to the ws path
- // e.g. ws/win32
- URL result = findInPlugin(b, filePath);
- if (result != null)
- return result;
- result = findInFragments(b, filePath);
- if (result != null)
- return result;
- // If we get to this point, we haven't found it yet.
- // Look in the plugin and fragment root directories
- result = findInPlugin(b, path);
- if (result != null)
- return result;
- return findInFragments(b, path);
- }
-
- private static URL findNL(Bundle b, IPath path, Map override) {
- String nl = null;
- String[] nlVariants = null;
- if (override != null)
- try {
- // check for override
- nl = (String) override.get("$nl$"); //$NON-NLS-1$
- } catch (ClassCastException e) {
- // just in case
- }
- nlVariants = nl == null ? NL_JAR_VARIANTS : buildNLVariants(nl);
- if (nl != null && nl.length() == 0)
- return null;
-
- URL result = null;
- for (int i = 0; i < nlVariants.length; i++) {
- IPath filePath = new Path(nlVariants[i]).append(path);
- result = findInPlugin(b, filePath);
- if (result != null)
- return result;
- result = findInFragments(b, filePath);
- if (result != null)
- return result;
- }
- // If we get to this point, we haven't found it yet.
- // Look in the plugin and fragment root directories
- result = findInPlugin(b, path);
- if (result != null)
- return result;
- return findInFragments(b, path);
- }
-
- private static URL findInPlugin(Bundle b, IPath filePath) {
- return b.getEntry(filePath.toString());
- }
-
- private static URL findInFragments(Bundle b, IPath filePath) {
- Bundle[] fragments = CommonOSGiUtils.getDefault().getFragments(b);
- if (fragments == null)
- return null;
-
- URL fileURL = null;
- int i = 0;
- while (i < fragments.length && fileURL == null) {
- fileURL = fragments[i].getEntry(filePath.toString());
- i++;
- }
- return fileURL;
- }
-
- /**
- * See doc on @link Platform#openStream(Bundle, IPath, boolean) Platform#Platform#openStream(Bundle, IPath, boolean)
- */
- public static final InputStream openStream(Bundle bundle, IPath file, boolean localized) throws IOException {
- URL url = null;
- if (!localized) {
- url = findInPlugin(bundle, file);
- if (url == null)
- url = findInFragments(bundle, file);
- } else {
- url = FindSupport.find(bundle, file);
- }
- if (url != null)
- return url.openStream();
- throw new IOException("Cannot find " + file.toString()); //$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/IAdapterFactoryExt.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/IAdapterFactoryExt.java
deleted file mode 100644
index c4739803d..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/IAdapterFactoryExt.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.runtime;
-
-import org.eclipse.core.runtime.IAdapterFactory;
-
-/**
- * An internal interface that exposes portion of AdapterFactoryProxy functionality
- * without the need to import the class itself.
- */
-public interface IAdapterFactoryExt {
-
- /**
- * Loads the real adapter factory, but only if its associated plug-in is
- * already loaded. Returns the real factory if it was successfully loaded.
- * @param force if <code>true</code> the plugin providing the
- * factory will be loaded if necessary, otherwise no plugin activations
- * will occur.
- */
- public IAdapterFactory loadFactory(boolean force);
-
- public String[] getAdapterNames();
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/IRuntimeConstants.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/IRuntimeConstants.java
deleted file mode 100644
index a31af5b56..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/IRuntimeConstants.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.runtime;
-
-public interface IRuntimeConstants {
-
- /**
- * The unique identifier constant (value "<code>org.eclipse.core.runtime</code>")
- * of the Core Runtime (pseudo-) plug-in.
- */
- public static final String PI_RUNTIME = "org.eclipse.core.runtime"; //$NON-NLS-1$
-
- /**
- * Name of this bundle.
- */
- public static final String NAME = "org.eclipse.runtime.common"; //$NON-NLS-1$
-
- /**
- * Status code constant (value 2) indicating an error occurred while running a plug-in.
- */
- public static final int PLUGIN_ERROR = 2;
-
- /**
- * Status code constant (value 5) indicating the platform could not write
- * some of its metadata.
- */
- public static final int FAILED_WRITE_METADATA = 5;
-
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/ListenerList.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/ListenerList.java
deleted file mode 100644
index 3b0e49e03..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/ListenerList.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.runtime;
-
-/**
- * This class is going to be removed soon.
- * Please use org.eclipse.core.runtime.ListenerList
- *
- * @deprecated
- */
-// TODO remove this class
-public class ListenerList {
-
- /**
- * The empty array singleton instance.
- */
- private static final Object[] EmptyArray = new Object[0];
-
- /**
- * Mode constant (value 0) indicating that listeners should be considered
- * the <a href="#same">same</a> if they are equal.
- */
- public static final int EQUALITY = 0;
-
- /**
- * Mode constant (value 1) indicating that listeners should be considered
- * the <a href="#same">same</a> if they are identical.
- */
- public static final int IDENTITY = 1;
-
- /**
- * Indicates the comparison mode used to determine if two
- * listeners are equivalent
- */
- private final boolean identity;
-
- /**
- * The list of listeners. Initially empty but initialized
- * to an array of size capacity the first time a listener is added.
- * Maintains invariant: listeners != null
- */
- private volatile Object[] listeners = EmptyArray;
-
- /**
- * Creates a listener list in which listeners are compared using equality.
- */
- public ListenerList() {
- this(EQUALITY);
- }
-
- /**
- * Creates a listener list using the provided comparison mode.
- *
- * @param mode The mode used to determine if listeners are the <a href="#same">same</a>.
- */
- public ListenerList(int mode) {
- if (mode != EQUALITY && mode != IDENTITY)
- throw new IllegalArgumentException();
- this.identity = mode == IDENTITY;
- }
-
- /**
- * Adds a listener to this list. This method has no effect if the <a href="#same">same</a>
- * listener is already registered.
- *
- * @param listener the listener to add
- */
- public synchronized void add(Object listener) {
- // This method is synchronized to protect against multiple threads adding
- // or removing listeners concurrently. This does not block concurrent readers.
- if (listener == null)
- throw new IllegalArgumentException();
- // check for duplicates
- final int oldSize = listeners.length;
- for (int i = 0; i < oldSize; ++i) {
- Object listener2 = listeners[i];
- if (identity ? listener == listener2 : listener.equals(listener2))
- return;
- }
- // Thread safety: create new array to avoid affecting concurrent readers
- Object[] newListeners = new Object[oldSize + 1];
- System.arraycopy(listeners, 0, newListeners, 0, oldSize);
- newListeners[oldSize] = listener;
- //atomic assignment
- this.listeners = newListeners;
- }
-
- /**
- * Returns an array containing all the registered listeners.
- * The resulting array is unaffected by subsequent adds or removes.
- * If there are no listeners registered, the result is an empty array.
- * Use this method when notifying listeners, so that any modifications
- * to the listener list during the notification will have no effect on
- * the notification itself.
- * <p>
- * Note: Callers of this method <b>must not</b> modify the returned array.
- *
- * @return the list of registered listeners
- */
- public Object[] getListeners() {
- return listeners;
- }
-
- /**
- * Returns whether this listener list is empty.
- *
- * @return <code>true</code> if there are no registered listeners, and
- * <code>false</code> otherwise
- */
- public boolean isEmpty() {
- return listeners.length == 0;
- }
-
- /**
- * Removes a listener from this list. Has no effect if the <a href="#same">same</a>
- * listener was not already registered.
- *
- * @param listener the listener to remove
- */
- public synchronized void remove(Object listener) {
- // This method is synchronized to protect against multiple threads adding
- // or removing listeners concurrently. This does not block concurrent readers.
- if (listener == null)
- throw new IllegalArgumentException();
- int oldSize = listeners.length;
- for (int i = 0; i < oldSize; ++i) {
- Object listener2 = listeners[i];
- if (identity ? listener == listener2 : listener.equals(listener2)) {
- if (oldSize == 1) {
- listeners = EmptyArray;
- } else {
- // Thread safety: create new array to avoid affecting concurrent readers
- Object[] newListeners = new Object[oldSize - 1];
- System.arraycopy(listeners, 0, newListeners, 0, i);
- System.arraycopy(listeners, i + 1, newListeners, i, oldSize - i - 1);
- //atomic assignment to field
- this.listeners = newListeners;
- }
- return;
- }
- }
- }
-
- /**
- * Returns the number of registered listeners.
- *
- * @return the number of registered listeners
- */
- public int size() {
- return listeners.length;
- }
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/MessageResourceBundle.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/MessageResourceBundle.java
deleted file mode 100644
index 4f7564e30..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/MessageResourceBundle.java
+++ /dev/null
@@ -1,225 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.runtime;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.*;
-import org.eclipse.core.runtime.Status;
-
-/**
- * This class is used for NLS processing in plugins that can't depend on OSGi.
- *
- * Class responsible for loading message values from a property file
- * and assigning them directly to the fields of a messages class.
- *
- * Copied from org.eclipse.osgi.framework.internal.core.MessageResourceBundle as of August 30, 2005.
- * Debug code removed; logging is done via RuntimeLog.
- *
- * @since org.eclipse.equinox.common 1.0
- */
-public class MessageResourceBundle {
- /**
- * Class which sub-classes java.util.Properties and uses the #put method
- * to set field values rather than storing the values in the table.
- *
- * @since 3.1
- */
- private static class MessagesProperties extends Properties {
-
- private static final int MOD_EXPECTED = Modifier.PUBLIC | Modifier.STATIC;
- private static final int MOD_MASK = MOD_EXPECTED | Modifier.FINAL;
- private static final long serialVersionUID = 1L;
-
- private final String bundleName;
- private final Map fields;
- private final boolean isAccessible;
-
- public MessagesProperties(Map fieldMap, String bundleName, boolean isAccessible) {
- super();
- this.fields = fieldMap;
- this.bundleName = bundleName;
- this.isAccessible = isAccessible;
- }
-
- /* (non-Javadoc)
- * @see java.util.Hashtable#put(java.lang.Object, java.lang.Object)
- */
- public synchronized Object put(Object key, Object value) {
- Object fieldObject = fields.put(key, ASSIGNED);
- // if already assigned, there is nothing to do
- if (fieldObject == ASSIGNED)
- return null;
- if (fieldObject == null) {
- final String msg = "NLS unused message: " + key + " in: " + bundleName;//$NON-NLS-1$ //$NON-NLS-2$
- log(SEVERITY_WARNING, msg, null);
- return null;
- }
- final Field field = (Field) fieldObject;
- //can only set value of public static non-final fields
- if ((field.getModifiers() & MOD_MASK) != MOD_EXPECTED)
- return null;
- try {
- // Check to see if we are allowed to modify the field. If we aren't (for instance
- // if the class is not public) then change the accessible attribute of the field
- // before trying to set the value.
- if (!isAccessible)
- makeAccessible(field);
- // Set the value into the field. We should never get an exception here because
- // we know we have a public static non-final field. If we do get an exception, silently
- // log it and continue. This means that the field will (most likely) be un-initialized and
- // will fail later in the code and if so then we will see both the NPE and this error.
- field.set(null, value);
- } catch (Exception e) {
- log(SEVERITY_ERROR, "Exception setting field value.", e); //$NON-NLS-1$
- }
- return null;
- }
- }
-
- /**
- * This object is assigned to the value of a field map to indicate
- * that a translated message has already been assigned to that field.
- */
- static final Object ASSIGNED = new Object();
-
- private static final String EXTENSION = ".properties"; //$NON-NLS-1$
-
- private static String[] nlSuffixes;
-
- static int SEVERITY_ERROR = 0x04;
-
- static int SEVERITY_WARNING = 0x02;
-
- /*
- * Build an array of property files to search. The returned array contains
- * the property fields in order from most specific to most generic.
- * So, in the FR_fr locale, it will return file_fr_FR.properties, then
- * file_fr.properties, and finally file.properties.
- */
- private static String[] buildVariants(String root) {
- if (nlSuffixes == null) {
- //build list of suffixes for loading resource bundles
- String nl = Locale.getDefault().toString();
- ArrayList result = new ArrayList(4);
- int lastSeparator;
- while (true) {
- result.add('_' + nl + EXTENSION);
- lastSeparator = nl.lastIndexOf('_');
- if (lastSeparator == -1)
- break;
- nl = nl.substring(0, lastSeparator);
- }
- //add the empty suffix last (most general)
- result.add(EXTENSION);
- nlSuffixes = (String[]) result.toArray(new String[result.size()]);
- }
- root = root.replace('.', '/');
- String[] variants = new String[nlSuffixes.length];
- for (int i = 0; i < variants.length; i++)
- variants[i] = root + nlSuffixes[i];
- return variants;
- }
-
- /*
- * Change the accessibility of the specified field so we can set its value
- * to be the appropriate message string.
- */
- static void makeAccessible(final Field field) {
- if (System.getSecurityManager() == null) {
- field.setAccessible(true);
- } else {
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- field.setAccessible(true);
- return null;
- }
- });
- }
- }
-
- private static void computeMissingMessages(String bundleName, Class clazz, Map fieldMap, Field[] fieldArray, boolean isAccessible) {
- // iterate over the fields in the class to make sure that there aren't any empty ones
- final int MOD_EXPECTED = Modifier.PUBLIC | Modifier.STATIC;
- final int MOD_MASK = MOD_EXPECTED | Modifier.FINAL;
- final int numFields = fieldArray.length;
- for (int i = 0; i < numFields; i++) {
- Field field = fieldArray[i];
- if ((field.getModifiers() & MOD_MASK) != MOD_EXPECTED)
- continue;
- //if the field has a a value assigned, there is nothing to do
- if (fieldMap.get(field.getName()) == ASSIGNED)
- continue;
- try {
- // Set a value for this empty field. We should never get an exception here because
- // we know we have a public static non-final field. If we do get an exception, silently
- // log it and continue. This means that the field will (most likely) be un-initialized and
- // will fail later in the code and if so then we will see both the NPE and this error.
- String value = "NLS missing message: " + field.getName() + " in: " + bundleName; //$NON-NLS-1$ //$NON-NLS-2$
- log(SEVERITY_WARNING, value, null);
- if (!isAccessible)
- makeAccessible(field);
- field.set(null, value);
- } catch (Exception e) {
- log(SEVERITY_ERROR, "Error setting the missing message value for: " + field.getName(), e); //$NON-NLS-1$
- }
- }
- }
-
- /**
- * Load the given resource bundle using the specified class loader.
- */
- public static void load(final String bundleName, Class clazz) {
- final Field[] fieldArray = clazz.getDeclaredFields();
- ClassLoader loader = clazz.getClassLoader();
-
- boolean isAccessible = (clazz.getModifiers() & Modifier.PUBLIC) != 0;
-
- //build a map of field names to Field objects
- final int len = fieldArray.length;
- Map fields = new HashMap(len * 2);
- for (int i = 0; i < len; i++)
- fields.put(fieldArray[i].getName(), fieldArray[i]);
-
- // search the variants from most specific to most general, since
- // the MessagesProperties.put method will mark assigned fields
- // to prevent them from being assigned twice
- final String[] variants = buildVariants(bundleName);
- for (int i = 0; i < variants.length; i++) {
- final InputStream input = loader.getResourceAsStream(variants[i]);
- if (input == null)
- continue;
- try {
- final MessagesProperties properties = new MessagesProperties(fields, bundleName, isAccessible);
- properties.load(input);
- } catch (IOException e) {
- log(SEVERITY_ERROR, "Error loading " + variants[i], e); //$NON-NLS-1$
- } finally {
- if (input != null)
- try {
- input.close();
- } catch (IOException e) {
- // ignore
- }
- }
- }
- computeMissingMessages(bundleName, clazz, fields, fieldArray, isAccessible);
- }
-
- private static void log(int severity, String msg, Exception e) {
- RuntimeLog.log(new Status(severity, IRuntimeConstants.PI_RUNTIME, 0, msg, e));
- }
-
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/MetaDataKeeper.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/MetaDataKeeper.java
deleted file mode 100644
index 164f318a3..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/MetaDataKeeper.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.runtime;
-
-import org.eclipse.core.internal.runtime.DataArea;
-
-/**
- * The class contains a set of utilities working platform metadata area.
- * This class can only be used if OSGi plugin is available.
- *
- * Copied from InternalPlatform as of August 30, 2005.
- * @since org.eclipse.equinox.common 1.0
- */
-public class MetaDataKeeper {
-
- private static DataArea metaArea = null;
-
- /**
- * Returns the object which defines the location and organization
- * of the platform's meta area.
- */
- public static DataArea getMetaArea() {
- if (metaArea != null)
- return metaArea;
-
- metaArea = new DataArea();
- return metaArea;
- }
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/ReferenceHashSet.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/ReferenceHashSet.java
deleted file mode 100644
index eab95b961..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/ReferenceHashSet.java
+++ /dev/null
@@ -1,323 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.runtime;
-
-import java.lang.ref.*;
-
-/**
- * A hashset whose values can be garbage collected.
- * This API is EXPERIMENTAL and provided as early access.
- * @since 3.1
- */
-public class ReferenceHashSet {
-
- private interface HashedReference {
- int hashCode();
-
- Object get();
- }
-
- private class HashableWeakReference extends WeakReference implements HashedReference {
- public int hashCode;
-
- public HashableWeakReference(Object referent, ReferenceQueue queue) {
- super(referent, queue);
- this.hashCode = referent.hashCode();
- }
-
- public boolean equals(Object obj) {
- if (!(obj instanceof HashableWeakReference))
- return false;
- Object referent = get();
- Object other = ((HashableWeakReference) obj).get();
- if (referent == null)
- return other == null;
- return referent.equals(other);
- }
-
- public int hashCode() {
- return this.hashCode;
- }
-
- public String toString() {
- Object referent = get();
- if (referent == null)
- return "[hashCode=" + this.hashCode + "] <referent was garbage collected>"; //$NON-NLS-1$ //$NON-NLS-2$
- return "[hashCode=" + this.hashCode + "] " + referent.toString(); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- private class HashableSoftReference extends SoftReference implements HashedReference {
- public int hashCode;
-
- public HashableSoftReference(Object referent, ReferenceQueue queue) {
- super(referent, queue);
- this.hashCode = referent.hashCode();
- }
-
- public boolean equals(Object obj) {
- if (!(obj instanceof HashableWeakReference))
- return false;
- Object referent = get();
- Object other = ((HashableWeakReference) obj).get();
- if (referent == null)
- return other == null;
- return referent.equals(other);
- }
-
- public int hashCode() {
- return this.hashCode;
- }
-
- public String toString() {
- Object referent = get();
- if (referent == null)
- return "[hashCode=" + this.hashCode + "] <referent was garbage collected>"; //$NON-NLS-1$ //$NON-NLS-2$
- return "[hashCode=" + this.hashCode + "] " + referent.toString(); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- private class StrongReference implements HashedReference {
- private Object referent;
-
- public StrongReference(Object referent, ReferenceQueue queue) {
- this.referent = referent;
- }
-
- public int hashCode() {
- return referent.hashCode();
- }
-
- public Object get() {
- return referent;
- }
-
- public boolean equals(Object obj) {
- return referent.equals(obj);
- }
- }
-
- HashedReference[] values;
-
- public int elementSize; // number of elements in the table
-
- int threshold;
-
- ReferenceQueue referenceQueue = new ReferenceQueue();
-
- public ReferenceHashSet() {
- this(5);
- }
-
- public ReferenceHashSet(int size) {
- this.elementSize = 0;
- this.threshold = size; // size represents the expected
- // number of elements
- int extraRoom = (int) (size * 1.75f);
- if (this.threshold == extraRoom)
- extraRoom++;
- this.values = new HashedReference[extraRoom];
- }
-
- /**
- * Constant indicating that hard references should be used.
- */
- final public static int HARD = 0;
-
- /**
- * Constant indiciating that soft references should be used.
- */
- final public static int SOFT = 1;
-
- /**
- * Constant indicating that weak references should be used.
- */
- final public static int WEAK = 2;
-
- private HashedReference toReference(int type, Object referent) {
- switch (type) {
- case HARD :
- return new StrongReference(referent, referenceQueue);
- case SOFT :
- return new HashableSoftReference(referent, referenceQueue);
- case WEAK :
- return new HashableWeakReference(referent, referenceQueue);
- default :
- throw new Error();
- }
- }
-
- /*
- * Adds the given object to this set. If an object that is equals to the
- * given object already exists, do nothing. Returns the existing object or
- * the new object if not found.
- */
- public Object add(Object obj, int referenceType) {
- cleanupGarbageCollectedValues();
- int index = (obj.hashCode() & 0x7FFFFFFF) % this.values.length;
- HashedReference currentValue;
- while ((currentValue = this.values[index]) != null) {
- Object referent;
- if (obj.equals(referent = currentValue.get())) {
- return referent;
- }
- index = (index + 1) % this.values.length;
- }
- this.values[index] = toReference(referenceType, obj);
-
- // assumes the threshold is never equal to the size of the table
- if (++this.elementSize > this.threshold)
- rehash();
-
- return obj;
- }
-
- private void addValue(HashedReference value) {
- Object obj = value.get();
- if (obj == null)
- return;
- int valuesLength = this.values.length;
- int index = (value.hashCode() & 0x7FFFFFFF) % valuesLength;
- HashedReference currentValue;
- while ((currentValue = this.values[index]) != null) {
- if (obj.equals(currentValue.get())) {
- return;
- }
- index = (index + 1) % valuesLength;
- }
- this.values[index] = value;
-
- // assumes the threshold is never equal to the size of the table
- if (++this.elementSize > this.threshold)
- rehash();
- }
-
- private void cleanupGarbageCollectedValues() {
- HashedReference toBeRemoved;
- while ((toBeRemoved = (HashedReference) this.referenceQueue.poll()) != null) {
- int hashCode = toBeRemoved.hashCode();
- int valuesLength = this.values.length;
- int index = (hashCode & 0x7FFFFFFF) % valuesLength;
- HashedReference currentValue;
- while ((currentValue = this.values[index]) != null) {
- if (currentValue == toBeRemoved) {
- // replace the value at index with the last value with the
- // same hash
- int sameHash = index;
- int current;
- while ((currentValue = this.values[current = (sameHash + 1) % valuesLength]) != null && currentValue.hashCode() == hashCode)
- sameHash = current;
- this.values[index] = this.values[sameHash];
- this.values[sameHash] = null;
- this.elementSize--;
- break;
- }
- index = (index + 1) % valuesLength;
- }
- }
- }
-
- public boolean contains(Object obj) {
- return get(obj) != null;
- }
-
- /*
- * Return the object that is in this set and that is equals to the given
- * object. Return null if not found.
- */
- public Object get(Object obj) {
- cleanupGarbageCollectedValues();
- int valuesLength = this.values.length;
- int index = (obj.hashCode() & 0x7FFFFFFF) % valuesLength;
- HashedReference currentValue;
- while ((currentValue = this.values[index]) != null) {
- Object referent;
- if (obj.equals(referent = currentValue.get())) {
- return referent;
- }
- index = (index + 1) % valuesLength;
- }
- return null;
- }
-
- private void rehash() {
- ReferenceHashSet newHashSet = new ReferenceHashSet(this.elementSize * 2); // double the number of expected elements
- newHashSet.referenceQueue = this.referenceQueue;
- HashedReference currentValue;
- for (int i = 0, length = this.values.length; i < length; i++)
- if ((currentValue = this.values[i]) != null)
- newHashSet.addValue(currentValue);
-
- this.values = newHashSet.values;
- this.threshold = newHashSet.threshold;
- this.elementSize = newHashSet.elementSize;
- }
-
- /*
- * Removes the object that is in this set and that is equals to the given
- * object. Return the object that was in the set, or null if not found.
- */
- public Object remove(Object obj) {
- cleanupGarbageCollectedValues();
- int valuesLength = this.values.length;
- int index = (obj.hashCode() & 0x7FFFFFFF) % valuesLength;
- HashedReference currentValue;
- while ((currentValue = this.values[index]) != null) {
- Object referent;
- if (obj.equals(referent = currentValue.get())) {
- this.elementSize--;
- this.values[index] = null;
- rehash();
- return referent;
- }
- index = (index + 1) % valuesLength;
- }
- return null;
- }
-
- public int size() {
- return this.elementSize;
- }
-
- public String toString() {
- StringBuffer buffer = new StringBuffer("{"); //$NON-NLS-1$
- for (int i = 0, length = this.values.length; i < length; i++) {
- HashedReference value = this.values[i];
- if (value != null) {
- Object ref = value.get();
- if (ref != null) {
- buffer.append(ref.toString());
- buffer.append(", "); //$NON-NLS-1$
- }
- }
- }
- buffer.append("}"); //$NON-NLS-1$
- return buffer.toString();
- }
-
- public Object[] toArray() {
- cleanupGarbageCollectedValues();
- Object[] result = new Object[elementSize];
- int resultSize = 0;
- for (int i = 0; i < values.length; i++) {
- if (values[i] == null)
- continue;
- Object tmp = values[i].get();
- if (tmp != null)
- result[resultSize++] = tmp;
- }
- if (result.length == resultSize)
- return result;
- Object[] finalResult = new Object[resultSize];
- System.arraycopy(result, 0, finalResult, 0, resultSize);
- return finalResult;
- }
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/ResourceTranslator.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/ResourceTranslator.java
deleted file mode 100644
index f12aebcf2..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/ResourceTranslator.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.runtime;
-
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.*;
-import org.eclipse.osgi.util.ManifestElement;
-import org.osgi.framework.*;
-
-/**
- * This class can only be used if OSGi plugin is available.
- */
-public class ResourceTranslator {
- private static final String KEY_PREFIX = "%"; //$NON-NLS-1$
- private static final String KEY_DOUBLE_PREFIX = "%%"; //$NON-NLS-1$
-
- public static String getResourceString(Bundle bundle, String value) {
- return getResourceString(bundle, value, null);
- }
-
- public static String getResourceString(Bundle bundle, String value, ResourceBundle resourceBundle) {
- String s = value.trim();
- if (!s.startsWith(KEY_PREFIX, 0))
- return s;
- if (s.startsWith(KEY_DOUBLE_PREFIX, 0))
- return s.substring(1);
-
- int ix = s.indexOf(' ');
- String key = ix == -1 ? s : s.substring(0, ix);
- String dflt = ix == -1 ? s : s.substring(ix + 1);
-
- if (resourceBundle == null && bundle != null) {
- try {
- resourceBundle = getResourceBundle(bundle);
- } catch (MissingResourceException e) {
- // just return the default (dflt)
- }
- }
-
- if (resourceBundle == null)
- return dflt;
-
- try {
- return resourceBundle.getString(key.substring(1));
- } catch (MissingResourceException e) {
- //this will avoid requiring a bundle access on the next lookup
- return dflt;
- }
- }
-
- public static ResourceBundle getResourceBundle(Bundle bundle) throws MissingResourceException {
- if (hasRuntime21(bundle))
- return ResourceBundle.getBundle("plugin", Locale.getDefault(), createTempClassloader(bundle)); //$NON-NLS-1$
- return CommonOSGiUtils.getDefault().getLocalization(bundle, null);
- }
-
- private static boolean hasRuntime21(Bundle b) {
- try {
- ManifestElement[] prereqs = ManifestElement.parseHeader(Constants.REQUIRE_BUNDLE, (String) b.getHeaders("").get(Constants.REQUIRE_BUNDLE)); //$NON-NLS-1$
- if (prereqs == null)
- return false;
- for (int i = 0; i < prereqs.length; i++) {
- if ("2.1".equals(prereqs[i].getAttribute(Constants.BUNDLE_VERSION_ATTRIBUTE)) && "org.eclipse.core.runtime".equals(prereqs[i].getValue())) { //$NON-NLS-1$//$NON-NLS-2$
- return true;
- }
- }
- } catch (BundleException e) {
- return false;
- }
- return false;
- }
-
- private static ClassLoader createTempClassloader(Bundle b) {
- ArrayList classpath = new ArrayList();
- addClasspathEntries(b, classpath);
- addBundleRoot(b, classpath);
- addDevEntries(b, classpath);
- addFragments(b, classpath);
- URL[] urls = new URL[classpath.size()];
- return new URLClassLoader((URL[]) classpath.toArray(urls));
- }
-
- private static void addFragments(Bundle host, ArrayList classpath) {
- Bundle[] fragments = CommonOSGiUtils.getDefault().getFragments(host);
- if (fragments == null)
- return;
-
- for (int i = 0; i < fragments.length; i++) {
- addClasspathEntries(fragments[i], classpath);
- addDevEntries(fragments[i], classpath);
- }
- }
-
- private static void addClasspathEntries(Bundle b, ArrayList classpath) {
- ManifestElement[] classpathElements;
- try {
- classpathElements = ManifestElement.parseHeader(Constants.BUNDLE_CLASSPATH, (String) b.getHeaders("").get(Constants.BUNDLE_CLASSPATH)); //$NON-NLS-1$
- if (classpathElements == null)
- return;
- for (int i = 0; i < classpathElements.length; i++) {
- URL classpathEntry = b.getEntry(classpathElements[i].getValue());
- if (classpathEntry != null)
- classpath.add(classpathEntry);
- }
- } catch (BundleException e) {
- //ignore
- }
- }
-
- private static void addBundleRoot(Bundle b, ArrayList classpath) {
- classpath.add(b.getEntry("/")); //$NON-NLS-1$
- }
-
- private static void addDevEntries(Bundle b, ArrayList classpath) {
- if (!DevClassPathHelper.inDevelopmentMode())
- return;
-
- String[] binaryPaths = DevClassPathHelper.getDevClassPath(b.getSymbolicName());
- for (int i = 0; i < binaryPaths.length; i++) {
- URL classpathEntry = b.getEntry(binaryPaths[i]);
- if (classpathEntry != null)
- classpath.add(classpathEntry);
- }
- }
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/RuntimeLog.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/RuntimeLog.java
deleted file mode 100644
index d0bd2a3f7..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/RuntimeLog.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- * Julian Chen - fix for bug #92572, jclRM
- *******************************************************************************/
-package org.eclipse.core.internal.runtime;
-
-import java.util.ArrayList;
-import org.eclipse.core.runtime.*;
-
-/**
- * NOT API!!! This log infrastructure was split from the InternalPlatform.
- *
- * @since org.eclipse.equinox.common 1.0
- */
-// XXX this must be removed and replaced with something more reasonable
-public final class RuntimeLog {
-
- private static ArrayList logListeners = new ArrayList(5);
-
- /**
- * @see Platform#addLogListener(ILogListener)
- */
- public static void addLogListener(ILogListener listener) {
- synchronized (logListeners) {
- // replace if already exists (Set behaviour but we use an array
- // since we want to retain order)
- logListeners.remove(listener);
- logListeners.add(listener);
- }
- }
-
- /**
- * @see Platform#removeLogListener(ILogListener)
- */
- public static void removeLogListener(ILogListener listener) {
- synchronized (logListeners) {
- logListeners.remove(listener);
- }
- }
-
- /**
- * Checks if the given listener is present
- */
- public static boolean contains(ILogListener listener) {
- synchronized (logListeners) {
- return logListeners.contains(listener);
- }
- }
-
- /**
- * Notifies all listeners of the platform log.
- */
- public static void log(final IStatus status) {
- // create array to avoid concurrent access
- ILogListener[] listeners;
- synchronized (logListeners) {
- listeners = (ILogListener[]) logListeners.toArray(new ILogListener[logListeners.size()]);
- }
- for (int i = 0; i < listeners.length; i++) {
- try {
- listeners[i].logging(status, IRuntimeConstants.PI_RUNTIME);
- } catch (Exception e) {
- handleException(e);
- } catch (LinkageError e) {
- handleException(e);
- }
- }
- }
-
- private static void handleException(Throwable e) {
- if (!(e instanceof OperationCanceledException)) {
- // Got a error while logging. Don't try to log again, just put it into stderr
- e.printStackTrace();
- }
- }
-
- /**
- * Helps determine if any listeners are registered with the logging mechanism.
- * @return true if no listeners are registered
- */
- public static boolean isEmpty() {
- synchronized (logListeners) {
- return (logListeners.size() == 0);
- }
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/commonMessages.properties b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/commonMessages.properties
deleted file mode 100644
index 61c1a8100..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/commonMessages.properties
+++ /dev/null
@@ -1,42 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2005 IBM Corporation 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:
-# IBM Corporation - initial API and implementation
-###############################################################################
-### Common runtime plugin messages
-
-ok = OK
-
-### metadata
-meta_couldNotCreate = Error trying to create the platform metadata area: {0}.
-meta_instanceDataUnspecified = The instance data location has not been specified yet.
-meta_noDataModeSpecified = No instance data can be specified.
-meta_notDir = Specified platform location \"{0}\" is not a directory.
-meta_readonly = The platform metadata area could not be written: {0}. By default the platform writes its content\nunder the current working directory when the platform is launched. Use the -data parameter to\nspecify a different content area for the platform.
-meta_pluginProblems = Problems occurred when invoking code from plug-in: \"{0}\".
-
-### parsing/resolve
-parse_doubleSeparatorVersion=Plug-in version identifier, \"{0}\", must not contain two consecutive separator characters.
-parse_emptyPluginVersion=A plug-in version identifier must be non-empty.
-parse_fourElementPluginVersion=Plug-in version identifier, \"{0}\", can contain a maximum of four components.
-parse_numericMajorComponent=The major (1st) component of plug-in version identifier, \"{0}\", must be numeric.
-parse_numericMinorComponent=The minor (2nd) component of plug-in version identifier, \"{0}\", must be numeric.
-parse_numericServiceComponent=The service (3rd) component of plug-in version identifier, \"{0}\", must be numeric.
-parse_oneElementPluginVersion=Plug-in version identifier, \"{0}\", must contain at least one component.
-parse_postiveMajor=Plug-in version identifier, \"{0}\", must have a positive major (1st) component.
-parse_postiveMinor=Plug-in version identifier, \"{0}\", must have a positive minor (2nd) component.
-parse_postiveService=Plug-in version identifier, \"{0}\", must have a positive service (3rd) component.
-parse_separatorEndVersion=Plug-in version identifier, \"{0}\", must not end with a separator character.
-parse_separatorStartVersion=Plug-in version identifier, \"{0}\", must not start with a separator character.
-
-#FileMananger messages
-fileManager_cannotLock = Unable to create lock manager.
-fileManager_couldNotSave = Could not save file table.
-fileManager_updateFailed = File update failed on one or more files.
-fileManager_illegalInReadOnlyMode = Cannot perform operation while in read-only mode.
-fileManager_notOpen = Manager is not opened.
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/package.html b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/package.html
deleted file mode 100644
index 0898ea239..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/package.html
+++ /dev/null
@@ -1,24 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <title>Package-level Javadoc</title>
-</head>
-<body>
-Provides core support for the runtime.
-<h2>
-Package Specification</h2>
-This package contains some classes that require OSGi presence. If OSGi plugin is not present in
-the platform, class loader errors will be raised if those classes get activated. The classes are:
-<UL>
-<LI>FindSupport
-<LI>DataArea
-<LI>MetaDataKeeper
-<LI>ResourceTranslator
-<LI>CommonRuntimeBundle
-<LI>CommonOSGiUtils
-</UL>
-
-
-</body>
-</html>
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Assert.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Assert.java
deleted file mode 100644
index 1ecef9686..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Assert.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-/**
- * <code>Assert</code> is useful for for embedding runtime sanity checks
- * in code.
- * The predicate methods all test a condition and throw some
- * type of unchecked exception if the condition does not hold.
- * <p>
- * Assertion failure exceptions, like most runtime exceptions, are
- * thrown when something is misbehaving. Assertion failures are invariably
- * unspecified behavior; consequently, clients should never rely on
- * these being thrown (and certainly should not being catching them
- * specifically).
- * </p>
- */
-public final class Assert {
- /* This class is not intended to be instantiated. */
- private Assert() {
- // not allowed
- }
-
- /** Asserts that an argument is legal. If the given boolean is
- * not <code>true</code>, an <code>IllegalArgumentException</code>
- * is thrown.
- *
- * @param expression the outcode of the check
- * @return <code>true</code> if the check passes (does not return
- * if the check fails)
- * @exception IllegalArgumentException if the legality test failed
- */
- public static boolean isLegal(boolean expression) {
- return isLegal(expression, ""); //$NON-NLS-1$
- }
-
- /** Asserts that an argument is legal. If the given boolean is
- * not <code>true</code>, an <code>IllegalArgumentException</code>
- * is thrown.
- * The given message is included in that exception, to aid debugging.
- *
- * @param expression the outcode of the check
- * @param message the message to include in the exception
- * @return <code>true</code> if the check passes (does not return
- * if the check fails)
- * @exception IllegalArgumentException if the legality test failed
- */
- public static boolean isLegal(boolean expression, String message) {
- if (!expression)
- throw new IllegalArgumentException(message);
- return expression;
- }
-
- /** Asserts that the given object is not <code>null</code>. If this
- * is not the case, some kind of unchecked exception is thrown.
- *
- * @param object the value to test
- * @exception IllegalArgumentException if the object is <code>null</code>
- */
- public static void isNotNull(Object object) {
- isNotNull(object, ""); //$NON-NLS-1$
- }
-
- /** Asserts that the given object is not <code>null</code>. If this
- * is not the case, some kind of unchecked exception is thrown.
- * The given message is included in that exception, to aid debugging.
- *
- * @param object the value to test
- * @param message the message to include in the exception
- * @exception IllegalArgumentException if the object is <code>null</code>
- */
- public static void isNotNull(Object object, String message) {
- if (object == null)
- throw new AssertionFailedException("null argument:" + message); //$NON-NLS-1$
- }
-
- /** Asserts that the given boolean is <code>true</code>. If this
- * is not the case, some kind of unchecked exception is thrown.
- *
- * @param expression the outcode of the check
- * @return <code>true</code> if the check passes (does not return
- * if the check fails)
- */
- public static boolean isTrue(boolean expression) {
- return isTrue(expression, ""); //$NON-NLS-1$
- }
-
- /** Asserts that the given boolean is <code>true</code>. If this
- * is not the case, some kind of unchecked exception is thrown.
- * The given message is included in that exception, to aid debugging.
- *
- * @param expression the outcode of the check
- * @param message the message to include in the exception
- * @return <code>true</code> if the check passes (does not return
- * if the check fails)
- */
- public static boolean isTrue(boolean expression, String message) {
- if (!expression)
- throw new AssertionFailedException("assertion failed: " + message); //$NON-NLS-1$
- return expression;
- }
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/AssertionFailedException.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/AssertionFailedException.java
deleted file mode 100644
index 8f3cbcb92..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/AssertionFailedException.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-/**
- * <code>AssertionFailedException</code> is a runtime exception thrown
- * by some of the methods in <code>Assert</code>.
- */
-public class AssertionFailedException extends RuntimeException {
- /**
- * All serializable objects should have a stable serialVersionUID
- */
- private static final long serialVersionUID = 1L;
-
- /** Constructs a new exception with the given message.
- */
- public AssertionFailedException(String detail) {
- super(detail);
- }
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/BundleFinder.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/BundleFinder.java
deleted file mode 100644
index daf4c50c0..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/BundleFinder.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.Map;
-import org.osgi.framework.Bundle;
-
-/**
- * This class contains collection of helper methods aimed at finding files in bundles.
- * This class can only be used if OSGi plugin is available.
- * <p>
- * The class is not intended to be subclassed or instantiated by clients.
- * </p>
- * @since 3.2
- * @deprecated clients should use {@link FileLocator} instead. This class will
- * be removed before the 3.2 release (in the next week!).
- */
-public final class BundleFinder {
-
- /**
- * Returns a URL for the given path in the given bundle. Returns <code>null</code> if the URL
- * could not be computed or created.
- *
- * @param bundle the bundle in which to search
- * @param path path relative to plug-in installation location
- * @return a URL for the given path or <code>null</code>. The actual form
- * of the returned URL is not specified.
- * @see #find(Bundle, IPath, Map)
- * @deprecated use {@link FileLocator#find(Bundle, IPath, Map)}
- */
- public static URL find(Bundle bundle, IPath path) {
- return FileLocator.find(bundle, path, null);
- }
-
- /**
- * Returns a URL for the given path in the given bundle. Returns <code>null</code> if the URL
- * could not be computed or created.
- * <p>
- * find looks for this path in given bundle and any attached fragments.
- * <code>null</code> is returned if no such entry is found. Note that
- * there is no specific order to the fragments.
- * </p><p>
- * The following arguments may also be used
- * <pre>
- * $nl$ - for language specific information
- * $os$ - for operating system specific information
- * $ws$ - for windowing system specific information
- * </pre>
- * </p><p>
- * A path of $nl$/about.properties in an environment with a default
- * locale of en_CA will return a URL corresponding to the first place
- * about.properties is found according to the following order:
- * <pre>
- * plugin root/nl/en/CA/about.properties
- * fragment1 root/nl/en/CA/about.properties
- * fragment2 root/nl/en/CA/about.properties
- * ...
- * plugin root/nl/en/about.properties
- * fragment1 root/nl/en/about.properties
- * fragment2 root/nl/en/about.properties
- * ...
- * plugin root/about.properties
- * fragment1 root/about.properties
- * fragment2 root/about.properties
- * ...
- * </pre>
- * </p><p>
- * The current environment variable values can be overridden using
- * the override map argument or <code>null</code> can be specified
- * if this is not desired.
- * </p>
- *
- * @param bundle the bundle in which to search
- * @param path file path relative to plug-in installation location
- * @param override map of override substitution arguments to be used for
- * any $arg$ path elements. The map keys correspond to the substitution
- * arguments (eg. "$nl$" or "$os$"). The resulting
- * values must be of type java.lang.String. If the map is <code>null</code>,
- * or does not contain the required substitution argument, the default
- * is used.
- * @return a URL for the given path or <code>null</code>. The actual form
- * of the returned URL is not specified.
- * @deprecated use {@link FileLocator#find(Bundle, IPath, Map)}
- */
- public static URL find(Bundle bundle, IPath path, Map override) {
- return FileLocator.find(bundle, path, override);
- }
-
- /**
- * Returns an input stream for the specified file. The file path
- * must be specified relative to this plug-in's installation location.
- * Optionally, the platform searches for the correct localized version
- * of the specified file using the users current locale, and Java
- * naming convention for localized resource files (locale suffix appended
- * to the specified file extension).
- * <p>
- * The caller must close the returned stream when done.
- * </p>
- *
- * @param bundle the bundle in which to search
- * @param file path relative to plug-in installation location
- * @param localized <code>true</code> for the localized version
- * of the file, and <code>false</code> for the file exactly
- * as specified
- * @return an input stream
- * @exception IOException if the given path cannot be found in this plug-in
- * @deprecated use {@link FileLocator#openStream(Bundle, IPath, boolean)}
- */
- public static InputStream openStream(Bundle bundle, IPath file, boolean localized) throws IOException {
- return FileLocator.openStream(bundle, file, localized);
- }
-
- /**
- * Returns an input stream for the specified file. The file path
- * must be specified relative this the plug-in's installation location.
- *
- * @param bundle the bundle in which to search
- * @param file path relative to plug-in installation location
- * @return an input stream
- * @exception IOException if the given path cannot be found in this plug-in
- *
- * @see #openStream(Bundle,IPath,boolean)
- * @deprecated use {@link FileLocator#openStream(Bundle, IPath, boolean)}
- */
- public static final InputStream openStream(Bundle bundle, IPath file) throws IOException {
- return FileLocator.openStream(bundle, file, false);
- }
-
- /**
- * Converts a URL that uses a user-defined protocol into a URL that uses the file
- * protocol. The contents of the URL may be extracted into a cache on the file-system
- * in order to get a file URL.
- * <p>
- * If the protocol for the given URL is not recognized by this converter, the original
- * URL is returned as-is.
- * </p>
- * @param url the original URL
- * @return the converted file URL or the original URL passed in if it is
- * not recognized by this converter
- * @throws IOException if an error occurs during the conversion
- * @deprecated use {@link FileLocator#toFileURL(URL)}
- */
- public static URL toFileURL(URL url) throws IOException {
- return FileLocator.toFileURL(url);
- }
-
- /**
- * Converts a URL that uses a client-defined protocol into a URL that uses a
- * protocol which is native to the Java class library (file, jar, http, etc).
- * <p>
- * Note however that users of this API should not assume too much about the
- * results of this method. While it may consistently return a file: URL in certain
- * installation configurations, others may result in jar: or http: URLs.
- * </p>
- * <p>
- * If the protocol is not reconized by this converter, then the original URL is
- * returned as-is.
- * </p>
- * @param url the original URL
- * @return the resolved URL or the original if the protocol is unknown to this converter
- * @exception IOException if unable to resolve URL
- * @throws IOException if an error occurs during the resolution
- * @deprecated use {@link FileLocator#resolve(URL)}
- */
- public static URL resolve(URL url) throws IOException {
- return FileLocator.resolve(url);
- }
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/CoreException.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/CoreException.java
deleted file mode 100644
index 9ac5b61d7..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/CoreException.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-import java.io.PrintStream;
-import java.io.PrintWriter;
-
-/**
- * A checked exception representing a failure.
- * <p>
- * Core exceptions contain a status object describing the
- * cause of the exception.
- * </p>
- *
- * @see IStatus
- */
-public class CoreException extends Exception {
-
- /**
- * All serializable objects should have a stable serialVersionUID
- */
- private static final long serialVersionUID = 1L;
-
- /** Status object. */
- private IStatus status;
-
- /**
- * Creates a new exception with the given status object. The message
- * of the given status is used as the exception message.
- *
- * @param status the status object to be associated with this exception
- */
- public CoreException(IStatus status) {
- super(status.getMessage());
- this.status = status;
- }
-
- /**
- * Returns the status object for this exception.
- *
- * @return a status object
- */
- public final IStatus getStatus() {
- return status;
- }
-
- /**
- * Prints a stack trace out for the exception, and
- * any nested exception that it may have embedded in
- * its Status object.
- */
- public void printStackTrace() {
- printStackTrace(System.err);
- }
-
- /**
- * Prints a stack trace out for the exception, and
- * any nested exception that it may have embedded in
- * its Status object.
- *
- * @param output the stream to write to
- */
- public void printStackTrace(PrintStream output) {
- synchronized (output) {
- if (status.getException() != null) {
- output.print(getClass().getName() + "[" + status.getCode() + "]: "); //$NON-NLS-1$ //$NON-NLS-2$
- status.getException().printStackTrace(output);
- } else
- super.printStackTrace(output);
- }
- }
-
- /**
- * Prints a stack trace out for the exception, and
- * any nested exception that it may have embedded in
- * its Status object.
- *
- * @param output the stream to write to
- */
- public void printStackTrace(PrintWriter output) {
- synchronized (output) {
- if (status.getException() != null) {
- output.print(getClass().getName() + "[" + status.getCode() + "]: "); //$NON-NLS-1$ //$NON-NLS-2$
- status.getException().printStackTrace(output);
- } else
- super.printStackTrace(output);
- }
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/FileLocator.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/FileLocator.java
deleted file mode 100644
index de658405b..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/FileLocator.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.Map;
-import org.eclipse.core.internal.runtime.*;
-import org.eclipse.osgi.service.urlconversion.URLConverter;
-import org.osgi.framework.Bundle;
-
-/**
- * This class contains collection of helper methods aimed at finding files in bundles.
- * This class can only be used if OSGi plugin is available.
- * <p>
- * The class is not intended to be subclassed or instantiated by clients.
- * </p>
- * @since 3.2
- */
-public final class FileLocator {
-
- /**
- * Returns a URL for the given path in the given bundle. Returns <code>null</code> if the URL
- * could not be computed or created.
- * <p>
- * find looks for this path in given bundle and any attached fragments.
- * <code>null</code> is returned if no such entry is found. Note that
- * there is no specific order to the fragments.
- * </p><p>
- * The following arguments may also be used
- * <pre>
- * $nl$ - for language specific information
- * $os$ - for operating system specific information
- * $ws$ - for windowing system specific information
- * </pre>
- * </p><p>
- * A path of $nl$/about.properties in an environment with a default
- * locale of en_CA will return a URL corresponding to the first place
- * about.properties is found according to the following order:
- * <pre>
- * plugin root/nl/en/CA/about.properties
- * fragment1 root/nl/en/CA/about.properties
- * fragment2 root/nl/en/CA/about.properties
- * ...
- * plugin root/nl/en/about.properties
- * fragment1 root/nl/en/about.properties
- * fragment2 root/nl/en/about.properties
- * ...
- * plugin root/about.properties
- * fragment1 root/about.properties
- * fragment2 root/about.properties
- * ...
- * </pre>
- * </p><p>
- * The current environment variable values can be overridden using
- * the override map argument or <code>null</code> can be specified
- * if this is not desired.
- * </p>
- *
- * @param bundle the bundle in which to search
- * @param path file path relative to plug-in installation location
- * @param override map of override substitution arguments to be used for
- * any $arg$ path elements. The map keys correspond to the substitution
- * arguments (eg. "$nl$" or "$os$"). The resulting
- * values must be of type java.lang.String. If the map is <code>null</code>,
- * or does not contain the required substitution argument, the default
- * is used.
- * @return a URL for the given path or <code>null</code>. The actual form
- * of the returned URL is not specified.
- */
- public static URL find(Bundle bundle, IPath path, Map override) {
- return FindSupport.find(bundle, path, override);
- }
-
- /**
- * Returns an input stream for the specified file. The file path
- * must be specified relative to this plug-in's installation location.
- * Optionally, the platform searches for the correct localized version
- * of the specified file using the users current locale, and Java
- * naming convention for localized resource files (locale suffix appended
- * to the specified file extension).
- * <p>
- * The caller must close the returned stream when done.
- * </p>
- *
- * @param bundle the bundle in which to search
- * @param file path relative to plug-in installation location
- * @param localized <code>true</code> for the localized version
- * of the file, and <code>false</code> for the file exactly
- * as specified
- * @return an input stream
- * @exception IOException if the given path cannot be found in this plug-in
- */
- public static InputStream openStream(Bundle bundle, IPath file, boolean localized) throws IOException {
- return FindSupport.openStream(bundle, file, localized);
- }
-
- /**
- * Converts a URL that uses a user-defined protocol into a URL that uses the file
- * protocol. The contents of the URL may be extracted into a cache on the file-system
- * in order to get a file URL.
- * <p>
- * If the protocol for the given URL is not recognized by this converter, the original
- * URL is returned as-is.
- * </p>
- * @param url the original URL
- * @return the converted file URL or the original URL passed in if it is
- * not recognized by this converter
- * @throws IOException if an error occurs during the conversion
- */
- public static URL toFileURL(URL url) throws IOException {
- URLConverter converter = Activator.getURLConverter(url);
- return converter == null ? url : converter.toFileURL(url);
- }
-
- /**
- * Converts a URL that uses a client-defined protocol into a URL that uses a
- * protocol which is native to the Java class library (file, jar, http, etc).
- * <p>
- * Note however that users of this API should not assume too much about the
- * results of this method. While it may consistently return a file: URL in certain
- * installation configurations, others may result in jar: or http: URLs.
- * </p>
- * <p>
- * If the protocol is not reconized by this converter, then the original URL is
- * returned as-is.
- * </p>
- * @param url the original URL
- * @return the resolved URL or the original if the protocol is unknown to this converter
- * @exception IOException if unable to resolve URL
- * @throws IOException if an error occurs during the resolution
- */
- public static URL resolve(URL url) throws IOException {
- URLConverter converter = Activator.getURLConverter(url);
- return converter == null ? url : converter.resolve(url);
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IAdaptable.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IAdaptable.java
deleted file mode 100644
index a935fadfa..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IAdaptable.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-/**
- * An interface for an adaptable object.
- * <p>
- * Adaptable objects can be dynamically extended to provide different
- * interfaces (or "adapters"). Adapters are created by adapter
- * factories, which are in turn managed by type by adapter managers.
- * </p>
- * For example,
- * <pre>
- * IAdaptable a = [some adaptable];
- * IFoo x = (IFoo)a.getAdapter(IFoo.class);
- * if (x != null)
- * [do IFoo things with x]
- * </pre>
- * <p>
- * Clients may implement this interface, or obtain a default implementation
- * of this interface by subclassing <code>PlatformObject</code>.
- * </p>
- * @see IAdapterFactory
- * @see IAdapterManager
- * @see PlatformObject
- */
-public interface IAdaptable {
- /**
- * Returns an object which is an instance of the given class
- * associated with this object. Returns <code>null</code> if
- * no such object can be found.
- *
- * @param adapter the adapter class to look up
- * @return a object castable to the given class,
- * or <code>null</code> if this object does not
- * have an adapter for the given class
- */
- public Object getAdapter(Class adapter);
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IAdapterFactory.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IAdapterFactory.java
deleted file mode 100644
index 994eaae3b..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IAdapterFactory.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-/**
- * An adapter factory defines behavioral extensions for
- * one or more classes that implements the <code>IAdaptable</code>
- * interface. Adapter factories are registered with an
- * adapter manager.
- * <p>
- * Clients may implement this interface.
- * </p>
- *
- * @see IAdapterManager
- * @see IAdaptable
- */
-public interface IAdapterFactory {
- /**
- * Returns an object which is an instance of the given class
- * associated with the given object. Returns <code>null</code> if
- * no such object can be found.
- *
- * @param adaptableObject the adaptable object being queried
- * (usually an instance of <code>IAdaptable</code>)
- * @param adapterType the type of adapter to look up
- * @return a object castable to the given adapter type,
- * or <code>null</code> if this adapter factory
- * does not have an adapter of the given type for the
- * given object
- */
- public Object getAdapter(Object adaptableObject, Class adapterType);
-
- /**
- * Returns the collection of adapter types handled by this
- * factory.
- * <p>
- * This method is generally used by an adapter manager
- * to discover which adapter types are supported, in advance
- * of dispatching any actual <code>getAdapter</code> requests.
- * </p>
- *
- * @return the collection of adapter types
- */
- public Class[] getAdapterList();
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IAdapterManager.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IAdapterManager.java
deleted file mode 100644
index bc0b8ab64..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IAdapterManager.java
+++ /dev/null
@@ -1,223 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-
-/**
- * An adapter manager maintains a registry of adapter factories. Clients
- * directly invoke methods on an adapter manager to register and unregister
- * adapters. All adaptable objects (that is, objects that implement the <code>IAdaptable</code>
- * interface) funnel <code>IAdaptable.getAdapter</code> invocations to their
- * adapter manager's <code>IAdapterManger.getAdapter</code> method. The
- * adapter manager then forwards this request unmodified to the <code>IAdapterFactory.getAdapter</code>
- * method on one of the registered adapter factories.
- * <p>
- * Adapter factories can be registered programmatically using the <code>registerAdapters</code>
- * method. Alternatively, they can be registered declaratively using the
- * <code>org.eclipse.core.runtime.adapters</code> extension point. Factories registered
- * with this extension point will not be able to provide adapters until their
- * corresponding plugin has been activated.
- * <p>
- * The following code snippet shows how one might register an adapter of type
- * <code>com.example.acme.Sticky</code> on resources in the workspace.
- * <p>
- *
- * <pre>
- * IAdapterFactory pr = new IAdapterFactory() {
- * public Class[] getAdapterList() {
- * return new Class[] { com.example.acme.Sticky.class };
- * }
- * public Object getAdapter(Object adaptableObject, Class adapterType) {
- * IResource res = (IResource) adaptableObject;
- * QualifiedName key = new QualifiedName(&quot;com.example.acme&quot;, &quot;sticky-note&quot;);
- * try {
- * com.example.acme.Sticky v = (com.example.acme.Sticky) res.getSessionProperty(key);
- * if (v == null) {
- * v = new com.example.acme.Sticky();
- * res.setSessionProperty(key, v);
- * }
- * } catch (CoreException e) {
- * // unable to access session property - ignore
- * }
- * return v;
- * }
- * }
- * Platform.getAdapterManager().registerAdapters(pr, IResource.class);
- * </pre>
- *
- * </p>
- * <p>
- * This interface is not intended to be implemented by clients.
- * </p>
- *
- * @see IAdaptable
- * @see IAdapterFactory
- * XXX Needs to put @since
- */
-public interface IAdapterManager {
-
- /**
- * Returns the types that can be obtained by converting <code>adaptableClass</code>
- * via this manager. Converting means that subsequent calls to <code>getAdapter()</code>
- * or <code>loadAdapter()</code> could result in an adapted object.
- * <p>
- * Note that the returned types do not guarantee that
- * a subsequent call to <code>getAdapter</code> with the same type as an argument
- * will return a non-null result. If the factory's plug-in has not yet been
- * loaded, or if the factory itself returns <code>null</code>, then
- * <code>getAdapter</code> will still return <code>null</code>.
- * </p>
- * @param adaptableClass the adaptable class being queried
- * @return an array of type names that can be obtained by converting
- * <code>adaptableClass</code> via this manager. An empty array
- * is returned if there are none.
- * @since 3.1
- */
- public String[] computeAdapterTypes(Class adaptableClass);
-
- /**
- * Returns the class search order for a given class. The search order from a
- * class with the definition <br>
- * <code>class X extends Y implements A, B</code><br>
- * is as follows:
- * <ul>
- * <li>the target's class: X
- * <li>X's superclasses in order to <code>Object</code>
- * <li>a breadth-first traversal of the target class's interfaces in the
- * order returned by <code>getInterfaces</code> (in the example, A and its
- * superinterfaces then B and its superinterfaces) </il>
- * </ul>
- *
- * @param clazz the class for which to return the class order.
- * @return the class search order for the given class. The returned
- * search order will minimally contain the target class.
- * @since 3.1
- */
- public Class[] computeClassOrder(Class clazz);
- /**
- * Returns an object which is an instance of the given class associated
- * with the given object. Returns <code>null</code> if no such object can
- * be found.
- * <p>
- * Note that this method will never cause plug-ins to be loaded. If the
- * only suitable factory is not yet loaded, this method will return <code>null</code>.
- *
- * @param adaptable the adaptable object being queried (usually an instance
- * of <code>IAdaptable</code>)
- * @param adapterType the type of adapter to look up
- * @return an object castable to the given adapter type, or <code>null</code>
- * if the given adaptable object does not have an available adapter of the
- * given type
- */
- public Object getAdapter(Object adaptable, Class adapterType);
-
- /**
- * Returns an object which is an instance of the given class name associated
- * with the given object. Returns <code>null</code> if no such object can
- * be found.
- * <p>
- * Note that this method will never cause plug-ins to be loaded. If the
- * only suitable factory is not yet loaded, this method will return <code>null</code>.
- * If activation of the plug-in providing the factory is required, use the
- * <code>loadAdapter</code> method instead.
- *
- * @param adaptable the adaptable object being queried (usually an instance
- * of <code>IAdaptable</code>)
- * @param adapterTypeName the fully qualified name of the type of adapter to look up
- * @return an object castable to the given adapter type, or <code>null</code>
- * if the given adaptable object does not have an available adapter of the
- * given type
- * @since 3.0
- */
- public Object getAdapter(Object adaptable, String adapterTypeName);
-
- /**
- * Returns whether there is an adapter factory registered that may be able
- * to convert <code>adaptable</code> to an object of type <code>adapterTypeName</code>.
- * <p>
- * Note that a return value of <code>true</code> does not guarantee that
- * a subsequent call to <code>getAdapter</code> with the same arguments
- * will return a non-null result. If the factory's plug-in has not yet been
- * loaded, or if the factory itself returns <code>null</code>, then
- * <code>getAdapter</code> will still return <code>null</code>.
- *
- * @param adaptable the adaptable object being queried (usually an instance
- * of <code>IAdaptable</code>)
- * @param adapterTypeName the fully qualified class name of an adapter to
- * look up
- * @return <code>true</code> if there is an adapter factory that claims
- * it can convert <code>adaptable</code> to an object of type <code>adapterType</code>,
- * and <code>false</code> otherwise.
- * @since 3.0
- */
- public boolean hasAdapter(Object adaptable, String adapterTypeName);
-
- /**
- * Returns an object that is an instance of the given class name associated
- * with the given object. Returns <code>null</code> if no such object can
- * be found.
- * <p>
- * Note that unlike the <code>getAdapter</code> methods, this method
- * will cause the plug-in that contributes the adapter factory to be loaded
- * if necessary. As such, this method should be used judiciously, in order
- * to avoid unnecessary plug-in activations. Most clients should avoid
- * activation by using <code>getAdapter</code> instead.
- *
- * @param adaptable the adaptable object being queried (usually an instance
- * of <code>IAdaptable</code>)
- * @param adapterTypeName the fully qualified name of the type of adapter to look up
- * @return an object castable to the given adapter type, or <code>null</code>
- * if the given adaptable object does not have an available adapter of the
- * given type
- * @since 3.0
- */
- public Object loadAdapter(Object adaptable, String adapterTypeName);
-
- /**
- * Registers the given adapter factory as extending objects of the given
- * type.
- * <p>
- * If the type being extended is a class, the given factory's adapters are
- * available on instances of that class and any of its subclasses. If it is
- * an interface, the adapters are available to all classes that directly or
- * indirectly implement that interface.
- * </p>
- *
- * @param factory the adapter factory
- * @param adaptable the type being extended
- * @see #unregisterAdapters(IAdapterFactory)
- * @see #unregisterAdapters(IAdapterFactory, Class)
- */
- public void registerAdapters(IAdapterFactory factory, Class adaptable);
-
- /**
- * Removes the given adapter factory completely from the list of registered
- * factories. Equivalent to calling <code>unregisterAdapters(IAdapterFactory,Class)</code>
- * on all classes against which it had been explicitly registered. Does
- * nothing if the given factory is not currently registered.
- *
- * @param factory the adapter factory to remove
- * @see #registerAdapters(IAdapterFactory, Class)
- */
- public void unregisterAdapters(IAdapterFactory factory);
-
- /**
- * Removes the given adapter factory from the list of factories registered
- * as extending the given class. Does nothing if the given factory and type
- * combination is not registered.
- *
- * @param factory the adapter factory to remove
- * @param adaptable one of the types against which the given factory is
- * registered
- * @see #registerAdapters(IAdapterFactory, Class)
- */
- public void unregisterAdapters(IAdapterFactory factory, Class adaptable);
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IBundleGroup.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IBundleGroup.java
deleted file mode 100644
index 3f5339404..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IBundleGroup.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-import org.osgi.framework.Bundle;
-
-/**
- * Bundle groups represent a logical collection of plug-ins (aka bundles). Bundle
- * groups do not contain their constituents but rather collect them together under
- * a common label. The main role of a bundle group is to report to the system
- * (e.g., the About dialog) what bundles have been installed. They are not intended
- * for use in managing the set of bundles they represent.
- * <p>
- * Since the bulk of the branding related information is specific to the consumer,
- * bundle groups also carry an arbitrary set of properties. The valid set of
- * key-value pairs and their interpretation defined by the consumer in the
- * target environment.
- * </p><p>
- * The Eclipse UI is the typical consumer of bundle groups and defines various
- * property keys that it will use, for example, to display About information. See
- * <code>org.eclipse.ui.branding.IBundleGroupConstants</code>.
- * </p>
- * @see IBundleGroupProvider
- * @since 3.0
- */
-public interface IBundleGroup {
-
- /**
- * Returns the identifier of this bundle group. Bundle groups are uniquely identified by the combination of
- * their identifier and their version.
- *
- * @see #getVersion()
- * @return the identifier for this bundle group
- */
- public String getIdentifier();
-
- /**
- * Returns the human-readable name of this bundle group.
- *
- * @return the human-readable name
- */
- public String getName();
-
- /**
- * Returns the version of this bundle group. Bundle group version strings have the same format as
- * bundle versions (i.e., major.minor.service.qualifier). Bundle groups are uniquely identified
- * by the combination of their identifier and their version.
- *
- * @see #getIdentifier()
- * @return the string form of this bundle group's version
- */
- public String getVersion();
-
- /**
- * Returns a text description of this bundle group.
- *
- * @return text description of this bundle group
- */
- public String getDescription();
-
- /**
- * Returns the name of the provider of this bundle group.
- *
- * @return the name of the provider or <code>null</code> if none
- */
- public String getProviderName();
-
- /**
- * Returns a list of all bundles supplied by this bundle group.
- *
- * @return the bundles supplied by this bundle group
- */
- public Bundle[] getBundles();
-
- /**
- * Returns the property of this bundle group with the given key.
- * <code>null</code> is returned if there is no such key/value pair.
- *
- * @param key the name of the property to return
- * @return the value associated with the given key or <code>null</code> if none
- */
- public String getProperty(String key);
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IBundleGroupProvider.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IBundleGroupProvider.java
deleted file mode 100644
index dad6eb5d6..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IBundleGroupProvider.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-/**
- * Bundle group providers define groups of plug-ins which have been installed in
- * the current system. Typically, a configuration agent (i.e., plug-in installer) will
- * define a bundle group provider so that it can report to the system the list
- * of plug-ins it has installed.
- *
- * @see IBundleGroup
- * @since 3.0
- */
-public interface IBundleGroupProvider {
-
- /**
- * Returns the human-readable name of this bundle group provider.
- *
- * @return the name of this bundle group provider
- */
- public String getName();
-
- /**
- * Returns the bundle groups provided by this provider.
- *
- * @return the bundle groups provided by this provider
- */
- public IBundleGroup[] getBundleGroups();
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ILogListener.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ILogListener.java
deleted file mode 100644
index b8c454823..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ILogListener.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-import java.util.EventListener;
-
-/**
- * A log listener is notified of entries added to a plug-in's log.
- * <p>
- * Clients may implement this interface.
- * </p>
- *
- * @see ILog#addLogListener(ILogListener)
- * @see Platform#addLogListener(ILogListener)
- */
-public interface ILogListener extends EventListener {
- /**
- * Notifies this listener that given status has been logged by
- * a plug-in. The listener is free to retain or ignore this status.
- *
- * @param status the status being logged
- * @param plugin the plugin of the log which generated this event
- */
- public void logging(IStatus status, String plugin);
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IPath.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IPath.java
deleted file mode 100644
index d9eb8ca38..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IPath.java
+++ /dev/null
@@ -1,504 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-/**
- * A path is an ordered collection of string segments,
- * separated by a standard separator character, "/".
- * A path may also have a leading and/or a trailing separator.
- * Paths may also be prefixed by an optional device id, which includes
- * the character(s) which separate the device id from the rest
- * of the path. For example, "C:" and "Server/Volume:" are typical
- * device ids.
- * A device independent path has <code>null</code> for a device id.
- * <p>
- * Note that paths are value objects; all operations on paths
- * return a new path; the path that is operated on is unscathed.
- * </p>
- * <p>
- * UNC paths are denoted by leading double-slashes such
- * as <code>//Server/Volume/My/Path</code>. When a new path
- * is constructed all double-slashes are removed except those
- * appearing at the beginning of the path.
- * </p>
- * <p>
- * This interface is not intended to be implemented by clients.
- * </p>
- *
- * @see Path
- */
-public interface IPath extends Cloneable {
-
- /**
- * Path separator character constant "/" used in paths.
- */
- public static final char SEPARATOR = '/';
-
- /**
- * Device separator character constant ":" used in paths.
- */
- public static final char DEVICE_SEPARATOR = ':';
-
- /**
- * Returns a new path which is the same as this path but with
- * the given file extension added. If this path is empty, root or has a
- * trailing separator, this path is returned. If this path already
- * has an extension, the existing extension is left and the given
- * extension simply appended. Clients wishing to replace
- * the current extension should first remove the extension and
- * then add the desired one.
- * <p>
- * The file extension portion is defined as the string
- * following the last period (".") character in the last segment.
- * The given extension should not include a leading ".".
- * </p>
- *
- * @param extension the file extension to append
- * @return the new path
- */
- public IPath addFileExtension(String extension);
-
- /**
- * Returns a path with the same segments as this path
- * but with a trailing separator added.
- * This path must have at least one segment.
- * <p>
- * If this path already has a trailing separator,
- * this path is returned.
- * </p>
- *
- * @return the new path
- * @see #hasTrailingSeparator()
- * @see #removeTrailingSeparator()
- */
- public IPath addTrailingSeparator();
-
- /**
- * Returns the canonicalized path obtained from the
- * concatenation of the given string path to the
- * end of this path. The given string path must be a valid
- * path. If it has a trailing separator,
- * the result will have a trailing separator.
- * The device id of this path is preserved (the one
- * of the given string is ignored). Duplicate slashes
- * are removed from the path except at the beginning
- * where the path is considered to be UNC.
- *
- * @param path the string path to concatenate
- * @return the new path
- * @see #isValidPath(String)
- */
- public IPath append(String path);
-
- /**
- * Returns the canonicalized path obtained from the
- * concatenation of the given path's segments to the
- * end of this path. If the given path has a trailing
- * separator, the result will have a trailing separator.
- * The device id of this path is preserved (the one
- * of the given path is ignored). Duplicate slashes
- * are removed from the path except at the beginning
- * where the path is considered to be UNC.
- *
- * @param path the path to concatenate
- * @return the new path
- */
- public IPath append(IPath path);
-
- /**
- * Returns a copy of this path.
- *
- * @return the cloned path
- */
- public Object clone();
-
- /**
- * Returns whether this path equals the given object.
- * <p>
- * Equality for paths is defined to be: same sequence of segments,
- * same absolute/relative status, and same device.
- * Trailing separators are disregarded.
- * Paths are not generally considered equal to objects other than paths.
- * </p>
- *
- * @param obj the other object
- * @return <code>true</code> if the paths are equivalent,
- * and <code>false</code> if they are not
- */
- public boolean equals(Object obj);
-
- /**
- * Returns the device id for this path, or <code>null</code> if this
- * path has no device id. Note that the result will end in ':'.
- *
- * @return the device id, or <code>null</code>
- * @see #setDevice(String)
- */
- public String getDevice();
-
- /**
- * Returns the file extension portion of this path,
- * or <code>null</code> if there is none.
- * <p>
- * The file extension portion is defined as the string
- * following the last period (".") character in the last segment.
- * If there is no period in the last segment, the path has no
- * file extension portion. If the last segment ends in a period,
- * the file extension portion is the empty string.
- * </p>
- *
- * @return the file extension or <code>null</code>
- */
- public String getFileExtension();
-
- /**
- * Returns whether this path has a trailing separator.
- * <p>
- * Note: In the root path ("/"), the separator is considered to
- * be leading rather than trailing.
- * </p>
- *
- * @return <code>true</code> if this path has a trailing
- * separator, and <code>false</code> otherwise
- * @see #addTrailingSeparator()
- * @see #removeTrailingSeparator()
- */
- public boolean hasTrailingSeparator();
-
- /**
- * Returns whether this path is an absolute path (ignoring
- * any device id).
- * <p>
- * Absolute paths start with a path separator.
- * A root path, like <code>/</code> or <code>C:/</code>,
- * is considered absolute. UNC paths are always absolute.
- * </p>
- *
- * @return <code>true</code> if this path is an absolute path,
- * and <code>false</code> otherwise
- */
- public boolean isAbsolute();
-
- /**
- * Returns whether this path has no segments and is not
- * a root path.
- *
- * @return <code>true</code> if this path is empty,
- * and <code>false</code> otherwise
- */
- public boolean isEmpty();
-
- /**
- * Returns whether this path is a prefix of the given path.
- * To be a prefix, this path's segments must
- * appear in the argument path in the same order,
- * and their device ids must match.
- * <p>
- * An empty path is a prefix of all paths with the same device; a root path is a prefix of
- * all absolute paths with the same device.
- * </p>
- * @param anotherPath the other path
- * @return <code>true</code> if this path is a prefix of the given path,
- * and <code>false</code> otherwise
- */
- public boolean isPrefixOf(IPath anotherPath);
-
- /**
- * Returns whether this path is a root path.
- * <p>
- * The root path is the absolute non-UNC path with zero segments;
- * e.g., <code>/</code> or <code>C:/</code>.
- * The separator is considered a leading separator, not a trailing one.
- * </p>
- *
- * @return <code>true</code> if this path is a root path,
- * and <code>false</code> otherwise
- */
- public boolean isRoot();
-
- /**
- * Returns a boolean value indicating whether or not this path
- * is considered to be in UNC form. Return false if this path
- * has a device set or if the first 2 characters of the path string
- * are not <code>Path.SEPARATOR</code>.
- *
- * @return boolean indicating if this path is UNC
- */
- public boolean isUNC();
-
- /**
- * Returns whether the given string is syntactically correct as
- * a path. The device id is the prefix up to and including the device
- * separator for the local file system; the path proper is everything to
- * the right of it, or the entire string if there is no device separator.
- * When the platform location is a file system with no meaningful device
- * separator, the entire string is treated as the path proper.
- * The device id is not checked for validity; the path proper is correct
- * if each of the segments in its canonicalized form is valid.
- *
- * @param path the path to check
- * @return <code>true</code> if the given string is a valid path,
- * and <code>false</code> otherwise
- * @see #isValidSegment(String)
- */
- public boolean isValidPath(String path);
-
- /**
- * Returns whether the given string is valid as a segment in
- * a path. The rules for valid segments are as follows:
- * <ul>
- * <li> the empty string is not valid
- * <li> any string containing the slash character ('/') is not valid
- * <li>any string containing segment or device separator characters
- * on the local file system, such as the backslash ('\') and colon (':')
- * on some file systems.
- * </ul>
- *
- * @param segment the path segment to check
- * @return <code>true</code> if the given path segment is valid,
- * and <code>false</code> otherwise
- */
- public boolean isValidSegment(String segment);
-
- /**
- * Returns the last segment of this path, or
- * <code>null</code> if it does not have any segments.
- *
- * @return the last segment of this path, or <code>null</code>
- */
- public String lastSegment();
-
- /**
- * Returns an absolute path with the segments and device id of this path.
- * Absolute paths start with a path separator. If this path is absolute,
- * it is simply returned.
- *
- * @return the new path
- */
- public IPath makeAbsolute();
-
- /**
- * Returns a relative path with the segments and device id of this path.
- * Absolute paths start with a path separator and relative paths do not.
- * If this path is relative, it is simply returned.
- *
- * @return the new path
- */
- public IPath makeRelative();
-
- /**
- * Return a new path which is the equivalent of this path converted to UNC
- * form (if the given boolean is true) or this path not as a UNC path (if the given
- * boolean is false). If UNC, the returned path will not have a device and the
- * first 2 characters of the path string will be <code>Path.SEPARATOR</code>. If not UNC, the
- * first 2 characters of the returned path string will not be <code>Path.SEPARATOR</code>.
- *
- * @param toUNC true if converting to UNC, false otherwise
- * @return the new path, either in UNC form or not depending on the boolean parameter
- */
- public IPath makeUNC(boolean toUNC);
-
- /**
- * Returns a count of the number of segments which match in
- * this path and the given path (device ids are ignored),
- * comparing in increasing segment number order.
- *
- * @param anotherPath the other path
- * @return the number of matching segments
- */
- public int matchingFirstSegments(IPath anotherPath);
-
- /**
- * Returns a new path which is the same as this path but with
- * the file extension removed. If this path does not have an
- * extension, this path is returned.
- * <p>
- * The file extension portion is defined as the string
- * following the last period (".") character in the last segment.
- * If there is no period in the last segment, the path has no
- * file extension portion. If the last segment ends in a period,
- * the file extension portion is the empty string.
- * </p>
- *
- * @return the new path
- */
- public IPath removeFileExtension();
-
- /**
- * Returns a copy of this path with the given number of segments
- * removed from the beginning. The device id is preserved.
- * The number must be greater or equal zero.
- * If the count is zero, this path is returned.
- * The resulting path will always be a relative path with respect
- * to this path. If the number equals or exceeds the number
- * of segments in this path, an empty relative path is returned.
- *
- * @param count the number of segments to remove
- * @return the new path
- */
- public IPath removeFirstSegments(int count);
-
- /**
- * Returns a copy of this path with the given number of segments
- * removed from the end. The device id is preserved.
- * The number must be greater or equal zero.
- * If the count is zero, this path is returned.
- * <p>
- * If this path has a trailing separator, it will still
- * have a trailing separator after the last segments are removed
- * (assuming there are some segments left). If there is no
- * trailing separator, the result will not have a trailing
- * separator.
- * If the number equals or exceeds the number
- * of segments in this path, an empty path is returned.
- * </p>
- *
- * @param count the number of segments to remove
- * @return the new path
- */
- public IPath removeLastSegments(int count);
-
- /**
- * Returns a path with the same segments as this path
- * but with a trailing separator removed.
- * Does nothing if this path does not have at least one segment.
- * The device id is preserved.
- * <p>
- * If this path does not have a trailing separator,
- * this path is returned.
- * </p>
- *
- * @return the new path
- * @see #addTrailingSeparator()
- * @see #hasTrailingSeparator()
- */
- public IPath removeTrailingSeparator();
-
- /**
- * Returns the specified segment of this path, or
- * <code>null</code> if the path does not have such a segment.
- *
- * @param index the 0-based segment index
- * @return the specified segment, or <code>null</code>
- */
- public String segment(int index);
-
- /**
- * Returns the number of segments in this path.
- * <p>
- * Note that both root and empty paths have 0 segments.
- * </p>
- *
- * @return the number of segments
- */
- public int segmentCount();
-
- /**
- * Returns the segments in this path in order.
- *
- * @return an array of string segments
- */
- public String[] segments();
-
- /**
- * Returns a new path which is the same as this path but with
- * the given device id. The device id must end with a ":".
- * A device independent path is obtained by passing <code>null</code>.
- * <p>
- * For example, "C:" and "Server/Volume:" are typical device ids.
- * </p>
- *
- * @param device the device id or <code>null</code>
- * @return a new path
- * @see #getDevice()
- */
- public IPath setDevice(String device);
-
- /**
- * Returns a <code>java.io.File</code> corresponding to this path.
- *
- * @return the file corresponding to this path
- */
- public java.io.File toFile();
-
- /**
- * Returns a string representation of this path which uses the
- * platform-dependent path separator defined by <code>java.io.File</code>.
- * This method is like <code>toString()</code> except that the
- * latter always uses the same separator (<code>/</code>) regardless of platform.
- * <p>
- * This string is suitable for passing to <code>java.io.File(String)</code>.
- * </p>
- *
- * @return a platform-dependent string representation of this path
- */
- public String toOSString();
-
- /**
- * Returns a platform-neutral string representation of this path. The
- * format is not specified, except that the resulting string can be
- * passed back to the <code>Path#fromPortableString(String)</code>
- * constructor to produce the exact same path on any platform.
- * <p>
- * This string is suitable for passing to <code>Path#fromPortableString(String)</code>.
- * </p>
- *
- * @return a platform-neutral string representation of this path
- * @see Path#fromPortableString(String)
- * @since 3.1
- */
- public String toPortableString();
-
- /**
- * Returns a string representation of this path, including its
- * device id. The same separator, "/", is used on all platforms.
- * <p>
- * Example result strings (without and with device id):
- * <pre>
- * "/foo/bar.txt"
- * "bar.txt"
- * "/foo/"
- * "foo/"
- * ""
- * "/"
- * "C:/foo/bar.txt"
- * "C:bar.txt"
- * "C:/foo/"
- * "C:foo/"
- * "C:"
- * "C:/"
- * </pre>
- * This string is suitable for passing to <code>Path(String)</code>.
- * </p>
- *
- * @return a string representation of this path
- * @see Path
- */
- public String toString();
-
- /**
- * Returns a copy of this path truncated after the
- * given number of segments. The number must not be negative.
- * The device id is preserved.
- * <p>
- * If this path has a trailing separator, the result will too
- * (assuming there are some segments left). If there is no
- * trailing separator, the result will not have a trailing
- * separator.
- * Copying up to segment zero simply means making an copy with
- * no path segments.
- * </p>
- *
- * @param count the segment number at which to truncate the path
- * @return the new path
- */
- public IPath uptoSegment(int count);
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IProgressMonitor.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IProgressMonitor.java
deleted file mode 100644
index 3a8f2d758..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IProgressMonitor.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-/**
- * The <code>IProgressMonitor</code> interface is implemented
- * by objects that monitor the progress of an activity; the methods
- * in this interface are invoked by code that performs the activity.
- * <p>
- * All activity is broken down into a linear sequence of tasks against
- * which progress is reported. When a task begins, a <code>beginTask(String, int)
- * </code> notification is reported, followed by any number and mixture of
- * progress reports (<code>worked()</code>) and subtask notifications
- * (<code>subTask(String)</code>). When the task is eventually completed, a
- * <code>done()</code> notification is reported. After the <code>done()</code>
- * notification, the progress monitor cannot be reused; i.e., <code>
- * beginTask(String, int)</code> cannot be called again after the call to
- * <code>done()</code>.
- * </p>
- * <p>
- * A request to cancel an operation can be signaled using the
- * <code>setCanceled</code> method. Operations taking a progress
- * monitor are expected to poll the monitor (using <code>isCanceled</code>)
- * periodically and abort at their earliest convenience. Operation can however
- * choose to ignore cancelation requests.
- * </p>
- * <p>
- * Since notification is synchronous with the activity itself, the listener should
- * provide a fast and robust implementation. If the handling of notifications would
- * involve blocking operations, or operations which might throw uncaught exceptions,
- * the notifications should be queued, and the actual processing deferred (or perhaps
- * delegated to a separate thread).
- * </p>
- * <p>
- * Clients may implement this interface.
- * </p>
- */
-public interface IProgressMonitor {
-
- /** Constant indicating an unknown amount of work.
- */
- public final static int UNKNOWN = -1;
-
- /**
- * Notifies that the main task is beginning. This must only be called once
- * on a given progress monitor instance.
- *
- * @param name the name (or description) of the main task
- * @param totalWork the total number of work units into which
- * the main task is been subdivided. If the value is <code>UNKNOWN</code>
- * the implementation is free to indicate progress in a way which
- * doesn't require the total number of work units in advance.
- */
- public void beginTask(String name, int totalWork);
-
- /**
- * Notifies that the work is done; that is, either the main task is completed
- * or the user canceled it. This method may be called more than once
- * (implementations should be prepared to handle this case).
- */
- public void done();
-
- /**
- * Internal method to handle scaling correctly. This method
- * must not be called by a client. Clients should
- * always use the method </code>worked(int)</code>.
- *
- * @param work the amount of work done
- */
- public void internalWorked(double work);
-
- /**
- * Returns whether cancelation of current operation has been requested.
- * Long-running operations should poll to see if cancelation
- * has been requested.
- *
- * @return <code>true</code> if cancellation has been requested,
- * and <code>false</code> otherwise
- * @see #setCanceled(boolean)
- */
- public boolean isCanceled();
-
- /**
- * Sets the cancel state to the given value.
- *
- * @param value <code>true</code> indicates that cancelation has
- * been requested (but not necessarily acknowledged);
- * <code>false</code> clears this flag
- * @see #isCanceled()
- */
- public void setCanceled(boolean value);
-
- /**
- * Sets the task name to the given value. This method is used to
- * restore the task label after a nested operation was executed.
- * Normally there is no need for clients to call this method.
- *
- * @param name the name (or description) of the main task
- * @see #beginTask(java.lang.String, int)
- */
- public void setTaskName(String name);
-
- /**
- * Notifies that a subtask of the main task is beginning.
- * Subtasks are optional; the main task might not have subtasks.
- *
- * @param name the name (or description) of the subtask
- */
- public void subTask(String name);
-
- /**
- * Notifies that a given number of work unit of the main task
- * has been completed. Note that this amount represents an
- * installment, as opposed to a cumulative amount of work done
- * to date.
- *
- * @param work the number of work units just completed
- */
- public void worked(int work);
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IProgressMonitorWithBlocking.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IProgressMonitorWithBlocking.java
deleted file mode 100644
index 23a2bac47..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IProgressMonitorWithBlocking.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation 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:
- * IBM - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-/**
- * An extension to the IProgressMonitor interface for monitors that want to
- * support feedback when an activity is blocked due to concurrent activity in
- * another thread.
- * <p>
- * When a monitor that supports this extension is passed to an operation, the
- * operation should call <code>setBlocked</code> whenever it knows that it
- * must wait for a lock that is currently held by another thread. The operation
- * should continue to check for and respond to cancelation requests while
- * blocked. When the operation is no longer blocked, it must call <code>clearBlocked</code>
- * to clear the blocked state.
- * <p>
- * Clients may implement this interface.
- * </p>
- * @see IProgressMonitor
- * @since 3.0
- */
-public interface IProgressMonitorWithBlocking extends IProgressMonitor {
- /**
- * Indicates that this operation is blocked by some background activity. If
- * a running operation ever calls <code>setBlocked</code>, it must
- * eventually call <code>clearBlocked</code> before the operation
- * completes.
- * <p>
- * If the caller is blocked by a currently executing job, this method will return
- * an <code>IJobStatus</code> indicating the job that is currently blocking
- * the caller. If this blocking job is not known, this method will return a plain
- * informational <code>IStatus</code> object.
- * </p>
- *
- * @param reason an optional status object whose message describes the
- * reason why this operation is blocked, or <code>null</code> if this
- * information is not available.
- * @see #clearBlocked()
- * @see org.eclipse.core.runtime.jobs.IJobStatus
- */
- public void setBlocked(IStatus reason);
-
- /**
- * Clears the blocked state of the running operation. If a running
- * operation ever calls <code>setBlocked</code>, it must eventually call
- * <code>clearBlocked</code> before the operation completes.
- *
- * @see #setBlocked(IStatus)
- */
- public void clearBlocked();
-
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ISafeRunnable.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ISafeRunnable.java
deleted file mode 100644
index 02a7ce10a..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ISafeRunnable.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-/**
- * Safe runnables represent blocks of code and associated exception
- * handlers. They are typically used when a plug-in needs to call some
- * untrusted code (e.g., code contributed by another plug-in via an
- * extension).
- * <p>
- * Clients may implement this interface.
- * </p>
- *
- * @see Platform#run(ISafeRunnable)
- */
-public interface ISafeRunnable {
- /**
- * Handles an exception thrown by this runnable's <code>run</code>
- * method. The processing done here should be specific to the
- * particular usecase for this runnable. Generalized exception
- * processing (e.g., logging in the platform's log) is done by the
- * Platform's run mechanism.
- *
- * @param exception an exception which occurred during processing
- * the body of this runnable (i.e., in <code>run()</code>)
- * @see Platform#run(ISafeRunnable)
- */
- public void handleException(Throwable exception);
-
- /**
- * Runs this runnable. Any exceptions thrown from this method will
- * be passed to this runnable's <code>handleException</code>
- * method.
- *
- * @exception Exception if a problem occurred while running this method.
- * The exception will be processed by <code>handleException</code>
- * @see Platform#run(ISafeRunnable)
- */
- public void run() throws Exception;
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IStatus.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IStatus.java
deleted file mode 100644
index a2418858e..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IStatus.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-/**
- * A status object represents the outcome of an operation.
- * All <code>CoreException</code>s carry a status object to indicate
- * what went wrong. Status objects are also returned by methods needing
- * to provide details of failures (e.g., validation methods).
- * <p>
- * A status carries the following information:
- * <ul>
- * <li> plug-in identifier (required)</li>
- * <li> severity (required)</li>
- * <li> status code (required)</li>
- * <li> message (required) - localized to current locale</li>
- * <li> exception (optional) - for problems stemming from a failure at
- * a lower level</li>
- * </ul>
- * Some status objects, known as multi-statuses, have other status objects
- * as children.
- * </p>
- * <p>
- * The class <code>Status</code> is the standard public implementation
- * of status objects; the subclass <code>MultiStatus</code> is the
- * implements multi-status objects.
- * </p>
- * @see MultiStatus
- * @see Status
- */
-public interface IStatus {
-
- /** Status severity constant (value 0) indicating this status represents the nominal case.
- * This constant is also used as the status code representing the nominal case.
- * @see #getSeverity()
- * @see #isOK()
- */
- public static final int OK = 0;
-
- /** Status type severity (bit mask, value 1) indicating this status is informational only.
- * @see #getSeverity()
- * @see #matches(int)
- */
- public static final int INFO = 0x01;
-
- /** Status type severity (bit mask, value 2) indicating this status represents a warning.
- * @see #getSeverity()
- * @see #matches(int)
- */
- public static final int WARNING = 0x02;
-
- /** Status type severity (bit mask, value 4) indicating this status represents an error.
- * @see #getSeverity()
- * @see #matches(int)
- */
- public static final int ERROR = 0x04;
-
- /** Status type severity (bit mask, value 8) indicating this status represents a
- * cancelation
- * @see #getSeverity()
- * @see #matches(int)
- * @since 3.0
- */
- public static final int CANCEL = 0x08;
-
- /**
- * Returns a list of status object immediately contained in this
- * multi-status, or an empty list if this is not a multi-status.
- *
- * @return an array of status objects
- * @see #isMultiStatus()
- */
- public IStatus[] getChildren();
-
- /**
- * Returns the plug-in-specific status code describing the outcome.
- *
- * @return plug-in-specific status code
- */
- public int getCode();
-
- /**
- * Returns the relevant low-level exception, or <code>null</code> if none.
- * For example, when an operation fails because of a network communications
- * failure, this might return the <code>java.io.IOException</code>
- * describing the exact nature of that failure.
- *
- * @return the relevant low-level exception, or <code>null</code> if none
- */
- public Throwable getException();
-
- /**
- * Returns the message describing the outcome.
- * The message is localized to the current locale.
- *
- * @return a localized message
- */
- public String getMessage();
-
- /**
- * Returns the unique identifier of the plug-in associated with this status
- * (this is the plug-in that defines the meaning of the status code).
- *
- * @return the unique identifier of the relevant plug-in
- */
- public String getPlugin();
-
- /**
- * Returns the severity. The severities are as follows (in
- * descending order):
- * <ul>
- * <li><code>CANCEL</code> - cancelation occurred</li>
- * <li><code>ERROR</code> - a serious error (most severe)</li>
- * <li><code>WARNING</code> - a warning (less severe)</li>
- * <li><code>INFO</code> - an informational ("fyi") message (least severe)</li>
- * <li><code>OK</code> - everything is just fine</li>
- * </ul>
- * <p>
- * The severity of a multi-status is defined to be the maximum
- * severity of any of its children, or <code>OK</code> if it has
- * no children.
- * </p>
- *
- * @return the severity: one of <code>OK</code>, <code>ERROR</code>,
- * <code>INFO</code>, <code>WARNING</code>, or <code>CANCEL</code>
- * @see #matches(int)
- */
- public int getSeverity();
-
- /**
- * Returns whether this status is a multi-status.
- * A multi-status describes the outcome of an operation
- * involving multiple operands.
- * <p>
- * The severity of a multi-status is derived from the severities
- * of its children; a multi-status with no children is
- * <code>OK</code> by definition.
- * A multi-status carries a plug-in identifier, a status code,
- * a message, and an optional exception. Clients may treat
- * multi-status objects in a multi-status unaware way.
- * </p>
- *
- * @return <code>true</code> for a multi-status,
- * <code>false</code> otherwise
- * @see #getChildren()
- */
- public boolean isMultiStatus();
-
- /**
- * Returns whether this status indicates everything is okay
- * (neither info, warning, nor error).
- *
- * @return <code>true</code> if this status has severity
- * <code>OK</code>, and <code>false</code> otherwise
- */
- public boolean isOK();
-
- /**
- * Returns whether the severity of this status matches the given
- * severity mask. Note that a status with severity <code>OK</code>
- * will never match; use <code>isOK</code> instead to detect
- * a status with a severity of <code>OK</code>.
- *
- * @param severityMask a mask formed by bitwise or'ing severity mask
- * constants (<code>ERROR</code>, <code>WARNING</code>,
- * <code>INFO</code>, <code>CANCEL</code>)
- * @return <code>true</code> if there is at least one match,
- * <code>false</code> if there are no matches
- * @see #getSeverity()
- * @see #CANCEL
- * @see #ERROR
- * @see #WARNING
- * @see #INFO
- */
- public boolean matches(int severityMask);
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ListenerList.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ListenerList.java
deleted file mode 100644
index f854147bb..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ListenerList.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-/**
- * This class is a thread safe list that is designed for storing lists of listeners.
- * The implementation is optimized for minimal memory footprint, frequent reads
- * and infrequent writes. Modification of the list is synchronized and relatively
- * expensive, while accessing the listeners is very fast. Readers are given access
- * to the underlying array data structure for reading, with the trust that they will
- * not modify the underlying array.
- * <p>
- * <a name="same">A listener list handles the <i>same</i> listener being added
- * multiple times, and tolerates removal of listeners that are the same as other
- * listeners in the list. For this purpose, listeners can be compared with each other
- * using either equality or identity, as specified in the list constructor.
- * </p>
- *
- * @since org.eclipse.equinox.common 1.0
- */
-public class ListenerList {
-
- /**
- * The empty array singleton instance.
- */
- private static final Object[] EmptyArray = new Object[0];
-
- /**
- * Mode constant (value 0) indicating that listeners should be considered
- * the <a href="#same">same</a> if they are equal.
- */
- public static final int EQUALITY = 0;
-
- /**
- * Mode constant (value 1) indicating that listeners should be considered
- * the <a href="#same">same</a> if they are identical.
- */
- public static final int IDENTITY = 1;
-
- /**
- * Indicates the comparison mode used to determine if two
- * listeners are equivalent
- */
- private final boolean identity;
-
- /**
- * The list of listeners. Initially empty but initialized
- * to an array of size capacity the first time a listener is added.
- * Maintains invariant: listeners != null
- */
- private volatile Object[] listeners = EmptyArray;
-
- /**
- * Creates a listener list in which listeners are compared using equality.
- */
- public ListenerList() {
- this(EQUALITY);
- }
-
- /**
- * Creates a listener list using the provided comparison mode.
- *
- * @param mode The mode used to determine if listeners are the <a href="#same">same</a>.
- */
- public ListenerList(int mode) {
- if (mode != EQUALITY && mode != IDENTITY)
- throw new IllegalArgumentException();
- this.identity = mode == IDENTITY;
- }
-
- /**
- * Adds a listener to this list. This method has no effect if the <a href="#same">same</a>
- * listener is already registered.
- *
- * @param listener the listener to add
- */
- public synchronized void add(Object listener) {
- // This method is synchronized to protect against multiple threads adding
- // or removing listeners concurrently. This does not block concurrent readers.
- if (listener == null)
- throw new IllegalArgumentException();
- // check for duplicates
- final int oldSize = listeners.length;
- for (int i = 0; i < oldSize; ++i) {
- Object listener2 = listeners[i];
- if (identity ? listener == listener2 : listener.equals(listener2))
- return;
- }
- // Thread safety: create new array to avoid affecting concurrent readers
- Object[] newListeners = new Object[oldSize + 1];
- System.arraycopy(listeners, 0, newListeners, 0, oldSize);
- newListeners[oldSize] = listener;
- //atomic assignment
- this.listeners = newListeners;
- }
-
- /**
- * Returns an array containing all the registered listeners.
- * The resulting array is unaffected by subsequent adds or removes.
- * If there are no listeners registered, the result is an empty array.
- * Use this method when notifying listeners, so that any modifications
- * to the listener list during the notification will have no effect on
- * the notification itself.
- * <p>
- * Note: Callers of this method <b>must not</b> modify the returned array.
- *
- * @return the list of registered listeners
- */
- public Object[] getListeners() {
- return listeners;
- }
-
- /**
- * Returns whether this listener list is empty.
- *
- * @return <code>true</code> if there are no registered listeners, and
- * <code>false</code> otherwise
- */
- public boolean isEmpty() {
- return listeners.length == 0;
- }
-
- /**
- * Removes a listener from this list. Has no effect if the <a href="#same">same</a>
- * listener was not already registered.
- *
- * @param listener the listener to remove
- */
- public synchronized void remove(Object listener) {
- // This method is synchronized to protect against multiple threads adding
- // or removing listeners concurrently. This does not block concurrent readers.
- if (listener == null)
- throw new IllegalArgumentException();
- int oldSize = listeners.length;
- for (int i = 0; i < oldSize; ++i) {
- Object listener2 = listeners[i];
- if (identity ? listener == listener2 : listener.equals(listener2)) {
- if (oldSize == 1) {
- listeners = EmptyArray;
- } else {
- // Thread safety: create new array to avoid affecting concurrent readers
- Object[] newListeners = new Object[oldSize - 1];
- System.arraycopy(listeners, 0, newListeners, 0, i);
- System.arraycopy(listeners, i + 1, newListeners, i, oldSize - i - 1);
- //atomic assignment to field
- this.listeners = newListeners;
- }
- return;
- }
- }
- }
-
- /**
- * Returns the number of registered listeners.
- *
- * @return the number of registered listeners
- */
- public int size() {
- return listeners.length;
- }
-
- /**
- * Removes all listeners from this list.
- */
- public synchronized void clear() {
- listeners = EmptyArray;
- }
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/MultiStatus.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/MultiStatus.java
deleted file mode 100644
index 5d8ed507c..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/MultiStatus.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-/**
- * A concrete multi-status implementation,
- * suitable either for instantiating or subclassing.
- */
-public class MultiStatus extends Status {
-
- /** List of child statuses.
- */
- private IStatus[] children;
-
- /**
- * Creates and returns a new multi-status object with the given children.
- *
- * @param pluginId the unique identifier of the relevant plug-in
- * @param code the plug-in-specific status code
- * @param newChildren the list of children status objects
- * @param message a human-readable message, localized to the
- * current locale
- * @param exception a low-level exception, or <code>null</code> if not
- * applicable
- */
- public MultiStatus(String pluginId, int code, IStatus[] newChildren, String message, Throwable exception) {
- this(pluginId, code, message, exception);
- Assert.isLegal(newChildren != null);
- int maxSeverity = getSeverity();
- for (int i = 0; i < newChildren.length; i++) {
- Assert.isLegal(newChildren[i] != null);
- int severity = newChildren[i].getSeverity();
- if (severity > maxSeverity)
- maxSeverity = severity;
- }
- this.children = new IStatus[newChildren.length];
- setSeverity(maxSeverity);
- System.arraycopy(newChildren, 0, this.children, 0, newChildren.length);
- }
-
- /**
- * Creates and returns a new multi-status object with no children.
- *
- * @param pluginId the unique identifier of the relevant plug-in
- * @param code the plug-in-specific status code
- * @param message a human-readable message, localized to the
- * current locale
- * @param exception a low-level exception, or <code>null</code> if not
- * applicable
- */
- public MultiStatus(String pluginId, int code, String message, Throwable exception) {
- super(OK, pluginId, code, message, exception);
- children = new IStatus[0];
- }
-
- /**
- * Adds the given status to this multi-status.
- *
- * @param status the new child status
- */
- public void add(IStatus status) {
- Assert.isLegal(status != null);
- IStatus[] result = new IStatus[children.length + 1];
- System.arraycopy(children, 0, result, 0, children.length);
- result[result.length - 1] = status;
- children = result;
- int newSev = status.getSeverity();
- if (newSev > getSeverity()) {
- setSeverity(newSev);
- }
- }
-
- /**
- * Adds all of the children of the given status to this multi-status.
- * Does nothing if the given status has no children (which includes
- * the case where it is not a multi-status).
- *
- * @param status the status whose children are to be added to this one
- */
- public void addAll(IStatus status) {
- Assert.isLegal(status != null);
- IStatus[] statuses = status.getChildren();
- for (int i = 0; i < statuses.length; i++) {
- add(statuses[i]);
- }
- }
-
- /* (Intentionally not javadoc'd)
- * Implements the corresponding method on <code>IStatus</code>.
- */
- public IStatus[] getChildren() {
- return children;
- }
-
- /* (Intentionally not javadoc'd)
- * Implements the corresponding method on <code>IStatus</code>.
- */
- public boolean isMultiStatus() {
- return true;
- }
-
- /**
- * Merges the given status into this multi-status.
- * Equivalent to <code>add(status)</code> if the
- * given status is not a multi-status.
- * Equivalent to <code>addAll(status)</code> if the
- * given status is a multi-status.
- *
- * @param status the status to merge into this one
- * @see #add(IStatus)
- * @see #addAll(IStatus)
- */
- public void merge(IStatus status) {
- Assert.isLegal(status != null);
- if (!status.isMultiStatus()) {
- add(status);
- } else {
- addAll(status);
- }
- }
-
- /**
- * Returns a string representation of the status, suitable
- * for debugging purposes only.
- */
- public String toString() {
- StringBuffer buf = new StringBuffer(super.toString());
- buf.append(" children=["); //$NON-NLS-1$
- for (int i = 0; i < children.length; i++) {
- if (i != 0) {
- buf.append(" "); //$NON-NLS-1$
- }
- buf.append(children[i].toString());
- }
- buf.append("]"); //$NON-NLS-1$
- return buf.toString();
- }
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/NullProgressMonitor.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/NullProgressMonitor.java
deleted file mode 100644
index 6c54d475a..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/NullProgressMonitor.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-/**
- * A default progress monitor implementation suitable for
- * subclassing.
- * <p>
- * This implementation supports cancelation. The default
- * implementations of the other methods do nothing.
- * </p>
- */
-public class NullProgressMonitor implements IProgressMonitor {
-
- /**
- * Indicates whether cancel has been requested.
- */
- private boolean cancelled = false;
-
- /**
- * Constructs a new progress monitor.
- */
- public NullProgressMonitor() {
- super();
- }
-
- /**
- * This implementation does nothing.
- * Subclasses may override this method to do interesting
- * processing when a task begins.
- *
- * @see IProgressMonitor#beginTask(String, int)
- */
- public void beginTask(String name, int totalWork) {
- // do nothing
- }
-
- /**
- * This implementation does nothing.
- * Subclasses may override this method to do interesting
- * processing when a task is done.
- *
- * @see IProgressMonitor#done()
- */
- public void done() {
- // do nothing
- }
-
- /**
- * This implementation does nothing.
- * Subclasses may override this method.
- *
- * @see IProgressMonitor#internalWorked(double)
- */
- public void internalWorked(double work) {
- // do nothing
- }
-
- /**
- * This implementation returns the value of the internal
- * state variable set by <code>setCanceled</code>.
- * Subclasses which override this method should
- * override <code>setCanceled</code> as well.
- *
- * @see IProgressMonitor#isCanceled()
- * @see IProgressMonitor#setCanceled(boolean)
- */
- public boolean isCanceled() {
- return cancelled;
- }
-
- /**
- * This implementation sets the value of an internal state variable.
- * Subclasses which override this method should override
- * <code>isCanceled</code> as well.
- *
- * @see IProgressMonitor#isCanceled()
- * @see IProgressMonitor#setCanceled(boolean)
- */
- public void setCanceled(boolean cancelled) {
- this.cancelled = cancelled;
- }
-
- /**
- * This implementation does nothing.
- * Subclasses may override this method to do something
- * with the name of the task.
- *
- * @see IProgressMonitor#setTaskName(String)
- */
- public void setTaskName(String name) {
- // do nothing
- }
-
- /**
- * This implementation does nothing.
- * Subclasses may override this method to do interesting
- * processing when a subtask begins.
- *
- * @see IProgressMonitor#subTask(String)
- */
- public void subTask(String name) {
- // do nothing
- }
-
- /**
- * This implementation does nothing.
- * Subclasses may override this method to do interesting
- * processing when some work has been completed.
- *
- * @see IProgressMonitor#worked(int)
- */
- public void worked(int work) {
- // do nothing
- }
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/OperationCanceledException.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/OperationCanceledException.java
deleted file mode 100644
index c0137351b..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/OperationCanceledException.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-/**
- * This exception is thrown to blow out of a long-running method
- * when the user cancels it.
- * <p>
- * This class is not intended to be subclassed by clients but
- * may be instantiated.
- * </p>
- */
-public final class OperationCanceledException extends RuntimeException {
- /**
- * All serializable objects should have a stable serialVersionUID
- */
- private static final long serialVersionUID = 1L;
-
- /**
- * Creates a new exception.
- */
- public OperationCanceledException() {
- super();
- }
-
- /**
- * Creates a new exception with the given message.
- *
- * @param message the message for the exception
- */
- public OperationCanceledException(String message) {
- super(message);
- }
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Path.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Path.java
deleted file mode 100644
index 6eb25cacb..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Path.java
+++ /dev/null
@@ -1,986 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-import java.io.File;
-
-/**
- * The standard implementation of the <code>IPath</code> interface.
- * Paths are always maintained in canonicalized form. That is, parent
- * references (i.e., <code>../../</code>) and duplicate separators are
- * resolved. For example,
- * <pre> new Path("/a/b").append("../foo/bar")</pre>
- * will yield the path
- * <pre> /a/foo/bar</pre>
- * <p>
- * This class is not intended to be subclassed by clients but
- * may be instantiated.
- * </p>
- * @see IPath
- */
-public class Path implements IPath, Cloneable {
- /** masks for separator values */
- private static final int HAS_LEADING = 1;
- private static final int IS_UNC = 2;
- private static final int HAS_TRAILING = 4;
-
- private static final int ALL_SEPARATORS = HAS_LEADING | IS_UNC | HAS_TRAILING;
-
- /** Constant empty string value. */
- private static final String EMPTY_STRING = ""; //$NON-NLS-1$
-
- /** Constant value indicating no segments */
- private static final String[] NO_SEGMENTS = new String[0];
-
- /** Constant value containing the empty path with no device. */
- public static final Path EMPTY = new Path(EMPTY_STRING);
-
- /** Mask for all bits that are involved in the hash code */
- private static final int HASH_MASK = ~HAS_TRAILING;
-
-
- /** Constant root path string (<code>"/"</code>). */
- private static final String ROOT_STRING = "/"; //$NON-NLS-1$
-
- /** Constant value containing the root path with no device. */
- public static final Path ROOT = new Path(ROOT_STRING);
-
- /** Constant value indicating if the current platform is Windows */
- private static final boolean WINDOWS = java.io.File.separatorChar == '\\';
-
- /** The device id string. May be null if there is no device. */
- private String device = null;
-
- //Private implementation note: the segments and separators
- //arrays are never modified, so that they can be shared between
- //path instances
-
- /** The path segments */
- private String[] segments;
-
- /** flags indicating separators (has leading, is UNC, has trailing) */
- private int separators;
-
- /**
- * Constructs a new path from the given string path.
- * The string path must represent a valid file system path
- * on the local file system.
- * The path is canonicalized and double slashes are removed
- * except at the beginning. (to handle UNC paths). All forward
- * slashes ('/') are treated as segment delimiters, and any
- * segment and device delimiters for the local file system are
- * also respected.
- *
- * @param pathString the portable string path
- * @see IPath#toPortableString()
- * @since 3.1
- */
- public static IPath fromOSString(String pathString) {
- return new Path(pathString);
- }
-
- /**
- * Constructs a new path from the given path string.
- * The path string must have been produced by a previous
- * call to <code>IPath.toPortableString</code>.
- *
- * @param pathString the portable path string
- * @see IPath#toPortableString()
- * @since 3.1
- */
- public static IPath fromPortableString(String pathString) {
- int firstMatch = pathString.indexOf(DEVICE_SEPARATOR) +1;
- //no extra work required if no device characters
- if (firstMatch <= 0)
- return new Path().initialize(null, pathString);
- //if we find a single colon, then the path has a device
- String devicePart = null;
- int pathLength = pathString.length();
- if (firstMatch == pathLength || pathString.charAt(firstMatch) != DEVICE_SEPARATOR) {
- devicePart = pathString.substring(0, firstMatch);
- pathString = pathString.substring(firstMatch, pathLength);
- }
- //optimize for no colon literals
- if (pathString.indexOf(DEVICE_SEPARATOR) == -1)
- return new Path().initialize(devicePart, pathString);
- //contract colon literals
- char[] chars = pathString.toCharArray();
- int readOffset = 0, writeOffset = 0, length = chars.length;
- while (readOffset < length) {
- if (chars[readOffset] == DEVICE_SEPARATOR)
- if (++readOffset >= length)
- break;
- chars[writeOffset++] = chars[readOffset++];
- }
- return new Path().initialize(devicePart, new String(chars, 0, writeOffset));
- }
-
- /* (Intentionally not included in javadoc)
- * Private constructor.
- */
- private Path() {
- // not allowed
- }
-
- /**
- * Constructs a new path from the given string path.
- * The string path must represent a valid file system path
- * on the local file system.
- * The path is canonicalized and double slashes are removed
- * except at the beginning. (to handle UNC paths). All forward
- * slashes ('/') are treated as segment delimiters, and any
- * segment and device delimiters for the local file system are
- * also respected (such as colon (':') and backslash ('\') on some file systems).
- *
- * @param fullPath the string path
- * @see #isValidPath(String)
- */
- public Path(String fullPath) {
- String devicePart = null;
- if (WINDOWS) {
- //convert backslash to forward slash
- fullPath = fullPath.indexOf('\\') == -1 ? fullPath : fullPath.replace('\\', SEPARATOR);
- //extract device
- int i = fullPath.indexOf(DEVICE_SEPARATOR);
- if (i != -1) {
- //remove leading slash from device part to handle output of URL.getFile()
- int start = fullPath.charAt(0) == SEPARATOR ? 1 : 0;
- devicePart = fullPath.substring(start, i + 1);
- fullPath = fullPath.substring(i + 1, fullPath.length());
- }
- }
- initialize(devicePart, fullPath);
- }
-
- /**
- * Constructs a new path from the given device id and string path.
- * The given string path must be valid.
- * The path is canonicalized and double slashes are removed except
- * at the beginning (to handle UNC paths). All forward
- * slashes ('/') are treated as segment delimiters, and any
- * segment delimiters for the local file system are
- * also respected (such as backslash ('\') on some file systems).
- *
- * @param device the device id
- * @param path the string path
- * @see #isValidPath(String)
- * @see #setDevice(String)
- */
- public Path(String device, String path) {
- if (WINDOWS) {
- //convert backslash to forward slash
- path = path.indexOf('\\') == -1 ? path : path.replace('\\', SEPARATOR);
- }
- initialize(device, path);
- }
-
- /* (Intentionally not included in javadoc)
- * Private constructor.
- */
- private Path(String device, String[] segments, int _separators) {
- // no segment validations are done for performance reasons
- this.segments = segments;
- this.device = device;
- //hash code is cached in all but the bottom three bits of the separators field
- this.separators = (computeHashCode() << 3) | (_separators & ALL_SEPARATORS);
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#addFileExtension
- */
- public IPath addFileExtension(String extension) {
- if (isRoot() || isEmpty() || hasTrailingSeparator())
- return this;
- int len = segments.length;
- String[] newSegments = new String[len];
- System.arraycopy(segments, 0, newSegments, 0, len - 1);
- newSegments[len - 1] = segments[len - 1] + '.' + extension;
- return new Path(device, newSegments, separators);
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#addTrailingSeparator
- */
- public IPath addTrailingSeparator() {
- if (hasTrailingSeparator() || isRoot()) {
- return this;
- }
- //XXX workaround, see 1GIGQ9V
- if (isEmpty()) {
- return new Path(device, segments, HAS_LEADING);
- }
- return new Path(device, segments, separators | HAS_TRAILING);
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#append(IPath)
- */
- public IPath append(IPath tail) {
- //optimize some easy cases
- if (tail == null || tail.segmentCount() == 0)
- return this;
- if (this.isEmpty())
- return tail.setDevice(device).makeRelative();
- if (this.isRoot())
- return tail.setDevice(device).makeAbsolute();
-
- //concatenate the two segment arrays
- int myLen = segments.length;
- int tailLen = tail.segmentCount();
- String[] newSegments = new String[myLen + tailLen];
- System.arraycopy(segments, 0, newSegments, 0, myLen);
- for (int i = 0; i < tailLen; i++) {
- newSegments[myLen + i] = tail.segment(i);
- }
- //use my leading separators and the tail's trailing separator
- Path result = new Path(device, newSegments, (separators & (HAS_LEADING | IS_UNC)) | (tail.hasTrailingSeparator() ? HAS_TRAILING : 0));
- String tailFirstSegment = newSegments[myLen];
- if (tailFirstSegment.equals("..") || tailFirstSegment.equals(".")) { //$NON-NLS-1$ //$NON-NLS-2$
- result.canonicalize();
- }
- return result;
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#append(java.lang.String)
- */
- public IPath append(String tail) {
- //optimize addition of a single segment
- if (tail.indexOf(SEPARATOR) == -1 && tail.indexOf("\\") == -1 && tail.indexOf(DEVICE_SEPARATOR) == -1) { //$NON-NLS-1$
- int tailLength = tail.length();
- if (tailLength < 3) {
- //some special cases
- if (tailLength == 0 || ".".equals(tail)) { //$NON-NLS-1$
- return this;
- }
- if ("..".equals(tail)) //$NON-NLS-1$
- return removeLastSegments(1);
- }
- //just add the segment
- int myLen = segments.length;
- String[] newSegments = new String[myLen + 1];
- System.arraycopy(segments, 0, newSegments, 0, myLen);
- newSegments[myLen] = tail;
- return new Path(device, newSegments, separators & ~HAS_TRAILING);
- }
- //go with easy implementation
- return append(new Path(tail));
- }
-
- /**
- * Destructively converts this path to its canonical form.
- * <p>
- * In its canonical form, a path does not have any
- * "." segments, and parent references ("..") are collapsed
- * where possible.
- * </p>
- * @return true if the path was modified, and false otherwise.
- */
- private boolean canonicalize() {
- //look for segments that need canonicalizing
- for (int i = 0, max = segments.length; i < max; i++) {
- String segment = segments[i];
- if (segment.charAt(0) == '.' && (segment.equals("..") || segment.equals("."))) { //$NON-NLS-1$ //$NON-NLS-2$
- //path needs to be canonicalized
- collapseParentReferences();
- //paths of length 0 have no trailing separator
- if (segments.length == 0)
- separators &= (HAS_LEADING | IS_UNC);
- //recompute hash because canonicalize affects hash
- separators = (separators & ALL_SEPARATORS) | (computeHashCode() << 3);
- return true;
- }
- }
- return false;
- }
-
- /* (Intentionally not included in javadoc)
- * Clones this object.
- */
- public Object clone() {
- try {
- return super.clone();
- } catch (CloneNotSupportedException e) {
- return null;
- }
- }
-
- /**
- * Destructively removes all occurrences of ".." segments from this path.
- */
- private void collapseParentReferences() {
- int segmentCount = segments.length;
- String[] stack = new String[segmentCount];
- int stackPointer = 0;
- for (int i = 0; i < segmentCount; i++) {
- String segment = segments[i];
- if (segment.equals("..")) { //$NON-NLS-1$
- if (stackPointer == 0) {
- // if the stack is empty we are going out of our scope
- // so we need to accumulate segments. But only if the original
- // path is relative. If it is absolute then we can't go any higher than
- // root so simply toss the .. references.
- if (!isAbsolute())
- stack[stackPointer++] = segment; //stack push
- } else {
- // if the top is '..' then we are accumulating segments so don't pop
- if ("..".equals(stack[stackPointer - 1])) //$NON-NLS-1$
- stack[stackPointer++] = ".."; //$NON-NLS-1$
- else
- stackPointer--;
- //stack pop
- }
- //collapse current references
- } else if (!segment.equals(".") || (i == 0 && !isAbsolute())) //$NON-NLS-1$
- stack[stackPointer++] = segment; //stack push
- }
- //if the number of segments hasn't changed, then no modification needed
- if (stackPointer == segmentCount)
- return;
- //build the new segment array backwards by popping the stack
- String[] newSegments = new String[stackPointer];
- System.arraycopy(stack, 0, newSegments, 0, stackPointer);
- this.segments = newSegments;
- }
-
- /**
- * Removes duplicate slashes from the given path, with the exception
- * of leading double slash which represents a UNC path.
- */
- private String collapseSlashes(String path) {
- int length = path.length();
- // if the path is only 0, 1 or 2 chars long then it could not possibly have illegal
- // duplicate slashes.
- if (length < 3)
- return path;
- // check for an occurrence of // in the path. Start at index 1 to ensure we skip leading UNC //
- // If there are no // then there is nothing to collapse so just return.
- if (path.indexOf("//", 1) == -1) //$NON-NLS-1$
- return path;
- // We found an occurrence of // in the path so do the slow collapse.
- char[] result = new char[path.length()];
- int count = 0;
- boolean hasPrevious = false;
- char[] characters = path.toCharArray();
- for (int index = 0; index < characters.length; index++) {
- char c = characters[index];
- if (c == SEPARATOR) {
- if (hasPrevious) {
- // skip double slashes, except for beginning of UNC.
- // note that a UNC path can't have a device.
- if (device == null && index == 1) {
- result[count] = c;
- count++;
- }
- } else {
- hasPrevious = true;
- result[count] = c;
- count++;
- }
- } else {
- hasPrevious = false;
- result[count] = c;
- count++;
- }
- }
- return new String(result, 0, count);
- }
-
- /* (Intentionally not included in javadoc)
- * Computes the hash code for this object.
- */
- private int computeHashCode() {
- int hash = device == null ? 17 : device.hashCode();
- int segmentCount = segments.length;
- for (int i = 0; i < segmentCount; i++) {
- //this function tends to given a fairly even distribution
- hash = hash * 37 + segments[i].hashCode();
- }
- return hash;
- }
-
- /* (Intentionally not included in javadoc)
- * Returns the size of the string that will be created by toString or toOSString.
- */
- private int computeLength() {
- int length = 0;
- if (device != null)
- length += device.length();
- if ((separators & HAS_LEADING) != 0)
- length++;
- if ((separators & IS_UNC) != 0)
- length++;
- //add the segment lengths
- int max = segments.length;
- if (max > 0) {
- for (int i = 0; i < max; i++) {
- length += segments[i].length();
- }
- //add the separator lengths
- length += max - 1;
- }
- if ((separators & HAS_TRAILING) != 0)
- length++;
- return length;
- }
-
- /* (Intentionally not included in javadoc)
- * Returns the number of segments in the given path
- */
- private int computeSegmentCount(String path) {
- int len = path.length();
- if (len == 0 || (len == 1 && path.charAt(0) == SEPARATOR)) {
- return 0;
- }
- int count = 1;
- int prev = -1;
- int i;
- while ((i = path.indexOf(SEPARATOR, prev + 1)) != -1) {
- if (i != prev + 1 && i != len) {
- ++count;
- }
- prev = i;
- }
- if (path.charAt(len - 1) == SEPARATOR) {
- --count;
- }
- return count;
- }
-
- /**
- * Computes the segment array for the given canonicalized path.
- */
- private String[] computeSegments(String path) {
- // performance sensitive --- avoid creating garbage
- int segmentCount = computeSegmentCount(path);
- if (segmentCount == 0)
- return NO_SEGMENTS;
- String[] newSegments = new String[segmentCount];
- int len = path.length();
- // check for initial slash
- int firstPosition = (path.charAt(0) == SEPARATOR) ? 1 : 0;
- // check for UNC
- if (firstPosition == 1 && len > 1 && (path.charAt(1) == SEPARATOR))
- firstPosition = 2;
- int lastPosition = (path.charAt(len - 1) != SEPARATOR) ? len - 1 : len - 2;
- // for non-empty paths, the number of segments is
- // the number of slashes plus 1, ignoring any leading
- // and trailing slashes
- int next = firstPosition;
- for (int i = 0; i < segmentCount; i++) {
- int start = next;
- int end = path.indexOf(SEPARATOR, next);
- if (end == -1) {
- newSegments[i] = path.substring(start, lastPosition + 1);
- } else {
- newSegments[i] = path.substring(start, end);
- }
- next = end + 1;
- }
- return newSegments;
- }
- /**
- * Returns the platform-neutral encoding of the given segment onto
- * the given string buffer. This escapes literal colon characters with double colons.
- */
- private void encodeSegment(String string, StringBuffer buf) {
- int len = string.length();
- for (int i = 0; i < len; i++) {
- char c = string.charAt(i);
- buf.append(c);
- if (c == DEVICE_SEPARATOR)
- buf.append(DEVICE_SEPARATOR);
- }
- }
-
- /* (Intentionally not included in javadoc)
- * Compares objects for equality.
- */
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (!(obj instanceof Path))
- return false;
- Path target = (Path) obj;
- //check leading separators and hash code
- if ((separators & HASH_MASK) != (target.separators & HASH_MASK))
- return false;
- String[] targetSegments = target.segments;
- int i = segments.length;
- //check segment count
- if (i != targetSegments.length)
- return false;
- //check segments in reverse order - later segments more likely to differ
- while (--i >= 0)
- if (!segments[i].equals(targetSegments[i]))
- return false;
- //check device last (least likely to differ)
- return device == target.device || (device != null && device.equals(target.device));
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#getDevice
- */
- public String getDevice() {
- return device;
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#getFileExtension
- */
- public String getFileExtension() {
- if (hasTrailingSeparator()) {
- return null;
- }
- String lastSegment = lastSegment();
- if (lastSegment == null) {
- return null;
- }
- int index = lastSegment.lastIndexOf('.');
- if (index == -1) {
- return null;
- }
- return lastSegment.substring(index + 1);
- }
-
- /* (Intentionally not included in javadoc)
- * Computes the hash code for this object.
- */
- public int hashCode() {
- return separators & HASH_MASK;
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#hasTrailingSeparator2
- */
- public boolean hasTrailingSeparator() {
- return (separators & HAS_TRAILING) != 0;
- }
-
- /*
- * Initialize the current path with the given string.
- */
- private IPath initialize(String deviceString, String path) {
- Assert.isNotNull(path);
- this.device = deviceString;
-
- path = collapseSlashes(path);
- int len = path.length();
-
- //compute the separators array
- if (len < 2) {
- if (len == 1 && path.charAt(0) == SEPARATOR) {
- this.separators = HAS_LEADING;
- } else {
- this.separators = 0;
- }
- } else {
- boolean hasLeading = path.charAt(0) == SEPARATOR;
- boolean isUNC = hasLeading && path.charAt(1) == SEPARATOR;
- //UNC path of length two has no trailing separator
- boolean hasTrailing = !(isUNC && len == 2) && path.charAt(len - 1) == SEPARATOR;
- separators = hasLeading ? HAS_LEADING : 0;
- if (isUNC)
- separators |= IS_UNC;
- if (hasTrailing)
- separators |= HAS_TRAILING;
- }
- //compute segments and ensure canonical form
- segments = computeSegments(path);
- if (!canonicalize()) {
- //compute hash now because canonicalize didn't need to do it
- separators = (separators & ALL_SEPARATORS) | (computeHashCode() << 3);
- }
- return this;
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#isAbsolute
- */
- public boolean isAbsolute() {
- //it's absolute if it has a leading separator
- return (separators & HAS_LEADING) != 0;
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#isEmpty
- */
- public boolean isEmpty() {
- //true if no segments and no leading prefix
- return segments.length == 0 && ((separators & ALL_SEPARATORS) != HAS_LEADING);
-
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#isPrefixOf
- */
- public boolean isPrefixOf(IPath anotherPath) {
- if (device == null) {
- if (anotherPath.getDevice() != null) {
- return false;
- }
- } else {
- if (!device.equalsIgnoreCase(anotherPath.getDevice())) {
- return false;
- }
- }
- if (isEmpty() || (isRoot() && anotherPath.isAbsolute())) {
- return true;
- }
- int len = segments.length;
- if (len > anotherPath.segmentCount()) {
- return false;
- }
- for (int i = 0; i < len; i++) {
- if (!segments[i].equals(anotherPath.segment(i)))
- return false;
- }
- return true;
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#isRoot
- */
- public boolean isRoot() {
- //must have no segments, a leading separator, and not be a UNC path.
- return this == ROOT || (segments.length == 0 && ((separators & ALL_SEPARATORS) == HAS_LEADING));
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#isUNC
- */
- public boolean isUNC() {
- if (device != null)
- return false;
- return (separators & IS_UNC) != 0;
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#isValidPath(String)
- */
- public boolean isValidPath(String path) {
- Path test = new Path(path);
- for (int i = 0, max = test.segmentCount(); i < max; i++)
- if (!isValidSegment(test.segment(i)))
- return false;
- return true;
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#isValidSegment(String)
- */
- public boolean isValidSegment(String segment) {
- int size = segment.length();
- if (size == 0)
- return false;
- for (int i = 0; i < size; i++) {
- char c = segment.charAt(i);
- if (c == '/')
- return false;
- if (WINDOWS && (c == '\\' || c == ':'))
- return false;
- }
- return true;
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#lastSegment()
- */
- public String lastSegment() {
- int len = segments.length;
- return len == 0 ? null : segments[len - 1];
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#makeAbsolute()
- */
- public IPath makeAbsolute() {
- if (isAbsolute()) {
- return this;
- }
- Path result = new Path(device, segments, separators | HAS_LEADING);
- //may need canonicalizing if it has leading ".." or "." segments
- if (result.segmentCount() > 0) {
- String first = result.segment(0);
- if (first.equals("..") || first.equals(".")) { //$NON-NLS-1$ //$NON-NLS-2$
- result.canonicalize();
- }
- }
- return result;
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#makeRelative()
- */
- public IPath makeRelative() {
- if (!isAbsolute()) {
- return this;
- }
- return new Path(device, segments, separators & HAS_TRAILING);
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#makeUNC(boolean)
- */
- public IPath makeUNC(boolean toUNC) {
- // if we are already in the right form then just return
- if (!(toUNC ^ isUNC()))
- return this;
-
- int newSeparators = this.separators;
- if (toUNC) {
- newSeparators |= HAS_LEADING | IS_UNC;
- } else {
- //mask out the UNC bit
- newSeparators &= HAS_LEADING | HAS_TRAILING;
- }
- return new Path(toUNC ? null : device, segments, newSeparators);
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#matchingFirstSegments(IPath)
- */
- public int matchingFirstSegments(IPath anotherPath) {
- Assert.isNotNull(anotherPath);
- int anotherPathLen = anotherPath.segmentCount();
- int max = Math.min(segments.length, anotherPathLen);
- int count = 0;
- for (int i = 0; i < max; i++) {
- if (!segments[i].equals(anotherPath.segment(i))) {
- return count;
- }
- count++;
- }
- return count;
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#removeFileExtension()
- */
- public IPath removeFileExtension() {
- String extension = getFileExtension();
- if (extension == null || extension.equals("")) { //$NON-NLS-1$
- return this;
- }
- String lastSegment = lastSegment();
- int index = lastSegment.lastIndexOf(extension) - 1;
- return removeLastSegments(1).append(lastSegment.substring(0, index));
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#removeFirstSegments(int)
- */
- public IPath removeFirstSegments(int count) {
- if (count == 0)
- return this;
- if (count >= segments.length) {
- return new Path(device, NO_SEGMENTS, 0);
- }
- Assert.isLegal(count > 0);
- int newSize = segments.length - count;
- String[] newSegments = new String[newSize];
- System.arraycopy(this.segments, count, newSegments, 0, newSize);
-
- //result is always a relative path
- return new Path(device, newSegments, separators & HAS_TRAILING);
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#removeLastSegments(int)
- */
- public IPath removeLastSegments(int count) {
- if (count == 0)
- return this;
- if (count >= segments.length) {
- //result will have no trailing separator
- return new Path(device, NO_SEGMENTS, separators & (HAS_LEADING | IS_UNC));
- }
- Assert.isLegal(count > 0);
- int newSize = segments.length - count;
- String[] newSegments = new String[newSize];
- System.arraycopy(this.segments, 0, newSegments, 0, newSize);
- return new Path(device, newSegments, separators);
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#removeTrailingSeparator()
- */
- public IPath removeTrailingSeparator() {
- if (!hasTrailingSeparator()) {
- return this;
- }
- return new Path(device, segments, separators & (HAS_LEADING | IS_UNC));
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#segment(int)
- */
- public String segment(int index) {
- if (index >= segments.length)
- return null;
- return segments[index];
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#segmentCount()
- */
- public int segmentCount() {
- return segments.length;
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#segments()
- */
- public String[] segments() {
- String[] segmentCopy = new String[segments.length];
- System.arraycopy(segments, 0, segmentCopy, 0, segments.length);
- return segmentCopy;
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#setDevice(String)
- */
- public IPath setDevice(String value) {
- if (value != null) {
- Assert.isTrue(value.indexOf(IPath.DEVICE_SEPARATOR) == (value.length() - 1), "Last character should be the device separator"); //$NON-NLS-1$
- }
- //return the receiver if the device is the same
- if (value == device || (value != null && value.equals(device)))
- return this;
-
- return new Path(value, segments, separators);
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#toFile()
- */
- public File toFile() {
- return new File(toOSString());
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#toOSString()
- */
- public String toOSString() {
- //Note that this method is identical to toString except
- //it uses the OS file separator instead of the path separator
- int resultSize = computeLength();
- if (resultSize <= 0)
- return EMPTY_STRING;
- char FILE_SEPARATOR = File.separatorChar;
- char[] result = new char[resultSize];
- int offset = 0;
- if (device != null) {
- int size = device.length();
- device.getChars(0, size, result, offset);
- offset += size;
- }
- if ((separators & HAS_LEADING) != 0)
- result[offset++] = FILE_SEPARATOR;
- if ((separators & IS_UNC) != 0)
- result[offset++] = FILE_SEPARATOR;
- int len = segments.length - 1;
- if (len >= 0) {
- //append all but the last segment, with separators
- for (int i = 0; i < len; i++) {
- int size = segments[i].length();
- segments[i].getChars(0, size, result, offset);
- offset += size;
- result[offset++] = FILE_SEPARATOR;
- }
- //append the last segment
- int size = segments[len].length();
- segments[len].getChars(0, size, result, offset);
- offset += size;
- }
- if ((separators & HAS_TRAILING) != 0)
- result[offset++] = FILE_SEPARATOR;
- return new String(result);
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#toPortableString()
- */
- public String toPortableString() {
- int resultSize = computeLength();
- if (resultSize <= 0)
- return EMPTY_STRING;
- StringBuffer result = new StringBuffer(resultSize);
- if (device != null)
- result.append(device);
- if ((separators & HAS_LEADING) != 0)
- result.append(SEPARATOR);
- if ((separators & IS_UNC) != 0)
- result.append(SEPARATOR);
- int len = segments.length;
- //append all segments with separators
- for (int i = 0; i < len; i++) {
- if (segments[i].indexOf(DEVICE_SEPARATOR) >= 0)
- encodeSegment(segments[i], result);
- else
- result.append(segments[i]);
- if (i < len-1 || (separators & HAS_TRAILING) != 0)
- result.append(SEPARATOR);
- }
- return result.toString();
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#toString()
- */
- public String toString() {
- int resultSize = computeLength();
- if (resultSize <= 0)
- return EMPTY_STRING;
- char[] result = new char[resultSize];
- int offset = 0;
- if (device != null) {
- int size = device.length();
- device.getChars(0, size, result, offset);
- offset += size;
- }
- if ((separators & HAS_LEADING) != 0)
- result[offset++] = SEPARATOR;
- if ((separators & IS_UNC) != 0)
- result[offset++] = SEPARATOR;
- int len = segments.length - 1;
- if (len >= 0) {
- //append all but the last segment, with separators
- for (int i = 0; i < len; i++) {
- int size = segments[i].length();
- segments[i].getChars(0, size, result, offset);
- offset += size;
- result[offset++] = SEPARATOR;
- }
- //append the last segment
- int size = segments[len].length();
- segments[len].getChars(0, size, result, offset);
- offset += size;
- }
- if ((separators & HAS_TRAILING) != 0)
- result[offset++] = SEPARATOR;
- return new String(result);
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#uptoSegment(int)
- */
- public IPath uptoSegment(int count) {
- if (count == 0)
- return new Path(device, NO_SEGMENTS, separators & (HAS_LEADING | IS_UNC));
- if (count >= segments.length)
- return this;
- Assert.isTrue(count > 0, "Invalid parameter to Path.uptoSegment"); //$NON-NLS-1$
- String[] newSegments = new String[count];
- System.arraycopy(segments, 0, newSegments, 0, count);
- return new Path(device, newSegments, separators);
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/PlatformObject.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/PlatformObject.java
deleted file mode 100644
index 5b2e5c872..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/PlatformObject.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-import org.eclipse.core.internal.runtime.AdapterManager;
-
-/**
- * An abstract superclass implementing the <code>IAdaptable</code>
- * interface. <code>getAdapter</code> invocations are directed
- * to the platform's adapter manager.
- * <p>
- * Note: In situations where it would be awkward to subclass this
- * class, the same affect can be achieved simply by implementing
- * the <code>IAdaptable</code> interface and explicitly forwarding
- * the <code>getAdapter</code> request to the platform's
- * adapter manager. The method would look like:
- * <pre>
- * public Object getAdapter(Class adapter) {
- * return Platform.getAdapterManager().getAdapter(this, adapter);
- * }
- * </pre>
- * </p>
- * <p>
- * Clients may subclass.
- * </p>
- *
- * @see Platform#getAdapterManager()
- * @see IAdaptable
- */
-public abstract class PlatformObject implements IAdaptable {
- /**
- * Constructs a new platform object.
- */
- public PlatformObject() {
- super();
- }
-
- /**
- * Returns an object which is an instance of the given class
- * associated with this object. Returns <code>null</code> if
- * no such object can be found.
- * <p>
- * This implementation of the method declared by <code>IAdaptable</code>
- * passes the request along to the platform's adapter manager; roughly
- * <code>Platform.getAdapterManager().getAdapter(this, adapter)</code>.
- * Subclasses may override this method (however, if they do so, they
- * should invoke the method on their superclass to ensure that the
- * Platform's adapter manager is consulted).
- * </p>
- *
- * @param adapter the class to adapt to
- * @return the adapted object or <code>null</code>
- * @see IAdaptable#getAdapter(Class)
- * @see Platform#getAdapterManager()
- */
- public Object getAdapter(Class adapter) {
- return AdapterManager.getDefault().getAdapter(this, adapter);
- }
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/PluginVersionIdentifier.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/PluginVersionIdentifier.java
deleted file mode 100644
index c8861e257..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/PluginVersionIdentifier.java
+++ /dev/null
@@ -1,455 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-import java.util.StringTokenizer;
-import java.util.Vector;
-import org.eclipse.core.internal.runtime.CommonMessages;
-import org.eclipse.core.internal.runtime.IRuntimeConstants;
-import org.eclipse.osgi.util.NLS;
-import org.osgi.framework.Version;
-
-/**
- * <p>
- * Version identifier for a plug-in. In its string representation,
- * it consists of up to 4 tokens separated by a decimal point.
- * The first 3 tokens are positive integer numbers, the last token
- * is an uninterpreted string (no whitespace characters allowed).
- * For example, the following are valid version identifiers
- * (as strings):
- * <ul>
- * <li><code>0.0.0</code></li>
- * <li><code>1.0.127564</code></li>
- * <li><code>3.7.2.build-127J</code></li>
- * <li><code>1.9</code> (interpreted as <code>1.9.0</code>)</li>
- * <li><code>3</code> (interpreted as <code>3.0.0</code>)</li>
- * </ul>
- * </p>
- * <p>
- * The version identifier can be decomposed into a major, minor,
- * service level component and qualifier components. A difference
- * in the major component is interpreted as an incompatible version
- * change. A difference in the minor (and not the major) component
- * is interpreted as a compatible version change. The service
- * level component is interpreted as a cumulative and compatible
- * service update of the minor version component. The qualifier is
- * not interpreted, other than in version comparisons. The
- * qualifiers are compared using lexicographical string comparison.
- * </p>
- * <p>
- * Version identifiers can be matched as perfectly equal, equivalent,
- * compatible or greaterOrEqual.
- * </p>
- * <p>
- * Clients may instantiate; not intended to be subclassed by clients.
- * </p>
- * @see java.lang.String#compareTo(java.lang.String)
- */
-
-// XXX consider deprecating in favour of org.osgi.framework.Version.
-// if deprecated then move this class to the compatibility plugin.
-public final class PluginVersionIdentifier {
-
- private Version version;
-
- private static final String SEPARATOR = "."; //$NON-NLS-1$
-
- /**
- * Creates a plug-in version identifier from its components.
- *
- * @param major major component of the version identifier
- * @param minor minor component of the version identifier
- * @param service service update component of the version identifier
- */
- public PluginVersionIdentifier(int major, int minor, int service) {
- this(major, minor, service, null);
- }
-
- /**
- * Creates a plug-in version identifier from its components.
- *
- * @param major major component of the version identifier
- * @param minor minor component of the version identifier
- * @param service service update component of the version identifier
- * @param qualifier qualifier component of the version identifier.
- * Qualifier characters that are not a letter or a digit are replaced.
- */
- public PluginVersionIdentifier(int major, int minor, int service, String qualifier) {
- // Do the test outside of the assert so that they 'Policy.bind'
- // will not be evaluated each time (including cases when we would
- // have passed by the assert).
-
- if (major < 0)
- Assert.isTrue(false, NLS.bind(CommonMessages.parse_postiveMajor, major + SEPARATOR + minor + SEPARATOR + service + SEPARATOR + qualifier));
- if (minor < 0)
- Assert.isTrue(false, NLS.bind(CommonMessages.parse_postiveMinor, major + SEPARATOR + minor + SEPARATOR + service + SEPARATOR + qualifier));
- if (service < 0)
- Assert.isTrue(false, NLS.bind(CommonMessages.parse_postiveService, major + SEPARATOR + minor + SEPARATOR + service + SEPARATOR + qualifier));
-
- this.version = new Version(major, minor, service, qualifier);
- }
-
- /**
- * Creates a plug-in version identifier from the given string.
- * The string representation consists of up to 4 tokens
- * separated by decimal point.
- * For example, the following are valid version identifiers
- * (as strings):
- * <ul>
- * <li><code>0.0.0</code></li>
- * <li><code>1.0.127564</code></li>
- * <li><code>3.7.2.build-127J</code></li>
- * <li><code>1.9</code> (interpreted as <code>1.9.0</code>)</li>
- * <li><code>3</code> (interpreted as <code>3.0.0</code>)</li>
- * </ul>
- * </p>
- *
- * @param versionId string representation of the version identifier.
- * Qualifier characters that are not a letter or a digit are replaced.
- */
- public PluginVersionIdentifier(String versionId) {
- Object[] parts = parseVersion(versionId);
- version = new Version(((Integer) parts[0]).intValue(), ((Integer) parts[1]).intValue(), ((Integer) parts[2]).intValue(), (String) parts[3]);
- }
-
- /**
- * Validates the given string as a plug-in version identifier.
- *
- * @param version the string to validate
- * @return a status object with code <code>IStatus.OK</code> if
- * the given string is valid as a plug-in version identifier, otherwise a status
- * object indicating what is wrong with the string
- * @since 2.0
- */
- public static IStatus validateVersion(String version) {
- try {
- parseVersion(version);
- } catch (RuntimeException e) {
- return new Status(IStatus.ERROR, IRuntimeConstants.PI_RUNTIME, IStatus.ERROR, e.getMessage(), e);
- }
- return Status.OK_STATUS;
- }
-
- private static Object[] parseVersion(String versionId) {
-
- // Do the test outside of the assert so that they 'Policy.bind'
- // will not be evaluated each time (including cases when we would
- // have passed by the assert).
- if (versionId == null)
- Assert.isNotNull(null, CommonMessages.parse_emptyPluginVersion);
- String s = versionId.trim();
- if (s.equals("")) //$NON-NLS-1$
- Assert.isTrue(false, CommonMessages.parse_emptyPluginVersion);
- if (s.startsWith(SEPARATOR))
- Assert.isTrue(false, NLS.bind(CommonMessages.parse_separatorStartVersion, s));
- if (s.endsWith(SEPARATOR))
- Assert.isTrue(false, NLS.bind(CommonMessages.parse_separatorEndVersion, s));
- if (s.indexOf(SEPARATOR + SEPARATOR) != -1)
- Assert.isTrue(false, NLS.bind(CommonMessages.parse_doubleSeparatorVersion, s));
-
- StringTokenizer st = new StringTokenizer(s, SEPARATOR);
- Vector elements = new Vector(4);
-
- while (st.hasMoreTokens())
- elements.addElement(st.nextToken());
-
- int elementSize = elements.size();
-
- if (elementSize <= 0)
- Assert.isTrue(false, NLS.bind(CommonMessages.parse_oneElementPluginVersion, s));
- if (elementSize > 4)
- Assert.isTrue(false, NLS.bind(CommonMessages.parse_fourElementPluginVersion, s));
-
- int[] numbers = new int[3];
- try {
- numbers[0] = Integer.parseInt((String) elements.elementAt(0));
- if (numbers[0] < 0)
- Assert.isTrue(false, NLS.bind(CommonMessages.parse_postiveMajor, s));
- } catch (NumberFormatException nfe) {
- Assert.isTrue(false, NLS.bind(CommonMessages.parse_numericMajorComponent, s));
- }
-
- try {
- if (elementSize >= 2) {
- numbers[1] = Integer.parseInt((String) elements.elementAt(1));
- if (numbers[1] < 0)
- Assert.isTrue(false, NLS.bind(CommonMessages.parse_postiveMinor, s));
- } else
- numbers[1] = 0;
- } catch (NumberFormatException nfe) {
- Assert.isTrue(false, NLS.bind(CommonMessages.parse_numericMinorComponent, s));
- }
-
- try {
- if (elementSize >= 3) {
- numbers[2] = Integer.parseInt((String) elements.elementAt(2));
- if (numbers[2] < 0)
- Assert.isTrue(false, NLS.bind(CommonMessages.parse_postiveService, s));
- } else
- numbers[2] = 0;
- } catch (NumberFormatException nfe) {
- Assert.isTrue(false, NLS.bind(CommonMessages.parse_numericServiceComponent, s));
- }
-
- // "result" is a 4-element array with the major, minor, service, and qualifier
- Object[] result = new Object[4];
- result[0] = new Integer(numbers[0]);
- result[1] = new Integer(numbers[1]);
- result[2] = new Integer(numbers[2]);
- if (elementSize >= 4)
- result[3] = (String) elements.elementAt(3);
- else
- result[3] = ""; //$NON-NLS-1$
- return result;
- }
-
- /**
- * Compare version identifiers for equality. Identifiers are
- * equal if all of their components are equal.
- *
- * @param object an object to compare
- * @return whether or not the two objects are equal
- */
- public boolean equals(Object object) {
- if (!(object instanceof PluginVersionIdentifier))
- return false;
- PluginVersionIdentifier v = (PluginVersionIdentifier) object;
- return version.equals(v.version);
- }
-
- /**
- * Returns a hash code value for the object.
- *
- * @return an integer which is a hash code value for this object.
- */
- public int hashCode() {
- return version.hashCode();
- }
-
- /**
- * Returns the major (incompatible) component of this
- * version identifier.
- *
- * @return the major version
- */
- public int getMajorComponent() {
- return version.getMajor();
- }
-
- /**
- * Returns the minor (compatible) component of this
- * version identifier.
- *
- * @return the minor version
- */
- public int getMinorComponent() {
- return version.getMinor();
- }
-
- /**
- * Returns the service level component of this
- * version identifier.
- *
- * @return the service level
- */
- public int getServiceComponent() {
- return version.getMicro();
- }
-
- /**
- * Returns the qualifier component of this
- * version identifier.
- *
- * @return the qualifier
- */
- public String getQualifierComponent() {
- return version.getQualifier();
- }
-
- /**
- * Compares two version identifiers to see if this one is
- * greater than or equal to the argument.
- * <p>
- * A version identifier is considered to be greater than or equal
- * if its major component is greater than the argument major
- * component, or the major components are equal and its minor component
- * is greater than the argument minor component, or the
- * major and minor components are equal and its service component is
- * greater than the argument service component, or the major, minor and
- * service components are equal and the qualifier component is
- * greater than the argument qualifier component (using lexicographic
- * string comparison), or all components are equal.
- * </p>
- *
- * @param id the other version identifier
- * @return <code>true</code> is this version identifier
- * is compatible with the given version identifier, and
- * <code>false</code> otherwise
- * @since 2.0
- */
- public boolean isGreaterOrEqualTo(PluginVersionIdentifier id) {
- if (id == null)
- return false;
- if (getMajorComponent() > id.getMajorComponent())
- return true;
- if ((getMajorComponent() == id.getMajorComponent()) && (getMinorComponent() > id.getMinorComponent()))
- return true;
- if ((getMajorComponent() == id.getMajorComponent()) && (getMinorComponent() == id.getMinorComponent()) && (getServiceComponent() > id.getServiceComponent()))
- return true;
- if ((getMajorComponent() == id.getMajorComponent()) && (getMinorComponent() == id.getMinorComponent()) && (getServiceComponent() == id.getServiceComponent()) && (getQualifierComponent().compareTo(id.getQualifierComponent()) >= 0))
- return true;
- else
- return false;
- }
-
- /**
- * Compares two version identifiers for compatibility.
- * <p>
- * A version identifier is considered to be compatible if its major
- * component equals to the argument major component, and its minor component
- * is greater than or equal to the argument minor component.
- * If the minor components are equal, than the service level of the
- * version identifier must be greater than or equal to the service level
- * of the argument identifier. If the service levels are equal, the two
- * version identifiers are considered to be equivalent if this qualifier is
- * greater or equal to the qualifier of the argument (using lexicographic
- * string comparison).
- * </p>
- *
- * @param id the other version identifier
- * @return <code>true</code> is this version identifier
- * is compatible with the given version identifier, and
- * <code>false</code> otherwise
- */
- public boolean isCompatibleWith(PluginVersionIdentifier id) {
- if (id == null)
- return false;
- if (getMajorComponent() != id.getMajorComponent())
- return false;
- if (getMinorComponent() > id.getMinorComponent())
- return true;
- if (getMinorComponent() < id.getMinorComponent())
- return false;
- if (getServiceComponent() > id.getServiceComponent())
- return true;
- if (getServiceComponent() < id.getServiceComponent())
- return false;
- if (getQualifierComponent().compareTo(id.getQualifierComponent()) >= 0)
- return true;
- else
- return false;
- }
-
- /**
- * Compares two version identifiers for equivalency.
- * <p>
- * Two version identifiers are considered to be equivalent if their major
- * and minor component equal and are at least at the same service level
- * as the argument. If the service levels are equal, the two version
- * identifiers are considered to be equivalent if this qualifier is
- * greater or equal to the qualifier of the argument (using lexicographic
- * string comparison).
- *
- * </p>
- *
- * @param id the other version identifier
- * @return <code>true</code> is this version identifier
- * is equivalent to the given version identifier, and
- * <code>false</code> otherwise
- */
- public boolean isEquivalentTo(PluginVersionIdentifier id) {
- if (id == null)
- return false;
- if (getMajorComponent() != id.getMajorComponent())
- return false;
- if (getMinorComponent() != id.getMinorComponent())
- return false;
- if (getServiceComponent() > id.getServiceComponent())
- return true;
- if (getServiceComponent() < id.getServiceComponent())
- return false;
- if (getQualifierComponent().compareTo(id.getQualifierComponent()) >= 0)
- return true;
- else
- return false;
- }
-
- /**
- * Compares two version identifiers for perfect equality.
- * <p>
- * Two version identifiers are considered to be perfectly equal if their
- * major, minor, service and qualifier components are equal
- * </p>
- *
- * @param id the other version identifier
- * @return <code>true</code> is this version identifier
- * is perfectly equal to the given version identifier, and
- * <code>false</code> otherwise
- * @since 2.0
- */
- public boolean isPerfect(PluginVersionIdentifier id) {
- if (id == null)
- return false;
- if ((getMajorComponent() != id.getMajorComponent()) || (getMinorComponent() != id.getMinorComponent()) || (getServiceComponent() != id.getServiceComponent()) || (!getQualifierComponent().equals(id.getQualifierComponent())))
- return false;
- else
- return true;
- }
-
- /**
- * Compares two version identifiers for order using multi-decimal
- * comparison.
- *
- * @param id the other version identifier
- * @return <code>true</code> is this version identifier
- * is greater than the given version identifier, and
- * <code>false</code> otherwise
- */
- public boolean isGreaterThan(PluginVersionIdentifier id) {
-
- if (id == null) {
- if (getMajorComponent() == 0 && getMinorComponent() == 0 && getServiceComponent() == 0 && getQualifierComponent().equals("")) //$NON-NLS-1$
- return false;
- else
- return true;
- }
-
- if (getMajorComponent() > id.getMajorComponent())
- return true;
- if (getMajorComponent() < id.getMajorComponent())
- return false;
- if (getMinorComponent() > id.getMinorComponent())
- return true;
- if (getMinorComponent() < id.getMinorComponent())
- return false;
- if (getServiceComponent() > id.getServiceComponent())
- return true;
- if (getServiceComponent() < id.getServiceComponent())
- return false;
- if (getQualifierComponent().compareTo(id.getQualifierComponent()) > 0)
- return true;
- else
- return false;
-
- }
-
- /**
- * Returns the string representation of this version identifier.
- * The result satisfies
- * <code>vi.equals(new PluginVersionIdentifier(vi.toString()))</code>.
- *
- * @return the string representation of this plug-in version identifier
- */
- public String toString() {
- return version.toString();
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ProgressMonitorWrapper.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ProgressMonitorWrapper.java
deleted file mode 100644
index 5b7117c61..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ProgressMonitorWrapper.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-/**
- * An abstract wrapper around a progress monitor which,
- * unless overridden, forwards <code>IProgressMonitor</code>
- * and <code>IProgressMonitorWithBlocking</code> methods to the wrapped progress monitor.
- * <p>
- * Clients may subclass.
- * </p>
- */
-public abstract class ProgressMonitorWrapper implements IProgressMonitor, IProgressMonitorWithBlocking {
-
- /** The wrapped progress monitor. */
- private IProgressMonitor progressMonitor;
-
- /**
- * Creates a new wrapper around the given monitor.
- *
- * @param monitor the progress monitor to forward to
- */
- protected ProgressMonitorWrapper(IProgressMonitor monitor) {
- Assert.isNotNull(monitor);
- progressMonitor = monitor;
- }
-
- /**
- * This implementation of a <code>IProgressMonitor</code>
- * method forwards to the wrapped progress monitor.
- * Clients may override this method to do additional
- * processing.
- *
- * @see IProgressMonitor#beginTask(String, int)
- */
- public void beginTask(String name, int totalWork) {
- progressMonitor.beginTask(name, totalWork);
- }
-
- /**
- * This implementation of a <code>IProgressMonitorWithBlocking</code>
- * method forwards to the wrapped progress monitor.
- * Clients may override this method to do additional
- * processing.
- *
- * @see IProgressMonitorWithBlocking#clearBlocked()
- * @since 3.0
- */
- public void clearBlocked() {
- if (progressMonitor instanceof IProgressMonitorWithBlocking)
- ((IProgressMonitorWithBlocking) progressMonitor).clearBlocked();
- }
-
- /**
- * This implementation of a <code>IProgressMonitor</code>
- * method forwards to the wrapped progress monitor.
- * Clients may override this method to do additional
- * processing.
- *
- * @see IProgressMonitor#done()
- */
- public void done() {
- progressMonitor.done();
- }
-
- /**
- * Returns the wrapped progress monitor.
- *
- * @return the wrapped progress monitor
- */
- public IProgressMonitor getWrappedProgressMonitor() {
- return progressMonitor;
- }
-
- /**
- * This implementation of a <code>IProgressMonitor</code>
- * method forwards to the wrapped progress monitor.
- * Clients may override this method to do additional
- * processing.
- *
- * @see IProgressMonitor#internalWorked(double)
- */
- public void internalWorked(double work) {
- progressMonitor.internalWorked(work);
- }
-
- /**
- * This implementation of a <code>IProgressMonitor</code>
- * method forwards to the wrapped progress monitor.
- * Clients may override this method to do additional
- * processing.
- *
- * @see IProgressMonitor#isCanceled()
- */
- public boolean isCanceled() {
- return progressMonitor.isCanceled();
- }
-
- /**
- * This implementation of a <code>IProgressMonitorWithBlocking</code>
- * method forwards to the wrapped progress monitor.
- * Clients may override this method to do additional
- * processing.
- *
- * @see IProgressMonitorWithBlocking#setBlocked(IStatus)
- * @since 3.0
- */
- public void setBlocked(IStatus reason) {
- if (progressMonitor instanceof IProgressMonitorWithBlocking)
- ((IProgressMonitorWithBlocking) progressMonitor).setBlocked(reason);
- }
-
- /**
- * This implementation of a <code>IProgressMonitor</code>
- * method forwards to the wrapped progress monitor.
- * Clients may override this method to do additional
- * processing.
- *
- * @see IProgressMonitor#setCanceled(boolean)
- */
- public void setCanceled(boolean b) {
- progressMonitor.setCanceled(b);
- }
-
- /**
- * This implementation of a <code>IProgressMonitor</code>
- * method forwards to the wrapped progress monitor.
- * Clients may override this method to do additional
- * processing.
- *
- * @see IProgressMonitor#setTaskName(String)
- */
- public void setTaskName(String name) {
- progressMonitor.setTaskName(name);
- }
-
- /**
- * This implementation of a <code>IProgressMonitor</code>
- * method forwards to the wrapped progress monitor.
- * Clients may override this method to do additional
- * processing.
- *
- * @see IProgressMonitor#subTask(String)
- */
- public void subTask(String name) {
- progressMonitor.subTask(name);
- }
-
- /**
- * This implementation of a <code>IProgressMonitor</code>
- * method forwards to the wrapped progress monitor.
- * Clients may override this method to do additional
- * processing.
- *
- * @see IProgressMonitor#worked(int)
- */
- public void worked(int work) {
- progressMonitor.worked(work);
- }
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/QualifiedName.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/QualifiedName.java
deleted file mode 100644
index 893faa797..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/QualifiedName.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-/**
- * Qualified names are two-part names: qualifier and local name.
- * The qualifier must be in URI form (see RFC2396).
- * Note however that the qualifier may be <code>null</code> if
- * the default name space is being used. The empty string is not
- * a valid local name.
- * <p>
- * This class is not intended to be subclassed by clients.
- * </p>
- */
-public final class QualifiedName {
-
- /** Qualifier part (potentially <code>null</code>). */
- /*package*/
- String qualifier = null;
-
- /** Local name part. */
- /*package*/
- String localName = null;
-
- /**
- * Creates and returns a new qualified name with the given qualifier
- * and local name. The local name must not be the empty string.
- * The qualifier may be <code>null</code>.
- * <p>
- * Clients may instantiate.
- * </p>
- * @param qualifier the qualifier string, or <code>null</code>
- * @param localName the local name string
- */
- public QualifiedName(String qualifier, String localName) {
- Assert.isLegal(localName != null && localName.length() != 0);
- this.qualifier = qualifier;
- this.localName = localName;
- }
-
- /**
- * Returns whether this qualified name is equivalent to the given object.
- * <p>
- * Qualified names are equal if and only if they have the same
- * qualified parts and local parts.
- * Qualified names are not equal to objects other than qualified names.
- * </p>
- *
- * @param obj the object to compare to
- * @return <code>true</code> if these are equivalent qualified
- * names, and <code>false</code> otherwise
- */
- public boolean equals(Object obj) {
- if (obj == this) {
- return true;
- }
- if (!(obj instanceof QualifiedName)) {
- return false;
- }
- QualifiedName qName = (QualifiedName) obj;
- /* There may or may not be a qualifier */
- if (qualifier == null && qName.getQualifier() != null) {
- return false;
- }
- if (qualifier != null && !qualifier.equals(qName.getQualifier())) {
- return false;
- }
- return localName.equals(qName.getLocalName());
- }
-
- /**
- * Returns the local part of this name.
- *
- * @return the local name string
- */
- public String getLocalName() {
- return localName;
- }
-
- /**
- * Returns the qualifier part for this qualified name, or <code>null</code>
- * if none.
- *
- * @return the qualifier string, or <code>null</code>
- */
- public String getQualifier() {
- return qualifier;
- }
-
- /* (Intentionally omitted from javadoc)
- * Implements the method <code>Object.hashCode</code>.
- *
- * Returns the hash code for this qualified name.
- */
- public int hashCode() {
- return (qualifier == null ? 0 : qualifier.hashCode()) + localName.hashCode();
- }
-
- /**
- * Converts this qualified name into a string, suitable for
- * debug purposes only.
- */
- public String toString() {
- return (getQualifier() == null ? "" : getQualifier() + ':') + getLocalName(); //$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/SafeRunner.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/SafeRunner.java
deleted file mode 100644
index 90f9db308..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/SafeRunner.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-import org.eclipse.core.internal.runtime.*;
-import org.eclipse.osgi.util.NLS;
-
-/**
- * Runs the given ISafeRunnable in a protected mode: exceptions
- * thrown in the runnable are logged and passed to the runnable's
- * exception handler. Such exceptions are not rethrown by this method.
- *
- * Note that this class requires presence of OSGi.
- *
- * @since org.eclipse.equinox.common 1.0
- */
-public final class SafeRunner {
-
- /**
- * Runs the given runnable in a protected mode. Exceptions
- * thrown in the runnable are logged and passed to the runnable's
- * exception handler. Such exceptions are not rethrown by this method.
- *
- * @param code the runnable to run
- */
- public static void run(ISafeRunnable code) {
- Assert.isNotNull(code);
- try {
- code.run();
- } catch (Exception e) {
- handleException(code, e);
- } catch (LinkageError e) {
- handleException(code, e);
- }
- }
-
- private static void handleException(ISafeRunnable code, Throwable e) {
- if (!(e instanceof OperationCanceledException)) {
- // try to obtain the correct plug-in id for the bundle providing the safe runnable
- String pluginId = CommonOSGiUtils.getDefault().getBundleId(code);
- if (pluginId == null)
- pluginId = IRuntimeConstants.NAME;
- String message = NLS.bind(CommonMessages.meta_pluginProblems, pluginId);
- IStatus status;
- if (e instanceof CoreException) {
- status = new MultiStatus(pluginId, IRuntimeConstants.PLUGIN_ERROR, message, e);
- ((MultiStatus) status).merge(((CoreException) e).getStatus());
- } else {
- status = new Status(IStatus.ERROR, pluginId, IRuntimeConstants.PLUGIN_ERROR, message, e);
- }
- // Make sure user sees the exception: if the log is empty, log the exceptions on stderr
- if (!RuntimeLog.isEmpty())
- RuntimeLog.log(status);
- else
- e.printStackTrace();
- }
- code.handleException(e);
- }
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Status.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Status.java
deleted file mode 100644
index 70a36422e..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Status.java
+++ /dev/null
@@ -1,231 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-import org.eclipse.core.internal.runtime.CommonMessages;
-import org.eclipse.core.internal.runtime.IRuntimeConstants;
-
-/**
- * A concrete status implementation, suitable either for
- * instantiating or subclassing.
- */
-public class Status implements IStatus {
-
- /**
- * A standard OK status with an "ok" message.
- *
- * @since 3.0
- */
- public static final IStatus OK_STATUS = new Status(OK, IRuntimeConstants.PI_RUNTIME, OK, CommonMessages.ok, null);
- /**
- * A standard CANCEL status with no message.
- *
- * @since 3.0
- */
- public static final IStatus CANCEL_STATUS = new Status(CANCEL, IRuntimeConstants.PI_RUNTIME, 1, "", null); //$NON-NLS-1$
- /**
- * The severity. One of
- * <ul>
- * <li><code>CANCEL</code></li>
- * <li><code>ERROR</code></li>
- * <li><code>WARNING</code></li>
- * <li><code>INFO</code></li>
- * <li>or <code>OK</code> (0)</li>
- * </ul>
- */
- private int severity = OK;
-
- /** Unique identifier of plug-in.
- */
- private String pluginId;
-
- /** Plug-in-specific status code.
- */
- private int code;
-
- /** Message, localized to the current locale.
- */
- private String message;
-
- /** Wrapped exception, or <code>null</code> if none.
- */
- private Throwable exception = null;
-
- /** Constant to avoid generating garbage.
- */
- private static final IStatus[] theEmptyStatusArray = new IStatus[0];
-
- /**
- * Creates a new status object. The created status has no children.
- *
- * @param severity the severity; one of <code>OK</code>, <code>ERROR</code>,
- * <code>INFO</code>, <code>WARNING</code>, or <code>CANCEL</code>
- * @param pluginId the unique identifier of the relevant plug-in
- * @param code the plug-in-specific status code, or <code>OK</code>
- * @param message a human-readable message, localized to the
- * current locale
- * @param exception a low-level exception, or <code>null</code> if not
- * applicable
- */
- public Status(int severity, String pluginId, int code, String message, Throwable exception) {
- setSeverity(severity);
- setPlugin(pluginId);
- setCode(code);
- setMessage(message);
- setException(exception);
- }
-
- /* (Intentionally not javadoc'd)
- * Implements the corresponding method on <code>IStatus</code>.
- */
- public IStatus[] getChildren() {
- return theEmptyStatusArray;
- }
-
- /* (Intentionally not javadoc'd)
- * Implements the corresponding method on <code>IStatus</code>.
- */
- public int getCode() {
- return code;
- }
-
- /* (Intentionally not javadoc'd)
- * Implements the corresponding method on <code>IStatus</code>.
- */
- public Throwable getException() {
- return exception;
- }
-
- /* (Intentionally not javadoc'd)
- * Implements the corresponding method on <code>IStatus</code>.
- */
- public String getMessage() {
- return message;
- }
-
- /* (Intentionally not javadoc'd)
- * Implements the corresponding method on <code>IStatus</code>.
- */
- public String getPlugin() {
- return pluginId;
- }
-
- /* (Intentionally not javadoc'd)
- * Implements the corresponding method on <code>IStatus</code>.
- */
- public int getSeverity() {
- return severity;
- }
-
- /* (Intentionally not javadoc'd)
- * Implements the corresponding method on <code>IStatus</code>.
- */
- public boolean isMultiStatus() {
- return false;
- }
-
- /* (Intentionally not javadoc'd)
- * Implements the corresponding method on <code>IStatus</code>.
- */
- public boolean isOK() {
- return severity == OK;
- }
-
- /* (Intentionally not javadoc'd)
- * Implements the corresponding method on <code>IStatus</code>.
- */
- public boolean matches(int severityMask) {
- return (severity & severityMask) != 0;
- }
-
- /**
- * Sets the status code.
- *
- * @param code the plug-in-specific status code, or <code>OK</code>
- */
- protected void setCode(int code) {
- this.code = code;
- }
-
- /**
- * Sets the exception.
- *
- * @param exception a low-level exception, or <code>null</code> if not
- * applicable
- */
- protected void setException(Throwable exception) {
- this.exception = exception;
- }
-
- /**
- * Sets the message.
- *
- * @param message a human-readable message, localized to the
- * current locale
- */
- protected void setMessage(String message) {
- Assert.isLegal(message != null);
- this.message = message;
- }
-
- /**
- * Sets the plug-in id.
- *
- * @param pluginId the unique identifier of the relevant plug-in
- */
- protected void setPlugin(String pluginId) {
- Assert.isLegal(pluginId != null && pluginId.length() > 0);
- this.pluginId = pluginId;
- }
-
- /**
- * Sets the severity.
- *
- * @param severity the severity; one of <code>OK</code>, <code>ERROR</code>,
- * <code>INFO</code>, <code>WARNING</code>, or <code>CANCEL</code>
- */
- protected void setSeverity(int severity) {
- Assert.isLegal(severity == OK || severity == ERROR || severity == WARNING || severity == INFO || severity == CANCEL);
- this.severity = severity;
- }
-
- /**
- * Returns a string representation of the status, suitable
- * for debugging purposes only.
- */
- public String toString() {
- StringBuffer buf = new StringBuffer();
- buf.append("Status "); //$NON-NLS-1$
- if (severity == OK) {
- buf.append("OK"); //$NON-NLS-1$
- } else if (severity == ERROR) {
- buf.append("ERROR"); //$NON-NLS-1$
- } else if (severity == WARNING) {
- buf.append("WARNING"); //$NON-NLS-1$
- } else if (severity == INFO) {
- buf.append("INFO"); //$NON-NLS-1$
- } else if (severity == CANCEL) {
- buf.append("CANCEL"); //$NON-NLS-1$
- } else {
- buf.append("severity="); //$NON-NLS-1$
- buf.append(severity);
- }
- buf.append(": "); //$NON-NLS-1$
- buf.append(pluginId);
- buf.append(" code="); //$NON-NLS-1$
- buf.append(code);
- buf.append(' ');
- buf.append(message);
- buf.append(' ');
- buf.append(exception);
- return buf.toString();
- }
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/SubProgressMonitor.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/SubProgressMonitor.java
deleted file mode 100644
index 425771005..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/SubProgressMonitor.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-/**
- * A progress monitor that uses a given amount of work ticks
- * from a parent monitor. It can be used as follows:
- * <pre>
- * try {
- * pm.beginTask("Main Task", 100);
- * doSomeWork(pm, 30);
- * SubProgressMonitor subMonitor= new SubProgressMonitor(pm, 40);
- * try {
- * subMonitor.beginTask("", 300);
- * doSomeWork(subMonitor, 300);
- * } finally {
- * subMonitor.done();
- * }
- * doSomeWork(pm, 30);
- * } finally {
- * pm.done();
- * }
- * </pre>
- * <p>
- * This class may be instantiated or subclassed by clients.
- * </p>
- */
-public class SubProgressMonitor extends ProgressMonitorWrapper {
-
- /**
- * Style constant indicating that calls to <code>subTask</code>
- * should not have any effect.
- *
- * @see #SubProgressMonitor(IProgressMonitor,int,int)
- */
- public static final int SUPPRESS_SUBTASK_LABEL = 1 << 1;
- /**
- * Style constant indicating that the main task label
- * should be prepended to the subtask label.
- *
- * @see #SubProgressMonitor(IProgressMonitor,int,int)
- */
- public static final int PREPEND_MAIN_LABEL_TO_SUBTASK = 1 << 2;
-
- private int parentTicks = 0;
- private double sentToParent = 0.0;
- private double scale = 0.0;
- private int nestedBeginTasks = 0;
- private boolean usedUp = false;
- private boolean hasSubTask = false;
- private int style;
- private String mainTaskLabel;
-
- /**
- * Creates a new sub-progress monitor for the given monitor. The sub
- * progress monitor uses the given number of work ticks from its
- * parent monitor.
- *
- * @param monitor the parent progress monitor
- * @param ticks the number of work ticks allocated from the
- * parent monitor
- */
- public SubProgressMonitor(IProgressMonitor monitor, int ticks) {
- this(monitor, ticks, 0);
- }
-
- /**
- * Creates a new sub-progress monitor for the given monitor. The sub
- * progress monitor uses the given number of work ticks from its
- * parent monitor.
- *
- * @param monitor the parent progress monitor
- * @param ticks the number of work ticks allocated from the
- * parent monitor
- * @param style one of
- * <ul>
- * <li> <code>SUPPRESS_SUBTASK_LABEL</code> </li>
- * <li> <code>PREPEND_MAIN_LABEL_TO_SUBTASK</code> </li>
- * </ul>
- * @see #SUPPRESS_SUBTASK_LABEL
- * @see #PREPEND_MAIN_LABEL_TO_SUBTASK
- */
- public SubProgressMonitor(IProgressMonitor monitor, int ticks, int style) {
- super(monitor);
- this.parentTicks = ticks;
- this.style = style;
- }
-
- /* (Intentionally not javadoc'd)
- * Implements the method <code>IProgressMonitor.beginTask</code>.
- *
- * Starts a new main task. Since this progress monitor is a sub
- * progress monitor, the given name will NOT be used to update
- * the progress bar's main task label. That means the given
- * string will be ignored. If style <code>PREPEND_MAIN_LABEL_TO_SUBTASK
- * <code> is specified, then the given string will be prepended to
- * every string passed to <code>subTask(String)</code>.
- */
- public void beginTask(String name, int totalWork) {
- nestedBeginTasks++;
- // Ignore nested begin task calls.
- if (nestedBeginTasks > 1) {
- return;
- }
- // be safe: if the argument would cause math errors (zero or
- // negative), just use 0 as the scale. This disables progress for
- // this submonitor.
- scale = totalWork <= 0 ? 0 : (double) parentTicks / (double) totalWork;
- if ((style & PREPEND_MAIN_LABEL_TO_SUBTASK) != 0) {
- mainTaskLabel = name;
- }
- }
-
- /* (Intentionally not javadoc'd)
- * Implements the method <code>IProgressMonitor.done</code>.
- */
- public void done() {
- // Ignore if more done calls than beginTask calls or if we are still
- // in some nested beginTasks
- if (nestedBeginTasks == 0 || --nestedBeginTasks > 0)
- return;
- // Send any remaining ticks and clear out the subtask text
- double remaining = parentTicks - sentToParent;
- if (remaining > 0)
- super.internalWorked(remaining);
- //clear the sub task if there was one
- if (hasSubTask)
- subTask(""); //$NON-NLS-1$
- sentToParent = 0;
- }
-
- /* (Intentionally not javadoc'd)
- * Implements the internal method <code>IProgressMonitor.internalWorked</code>.
- */
- public void internalWorked(double work) {
- if (usedUp || nestedBeginTasks != 1) {
- return;
- }
-
- double realWork = scale * work;
- super.internalWorked(realWork);
- sentToParent += realWork;
- if (sentToParent >= parentTicks) {
- usedUp = true;
- }
- }
-
- /* (Intentionally not javadoc'd)
- * Implements the method <code>IProgressMonitor.subTask</code>.
- */
- public void subTask(String name) {
- if ((style & SUPPRESS_SUBTASK_LABEL) != 0) {
- return;
- }
- hasSubTask = true;
- String label = name;
- if ((style & PREPEND_MAIN_LABEL_TO_SUBTASK) != 0 && mainTaskLabel != null && mainTaskLabel.length() > 0) {
- label = mainTaskLabel + ' ' + label;
- }
- super.subTask(label);
- }
-
- /* (Intentionally not javadoc'd)
- * Implements the method <code>IProgressMonitor.worked</code>.
- */
- public void worked(int work) {
- internalWorked(work);
- }
-}
diff --git a/bundles/org.eclipse.equinox.device/.classpath b/bundles/org.eclipse.equinox.device/.classpath
deleted file mode 100644
index 065ac06e1..000000000
--- a/bundles/org.eclipse.equinox.device/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/bundles/org.eclipse.equinox.device/.cvsignore b/bundles/org.eclipse.equinox.device/.cvsignore
deleted file mode 100644
index ba077a403..000000000
--- a/bundles/org.eclipse.equinox.device/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
diff --git a/bundles/org.eclipse.equinox.device/.project b/bundles/org.eclipse.equinox.device/.project
deleted file mode 100644
index 5d5c43191..000000000
--- a/bundles/org.eclipse.equinox.device/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.equinox.device</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/bundles/org.eclipse.equinox.device/.settings/org.eclipse.jdt.core.prefs b/bundles/org.eclipse.equinox.device/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index c8df024d6..000000000
--- a/bundles/org.eclipse.equinox.device/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,49 +0,0 @@
-#Fri Dec 16 09:19:41 CST 2005
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
-org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
-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=warning
-org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
-org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
-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=warning
-org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
-org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
-org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
-org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
-org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
-org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
-org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore
-org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
-org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
-org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning
-org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
-org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
-org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
-org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.unusedImport=error
-org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
-org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
-org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
-org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
diff --git a/bundles/org.eclipse.equinox.device/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.device/META-INF/MANIFEST.MF
deleted file mode 100644
index 9d73e9bfc..000000000
--- a/bundles/org.eclipse.equinox.device/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,15 +0,0 @@
-Bundle-ManifestVersion: 2
-Bundle-Name: %bundleName
-Bundle-Version: 1.0.0.qualifier
-Bundle-Activator: org.eclipse.equinox.device.Activator
-Bundle-SymbolicName: org.eclipse.equinox.device
-Bundle-Vendor: %bundleVendor
-Bundle-Copyright: %bundleCopyright
-Bundle-Localization: plugin
-Import-Service: org.osgi.service.log.LogService
-Import-Package: org.osgi.framework;version="1.2",
- org.osgi.service.device,
- org.osgi.service.log;version="1.2",
- org.osgi.util.tracker,
- org.eclipse.osgi.util
-Export-Package: org.eclipse.equinox.device; x-internal:=true
diff --git a/bundles/org.eclipse.equinox.device/about.html b/bundles/org.eclipse.equinox.device/about.html
deleted file mode 100644
index b2f1e6bad..000000000
--- a/bundles/org.eclipse.equinox.device/about.html
+++ /dev/null
@@ -1,22 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
-<!-- saved from url=(0043)http://www.eclipse.org/legal/epl/about.html -->
-<HTML><HEAD><TITLE>About</TITLE>
-<META http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-<META content="MSHTML 6.00.2800.1498" name=GENERATOR></HEAD>
-<BODY lang=EN-US>
-<H2>About This Content</H2>
-<P>February 24, 2005</P>
-<H3>License</H3>
-<P>The Eclipse Foundation makes available all content in this plug-in
-("Content"). Unless otherwise indicated below, the Content is provided to you
-under the terms and conditions of the Eclipse Public License Version 1.0
-("EPL"). A copy of the EPL is available at <A
-href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</A>.
-For purposes of the EPL, "Program" will mean the Content.</P>
-<P>If you did not receive this Content directly from the Eclipse Foundation, the
-Content is being redistributed by another party ("Redistributor") and different
-terms and conditions may apply to your use of any object code in the Content.
-Check the Redistributor's license that was provided with the Content. If no such
-license exists, contact the Redistributor. Unless otherwise indicated below, the
-terms and conditions of the EPL still apply to any source code in the
-Content.</P></BODY></HTML>
diff --git a/bundles/org.eclipse.equinox.device/build.properties b/bundles/org.eclipse.equinox.device/build.properties
deleted file mode 100644
index 3da785a7f..000000000
--- a/bundles/org.eclipse.equinox.device/build.properties
+++ /dev/null
@@ -1,17 +0,0 @@
-###############################################################################
-# Copyright (c) 2005 IBM Corporation.
-# 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:
-# IBM Corporation - initial API and implementation
-###############################################################################
-bin.includes = META-INF/,\
- plugin.properties,\
- about.html,\
- .
-src.includes = about.html
-source.. = src/
-output.. = bin/
diff --git a/bundles/org.eclipse.equinox.device/plugin.properties b/bundles/org.eclipse.equinox.device/plugin.properties
deleted file mode 100644
index 86742fd77..000000000
--- a/bundles/org.eclipse.equinox.device/plugin.properties
+++ /dev/null
@@ -1,13 +0,0 @@
-###############################################################################
-# Copyright (c) 2005 IBM Corporation.
-# 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:
-# IBM Corporation - initial API and implementation
-###############################################################################
-bundleVendor = Eclipse.org
-bundleName = Device Access Service
-bundleCopyright = Copyright (c) IBM Corp. 1999, 2005
diff --git a/bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/Activator.java b/bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/Activator.java
deleted file mode 100644
index ac4f9089f..000000000
--- a/bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/Activator.java
+++ /dev/null
@@ -1,420 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.device;
-
-import org.eclipse.osgi.util.NLS;
-import org.osgi.framework.*;
-import org.osgi.util.tracker.ServiceTracker;
-import org.osgi.util.tracker.ServiceTrackerCustomizer;
-
-/**
- * DeviceManager bundle. This bundle implements the OSGi Device Access 1.1
- * specification.
- *
- * This implementation does not include the optimizations in section
- * 8.7.4 of the OSGi SP R2 spec.
- *
- */
-public class Activator implements BundleActivator, ServiceTrackerCustomizer, FrameworkListener, Runnable {
- protected final static boolean DEBUG = false;
-
- /** DeviceManager BundleContext */
- protected BundleContext context;
-
- /** LogTracker object */
- protected LogTracker log;
-
- /** if false the thread must terminate */
- protected volatile boolean running;
-
- /** DeviceManager thread */
- protected Thread thread;
-
- /** DriverTracker for Driver services. */
- protected DriverTracker drivers;
-
- /** Tracker for DriverLocator services */
- protected DriverLocatorTracker locators;
-
- /** Tracker for DriverSelector services */
- protected DriverSelectorTracker selectors;
-
- /** ServiceTracker object for device services */
- protected ServiceTracker devices;
-
- /** filter for Device services */
- protected Filter deviceFilter;
-
- /** filter for Driver services */
- protected Filter driverFilter;
-
- /**
- * Linked List item
- */
- static class DeviceService {
- /** object for this item */
- final DeviceTracker device;
- /** next item in event queue */
- DeviceService next;
-
- /**
- * Constructor for work queue item
- *
- * @param o Object for this event
- */
- DeviceService(DeviceTracker device) {
- this.device = device;
- next = null;
- }
- }
-
- /** item at the head of the event queue */
- private DeviceService head;
- /** item at the tail of the event queue */
- private DeviceService tail;
-
- /** number of milliseconds to wait before refining idle Device services */
- protected long updatewait;
-
- /** set to true by DriverTracker when a Driver Service is registered */
- protected volatile boolean driverServiceRegistered;
-
- /**
- * Create a DeviceManager object.
- *
- */
-
- public Activator() {
- super();
- }
-
- /**
- * Start the Device Manager.
- *
- * @param context The device manager's bundle context
- */
-
- public void start(BundleContext context) throws Exception {
- this.context = context;
- running = false;
-
- log = new LogTracker(context, System.err);
-
- try {
- deviceFilter = context.createFilter("(|(" + org.osgi.framework.Constants.OBJECTCLASS + "=" + DeviceTracker.clazz + ////-1$ ////-2$ //$NON-NLS-1$ //$NON-NLS-2$
- ")(" + org.osgi.service.device.Constants.DEVICE_CATEGORY + "=*))"); //$NON-NLS-1$ //$NON-NLS-2$
-
- driverFilter = context.createFilter("(" + org.osgi.framework.Constants.OBJECTCLASS + "=" + DriverTracker.clazz + ")"); ////-1$ ////-2$ ////-3$ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- } catch (InvalidSyntaxException e) {
- log.log(log.LOG_ERROR, NLS.bind(DeviceMsg.Unable_to_create_Filter_for_DeviceManager, e)); ////-1$
- throw e;
- }
-
- updatewait = 5 * 1000L;
-
- String prop = context.getProperty("org.eclipse.equinox.device.updatewait"); //$NON-NLS-1$
-
- if (prop != null) {
- try {
- updatewait = Long.parseLong(prop) * 1000L;
- } catch (NumberFormatException e) {
- }
- }
-
- Bundle systemBundle = context.getBundle(0);
-
- if ((systemBundle != null) && ((systemBundle.getState() & systemBundle.STARTING) != 0)) { /* if the system bundle is starting */
- context.addFrameworkListener(this);
- } else {
- startDeviceManager();
- }
-
- log.log(log.LOG_INFO, DeviceMsg.DeviceManager_started);
- }
-
- /**
- * Receive notification of a general framework event.
- *
- * @param event The FrameworkEvent.
- */
- public void frameworkEvent(FrameworkEvent event) {
- switch (event.getType()) {
- case FrameworkEvent.STARTED : {
- context.removeFrameworkListener(this);
-
- try {
- startDeviceManager();
- } catch (Throwable t) {
- log.log(log.LOG_ERROR, NLS.bind(DeviceMsg.DeviceManager_has_thrown_an_error, t)); ////-1$
- }
-
- break;
- }
- }
- }
-
- /**
- * Start the DeviceManager thread.
- *
- */
- public void startDeviceManager() {
- if (!running) {
- head = null;
- tail = null;
-
- locators = new DriverLocatorTracker(this);
-
- selectors = new DriverSelectorTracker(this);
-
- drivers = new DriverTracker(this);
-
- devices = new ServiceTracker(context, deviceFilter, this);
- devices.open();
-
- running = true;
- driverServiceRegistered = false;
-
- thread = (new SecureAction()).createThread(this, "DeviceManager"); //$NON-NLS-1$
- thread.start(); /* Start DeviceManager thread */
- }
- }
-
- /**
- * Stop the Device Manager bundle.
- *
- * @param context The device manager's bundle context
- */
-
- public void stop(BundleContext context) throws Exception {
- context.removeFrameworkListener(this);
-
- if (running) {
- Thread t = thread;
-
- running = false; /* request thread to stop */
-
- if (t != null) {
- t.interrupt();
-
- synchronized (t) {
- while (t.isAlive()) /* wait for thread to complete */
- {
- try {
- t.wait(0);
- } catch (InterruptedException e) {
- }
- }
- }
- }
- }
-
- if (drivers != null) {
- drivers.close();
- drivers = null;
- }
-
- if (devices != null) {
- devices.close();
- devices = null;
- }
-
- if (locators != null) {
- locators.close();
- locators = null;
- }
-
- if (selectors != null) {
- selectors.close();
- selectors = null;
- }
-
- if (log != null) {
- log.close();
- log = null;
- }
-
- this.context = null;
- }
-
- /**
- * A service is being added to the ServiceTracker.
- *
- * <p>This method is called before a service which matched
- * the search parameters of the ServiceTracker is
- * added to the ServiceTracker. This method should return the
- * service object to be tracked for this ServiceReference.
- * The returned service object is stored in the ServiceTracker
- * and is available from the getService and getServices
- * methods.
- *
- * @param reference Reference to service being added to the ServiceTracker.
- * @return The service object to be tracked for the
- * ServiceReference or <tt>null</tt> if the ServiceReference should not
- * be tracked.
- */
- public Object addingService(ServiceReference reference) {
- if (Activator.DEBUG) {
- log.log(reference, log.LOG_DEBUG, "DeviceManager device service registered"); //$NON-NLS-1$
- }
-
- enqueue(new DeviceTracker(this, reference));
-
- return (reference);
- }
-
- /**
- * A service tracked by the ServiceTracker has been modified.
- *
- * <p>This method is called when a service being tracked
- * by the ServiceTracker has had it properties modified.
- *
- * @param reference Reference to service that has been modified.
- * @param service The service object for the modified service.
- */
- public void modifiedService(ServiceReference reference, Object service) {
- }
-
- /**
- * A service tracked by the ServiceTracker is being removed.
- *
- * <p>This method is called after a service is no longer being tracked
- * by the ServiceTracker.
- *
- * @param reference Reference to service that has been removed.
- * @param service The service object for the removed service.
- */
- public void removedService(ServiceReference reference, Object object) {
- if (Activator.DEBUG) {
- log.log(reference, log.LOG_DEBUG, "DeviceManager device service unregistered"); //$NON-NLS-1$
- }
-
- /* We do not implement optional driver reclamation.
- * Thus we take no specific action upon Device service unregistration .
- */
- }
-
- public void refineIdleDevices() {
- if (Activator.DEBUG) {
- log.log(log.LOG_DEBUG, "DeviceManager refining idle device services"); //$NON-NLS-1$
- }
-
- ServiceReference[] references = devices.getServiceReferences();
-
- if (references != null) {
- int size = references.length;
-
- for (int i = 0; i < size; i++) {
- ServiceReference device = references[i];
-
- enqueue(new DeviceTracker(this, device));
- }
- }
- }
-
- /**
- * Main thread for DeviceManager.
- *
- * Attempt to refine all Device services that are not in use
- * by a driver bundle.
- */
- public void run() {
- while (running) {
- DeviceTracker device;
-
- try {
- device = dequeue();
- } catch (InterruptedException e) {
- continue;
- }
-
- try {
- device.refine();
- } catch (Throwable t) {
- log.log(log.LOG_ERROR, NLS.bind(DeviceMsg.DeviceManager_has_thrown_an_error, t)); ////-1$
- }
- }
- }
-
- /**
- * Queue the object to be processed on the work thread.
- * The thread is notified.
- *
- * @param device Work item.
- */
- public synchronized void enqueue(DeviceTracker device) {
- if (device != null) {
- if (Activator.DEBUG) {
- log.log(log.LOG_DEBUG, "DeviceManager queuing DeviceTracker"); //$NON-NLS-1$
- }
-
- DeviceService item = new DeviceService(device);
-
- if (head == null) /* if the queue was empty */
- {
- head = item;
- tail = item;
- } else /* else add to end of queue */
- {
- tail.next = item;
- tail = item;
- }
- }
-
- notify();
- }
-
- /**
- * Dequeue an object from the work thread.
- * If the queue is empty, this method blocks.
- *
- * @return Dequeue object from the work thread.
- * @throws InterruptedException If the queue has been stopped.
- */
- private synchronized DeviceTracker dequeue() throws InterruptedException {
- while (running && (head == null)) {
- /* This should be included per Section 8.7.7 of the OSGi SP R2
- * spec, but it causes the OSGi SP R2 Test Suite to fail.
- * We should turn this on for R3.
-
- if (driverServiceRegistered)
- */
- if (false) {
- driverServiceRegistered = false;
-
- refineIdleDevices();
- } else {
- locators.uninstallDriverBundles();
-
- try {
- if (Activator.DEBUG) {
- log.log(log.LOG_DEBUG, "DeviceManager waiting on queue"); //$NON-NLS-1$
- }
-
- wait();
- } catch (InterruptedException e) {
- }
- }
- }
-
- if (!running) /* if we are stopping */
- {
- throw new InterruptedException(); /* throw an exception */
- }
-
- DeviceService item = head;
- head = item.next;
- if (head == null) {
- tail = null;
- }
-
- return (item.device);
- }
-}
diff --git a/bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/DeviceMsg.java b/bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/DeviceMsg.java
deleted file mode 100644
index bbb83f35e..000000000
--- a/bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/DeviceMsg.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.device;
-
-import org.eclipse.osgi.util.NLS;
-
-public class DeviceMsg extends NLS {
- private static final String BUNDLE_NAME = "org.eclipse.equinox.device.ExternalMessages"; //$NON-NLS-1$
-
- public static String DeviceManager_started;
- public static String Device_service_unregistered;
- public static String Device_noDriverFound_called;
- public static String Multiple_Driver_services_with_the_same_DRIVER_ID;
- public static String DeviceManager_Update_Wait;
- public static String Driver_service_has_no_DRIVER_ID_property;
- public static String Device_attached_by_DRIVER_ID;
- public static String Device_referred_to;
- public static String Unable_to_create_Filter_for_DeviceManager;
- public static String DeviceManager_has_thrown_an_error;
- public static String Device_noDriverFound_error;
- public static String DriverLocator_unable_to_load_driver;
- public static String DriverLocator_error_calling_findDrivers;
- public static String Unable_to_install_or_start_driver_bundle;
- public static String Unable_to_uninstall_driver_bundle;
- public static String Unable_to_uninstall_driver_bundle_number;
- public static String DriverSelector_error_during_match;
- public static String Driver_service_has_no_DRIVER_ID;
- public static String Driver_error_during_match;
- public static String Driver_error_during_attach;
-
- static {
- // initialize resource bundles
- NLS.initializeMessages(BUNDLE_NAME, DeviceMsg.class);
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/DeviceTracker.java b/bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/DeviceTracker.java
deleted file mode 100644
index ee85a7f6d..000000000
--- a/bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/DeviceTracker.java
+++ /dev/null
@@ -1,341 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.device;
-
-import java.util.*;
-import org.eclipse.osgi.util.NLS;
-import org.osgi.framework.*;
-import org.osgi.service.device.Device;
-import org.osgi.service.log.LogService;
-import org.osgi.util.tracker.ServiceTracker;
-
-/**
- * DeviceTracker class. This class has the logic for refining a
- * Device service.
- *
- */
-public class DeviceTracker extends ServiceTracker {
- /** OSGi Device class name */
- protected final static String clazz = "org.osgi.service.device.Device"; //$NON-NLS-1$
-
- /** DeviceManager object. */
- protected Activator manager;
-
- /** reference to Device service we are attempting to refine */
- protected ServiceReference device;
-
- /** LogService object */
- protected LogService log;
-
- /** Device services properties */
- protected Dictionary properties;
-
- /** if false the algorithm must terminate */
- protected volatile boolean running;
-
- /**
- * Create a DeviceTracker from a ServiceReference.
- *
- * @param manager DeviceManager object
- * @param device ServiceReference to the Device service.
- * @param id ID of DeviceTracker object
- */
- public DeviceTracker(Activator manager, ServiceReference device) {
- super(manager.context, device, null);
-
- this.manager = manager;
- log = manager.log;
-
- if (Activator.DEBUG) {
- log.log(device, log.LOG_DEBUG, this + " constructor"); //$NON-NLS-1$
- }
-
- open();
- }
-
- /**
- * Close the Device.
- */
-
- public void close() {
- if (device != null) {
- if (Activator.DEBUG) {
- log.log(device, log.LOG_DEBUG, this + " closing"); //$NON-NLS-1$
- }
-
- running = false; /* request thread to stop */
-
- super.close();
-
- device = null;
- }
- }
-
- /**
- * A service is being added to the ServiceTracker.
- *
- * <p>This method is called before a service which matched
- * the search parameters of the ServiceTracker is
- * added to the ServiceTracker. This method should return the
- * service object to be tracked for this ServiceReference.
- * The returned service object is stored in the ServiceTracker
- * and is available from the getService and getServices
- * methods.
- *
- * @param reference Reference to service being added to the ServiceTracker.
- * @return The service object to be tracked for the
- * ServiceReference or <tt>null</tt> if the ServiceReference should not
- * be tracked.
- */
- public Object addingService(ServiceReference reference) {
- if (Activator.DEBUG) {
- log.log(reference, log.LOG_DEBUG, this + " adding Device service"); //$NON-NLS-1$
- }
-
- device = reference;
-
- running = true;
-
- properties = new Properties(reference);
-
- return (reference);
- }
-
- /**
- * A service tracked by the ServiceTracker has been modified.
- *
- * <p>This method is called when a service being tracked
- * by the ServiceTracker has had it properties modified.
- *
- * @param reference Reference to service that has been modified.
- * @param service The service object for the modified service.
- */
- public void modifiedService(ServiceReference reference, Object service) {
- properties = new Properties(reference);
- }
-
- /**
- * A service tracked by the ServiceTracker is being removed.
- *
- * <p>This method is called after a service is no longer being tracked
- * by the ServiceTracker.
- *
- * @param reference Reference to service that has been removed.
- * @param service The service object for the removed service.
- */
- public void removedService(ServiceReference reference, Object service) {
- if (running) {
- log.log(reference, log.LOG_WARNING, DeviceMsg.Device_service_unregistered);
- running = false; /* request algorithm to stop */
- } else {
- if (Activator.DEBUG) {
- log.log(reference, log.LOG_DEBUG, this + " removing Device service"); //$NON-NLS-1$
- }
- }
- }
-
- /**
- * Attempt to refine this Device service.
- *
- */
- public void refine() {
- if (Activator.DEBUG) {
- log.log(device, log.LOG_DEBUG, this + " refining " + device); //$NON-NLS-1$
- }
-
- if (running && isIdle()) {
- /* List of excluded drivers from this algorithm run */
- DriverTracker drivers = manager.drivers;
-
- manager.locators.loadDrivers(properties, drivers);
-
- Vector exclude = new Vector(drivers.size());
-
- while (running) {
- ServiceReference driver = drivers.match(device, exclude);
-
- if (driver == null) {
- noDriverFound();
- break;
- }
-
- if (drivers.attach(driver, device, exclude)) {
- break;
- }
- }
- }
-
- close();
- }
-
- /**
- * Determine if the device service tracked by this object is idle.
- *
- * OSGi SP R2 Section 8.2.2 defines in idle device service as:
- * "A Device service is not used by any other bundle according to the Framework;
- * it is called an idle Device service."
- *
- * This method defines it as:
- * A Device service is not used by any DRIVER bundle according to the Framework;
- * it is called an idle Device service.
- *
- * Thus if a non-driver bundle uses a device service, it is still considered
- * idle by this method.
- *
- * @return true if the device service is idle.
- */
- public boolean isIdle() {
- if (Activator.DEBUG) {
- log.log(device, log.LOG_DEBUG, "Check device service idle: " + device); //$NON-NLS-1$
- }
-
- Filter filter = manager.driverFilter;
- Bundle[] users = device.getUsingBundles();
-
- int userCount = (users == null) ? 0 : users.length;
-
- for (int i = 0; i < userCount; i++) {
- ServiceReference[] services = users[i].getRegisteredServices();
-
- int servicesCount = (services == null) ? 0 : services.length;
-
- for (int j = 0; j < servicesCount; j++) {
- if (filter.match(services[j])) {
- if (Activator.DEBUG) {
- log.log(log.LOG_DEBUG, "Device " + device + " already in use by bundle " + users[i]); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- return (false);
- }
- }
- }
-
- return (true);
- }
-
- /**
- * Called by the device manager after it has failed to attach
- * any driver to the device.
- * <p>
- * If the device can be configured in alternate ways, the driver
- * may respond by unregistering the device service and registering
- * a different device service instead.</p>
- */
-
- public void noDriverFound() {
- BundleContext context = manager.context;
-
- Object service = context.getService(device);
-
- try {
- //It is possible that this is a Free Format Device that does not
- //implement Device
- if (service instanceof Device) {
- log.log(device, log.LOG_INFO, DeviceMsg.Device_noDriverFound_called);
-
- try {
- ((Device) service).noDriverFound();
- } catch (Throwable t) {
- log.log(device, log.LOG_ERROR, NLS.bind(DeviceMsg.Device_noDriverFound_error, t));
- }
- }
- } finally {
- context.ungetService(device);
- }
-
- }
-
- public String toString() {
- return "DeviceTracker"; //$NON-NLS-1$
- }
-
- /**
- * Readonly Dictionary for device properties.
- *
- */
- static class Properties extends Hashtable {
- /**
- * keys in original case.
- */
- protected Vector keys;
-
- /**
- * Create a properties object for the service.
- *
- * @param device The service to get the properties of.
- */
- protected Properties(ServiceReference device) {
- super();
-
- String[] props = device.getPropertyKeys();
-
- if (props != null) {
- int size = props.length;
-
- keys = new Vector(size);
-
- for (int i = 0; i < size; i++) {
- String key = props[i];
- Object value = device.getProperty(key);
-
- if (value != null) {
- keys.addElement(key);
-
- super.put(key.toLowerCase(), value);
- }
- }
- } else {
- keys = new Vector(0);
- }
- }
-
- /**
- * Override keys to support case-preserving of keys.
- */
- public Enumeration keys() {
- return (keys.elements());
- }
-
- /**
- * Override get to support case-insensitivity.
- *
- * @param key header name.
- */
- public Object get(Object key) {
- if (key instanceof String) {
- return (super.get(((String) key).toLowerCase()));
- }
-
- return (null);
- }
-
- /**
- * Override put to disable it. This Dictionary is readonly once built.
- *
- * @param key header name.
- * @param value header value.
- * @throws UnsupportedOperationException.
- */
- public Object put(Object key, Object value) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Override remove to disable it. This Dictionary is readonly once built.
- *
- * @param key header name.
- * @throws UnsupportedOperationException.
- */
- public Object remove(Object key) {
- throw new UnsupportedOperationException();
- }
- }
-}
diff --git a/bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/DriverLocatorTracker.java b/bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/DriverLocatorTracker.java
deleted file mode 100644
index 329fd6738..000000000
--- a/bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/DriverLocatorTracker.java
+++ /dev/null
@@ -1,344 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.device;
-
-import java.io.InputStream;
-import java.util.Dictionary;
-import java.util.Vector;
-import org.eclipse.osgi.util.NLS;
-import org.osgi.framework.*;
-import org.osgi.service.device.DriverLocator;
-import org.osgi.service.log.LogService;
-import org.osgi.util.tracker.ServiceTracker;
-
-/**
- * DriverLocatorTracker class. This class tracks all DriverLocator services.
- *
- */
-public class DriverLocatorTracker extends ServiceTracker {
- protected final static String clazz = "org.osgi.service.device.DriverLocator"; //$NON-NLS-1$
-
- /** DeviceManager object. */
- protected Activator manager;
-
- /** LogService object */
- protected LogService log;
-
- /** List of bundles to be uninstalled. */
- protected Vector bundles;
-
- /**
- * Create the DriverLocatorTracker.
- *
- * @param context Device manager bundle context.
- * @param log LogService object
- */
- public DriverLocatorTracker(Activator manager) {
- super(manager.context, clazz, null);
-
- this.manager = manager;
- log = manager.log;
- bundles = new Vector(10, 10);
-
- if (Activator.DEBUG) {
- log.log(LogService.LOG_DEBUG, "DriverLocatorTracker constructor"); //$NON-NLS-1$
- }
-
- open();
- }
-
- /**
- * A service is being added to the ServiceTracker.
- *
- * <p>This method is called before a service which matched
- * the search parameters of the ServiceTracker is
- * added to the ServiceTracker. This method should return the
- * service object to be tracked for this ServiceReference.
- * The returned service object is stored in the ServiceTracker
- * and is available from the getService and getServices
- * methods.
- *
- * @param reference Reference to service being added to the ServiceTracker.
- * @return The service object to be tracked for the
- * ServiceReference or <tt>null</tt> if the ServiceReference should not
- * be tracked.
- */
- public Object addingService(ServiceReference reference) {
- if (Activator.DEBUG) {
- log.log(reference, LogService.LOG_DEBUG, "DriverLocatorTracker adding service"); //$NON-NLS-1$
- }
-
- return (context.getService(reference));
- }
-
- /**
- * A service tracked by the ServiceTracker has been modified.
- *
- * <p>This method is called when a service being tracked
- * by the ServiceTracker has had it properties modified.
- *
- * @param reference Reference to service that has been modified.
- * @param service The service object for the modified service.
- */
- public void modifiedService(ServiceReference reference, Object service) {
- }
-
- /**
- * A service tracked by the ServiceTracker is being removed.
- *
- * <p>This method is called after a service is no longer being tracked
- * by the ServiceTracker.
- *
- * @param reference Reference to service that has been removed.
- * @param service The service object for the removed service.
- */
- public void removedService(ServiceReference reference, Object object) {
- if (Activator.DEBUG) {
- log.log(reference, LogService.LOG_DEBUG, "DriverLocatorTracker removing service"); //$NON-NLS-1$
- }
-
- context.ungetService(reference);
- }
-
- /**
- * Call the DriverLocator services in an attempt to locate and
- * install driver bundles to refine the device service.
- *
- * @param locators Array of DriverLocator objects
- * @param drivers Dictionary of drivers with key=DRIVER_ID, value=Driver object
- */
- public void loadDrivers(Dictionary properties, DriverTracker drivers) {
- if (Activator.DEBUG) {
- log.log(LogService.LOG_DEBUG, Thread.currentThread().getName() + ": DriverLocatorTracker loadDrivers called"); //$NON-NLS-1$
- }
-
- ServiceReference[] references = getServiceReferences();
-
- if (references != null) {
- int size = references.length;
-
- for (int i = 0; i < size; i++) {
- ServiceReference locator = references[i];
- DriverLocator service = (DriverLocator) getService(locator);
-
- if (service != null) {
- if (Activator.DEBUG) {
- log.log(locator, LogService.LOG_DEBUG, Thread.currentThread().getName() + ": DriverLocator findDrivers called"); //$NON-NLS-1$
- }
-
- try {
- String[] driver_ids = service.findDrivers(properties);
-
- if (Activator.DEBUG) {
- int count = (driver_ids == null) ? 0 : driver_ids.length;
-
- StringBuffer sb = new StringBuffer();
-
- sb.append('<');
-
- for (int k = 0; k < count; k++) {
- if (k > 0) {
- sb.append(',');
- }
- sb.append(driver_ids[k]);
- }
-
- sb.append('>');
-
- log.log(locator, LogService.LOG_DEBUG, Thread.currentThread().getName() + ": DriverLocator findDrivers returned: " + sb); //$NON-NLS-1$
- }
-
- if (driver_ids != null) {
- int count = driver_ids.length;
-
- for (int j = 0; j < count; j++) {
- String driver_id = driver_ids[j];
-
- if (drivers.getDriver(driver_id) == null) {
- if (Activator.DEBUG) {
- log.log(locator, LogService.LOG_DEBUG, Thread.currentThread().getName() + ": DriverLocator loadDriver called for driver: " + driver_id); //$NON-NLS-1$
- }
-
- try {
- InputStream in = service.loadDriver(driver_id);
-
- if (Activator.DEBUG) {
- log.log(locator, LogService.LOG_DEBUG, Thread.currentThread().getName() + ": DriverLocator loadDriver returned: " + in); //$NON-NLS-1$
- }
-
- installDriverBundle(driver_id, in);
- } catch (Throwable t) {
- log.log(locator, LogService.LOG_ERROR, NLS.bind(DeviceMsg.DriverLocator_unable_to_load_driver, driver_id), t);
- }
- }
- }
- }
- } catch (Throwable t) {
- log.log(locator, LogService.LOG_ERROR, DeviceMsg.DriverLocator_error_calling_findDrivers, t);
- }
- }
- }
- }
- }
-
- /**
- * Get an <code>InputStream</code> from which the driver bundle providing a driver with the giving ID can be installed.
- *
- * @param id the ID of the driver that needs to be installed.
- * @return the <code>InputStream</code> from which the driver
- * bundle can be installed
- */
-
- public void loadDriver(String driver_id, DriverTracker drivers) {
- if (Activator.DEBUG) {
- log.log(LogService.LOG_DEBUG, Thread.currentThread().getName() + ": DriverLocatorTracker loadDriver called for driver: " + driver_id); //$NON-NLS-1$
- }
-
- if (drivers.getDriver(driver_id) == null) {
- ServiceReference[] references = getServiceReferences();
-
- if (references != null) {
- int size = references.length;
-
- for (int i = 0; i < size; i++) {
- ServiceReference locator = references[i];
- DriverLocator service = (DriverLocator) getService(locator);
-
- if (service != null) {
- if (Activator.DEBUG) {
- log.log(locator, LogService.LOG_DEBUG, Thread.currentThread().getName() + ": DriverLocator loadDriver called for driver: " + driver_id); //$NON-NLS-1$
- }
-
- try {
- InputStream in = service.loadDriver(driver_id);
-
- if (Activator.DEBUG) {
- log.log(locator, LogService.LOG_DEBUG, Thread.currentThread().getName() + ": DriverLocator loadDriver returned: " + in); //$NON-NLS-1$
- }
-
- if (in != null) {
- installDriverBundle(driver_id, in);
-
- break;
- }
- } catch (Throwable t) {
- log.log(locator, LogService.LOG_ERROR, NLS.bind(DeviceMsg.DriverLocator_unable_to_load_driver, driver_id), t);
- }
- }
- }
- }
- }
- }
-
- /**
- * Install a Driver bundle.
- *
- * @param driver_id DRIVER_ID for new driver bundle.
- * @param in InputStream to a new driver bundle.
- */
- public void installDriverBundle(String driver_id, InputStream in) {
- if (Activator.DEBUG) {
- log.log(LogService.LOG_DEBUG, Thread.currentThread().getName() + ": installDriverBundle from InputStream: " + driver_id); //$NON-NLS-1$
- }
-
- if (in != null) {
- Bundle bundle = null;
-
- try {
- bundle = context.installBundle(driver_id, in);
- /* installBundle will close the InputStream */
-
- if (Activator.DEBUG) {
- log.log(LogService.LOG_DEBUG, Thread.currentThread().getName() + ": Driver bundle installed: " + driver_id); //$NON-NLS-1$
- }
-
- synchronized (bundles) {
- if (!bundles.contains(bundle)) {
- bundles.addElement(bundle);
- }
- }
-
- bundle.start();
-
- if (Activator.DEBUG) {
- log.log(LogService.LOG_DEBUG, Thread.currentThread().getName() + ": Driver bundle started: " + driver_id); //$NON-NLS-1$
- }
- } catch (BundleException e) {
- log.log(LogService.LOG_ERROR, NLS.bind(DeviceMsg.Unable_to_install_or_start_driver_bundle, driver_id), e);
-
- if (bundle != null) {
- bundles.removeElement(bundle);
-
- try {
- bundle.uninstall();
-
- if (Activator.DEBUG) {
- log.log(LogService.LOG_DEBUG, Thread.currentThread().getName() + ": Driver bundle uninstalled: " + driver_id); //$NON-NLS-1$
- }
- } catch (BundleException ee) {
- log.log(LogService.LOG_ERROR, NLS.bind(DeviceMsg.Unable_to_uninstall_driver_bundle_number, driver_id), ee);
- }
-
- bundle = null;
- }
- }
- }
- }
-
- /**
- * Remove bundle from uninstall list.
- *
- * @param bundle bundle to remove from list.
- */
- public void usingDriverBundle(Bundle bundle) {
- bundles.removeElement(bundle);
- }
-
- /**
- * Uninstall the recently installed but unused driver bundles.
- *
- */
- public void uninstallDriverBundles() {
- int size;
- Bundle[] uninstall = null;
-
- synchronized (bundles) {
- size = bundles.size();
-
- if (size > 0) {
- uninstall = new Bundle[size];
- bundles.copyInto(uninstall);
- }
- }
-
- for (int i = 0; i < size; i++) {
- Bundle bundle = uninstall[i];
-
- if ((bundle.getState() & Bundle.UNINSTALLED) == 0) { /* if bundle not already uninstalled */
- try {
- bundle.uninstall();
-
- if (Activator.DEBUG) {
- log.log(LogService.LOG_DEBUG, Thread.currentThread().getName() + ": Driver bundle uninstalled"); //$NON-NLS-1$
- }
- } catch (BundleException ee) {
- log.log(LogService.LOG_ERROR, NLS.bind(DeviceMsg.Unable_to_uninstall_driver_bundle, ee));
- }
- }
- }
-
- bundles.removeAllElements();
- }
-
- public boolean isUninstallCandidate(Bundle bundle) {
- return bundles.contains(bundle);
- }
-}
diff --git a/bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/DriverSelectorTracker.java b/bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/DriverSelectorTracker.java
deleted file mode 100644
index cbd469a0f..000000000
--- a/bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/DriverSelectorTracker.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.device;
-
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.device.Device;
-import org.osgi.service.device.DriverSelector;
-import org.osgi.service.log.LogService;
-import org.osgi.util.tracker.ServiceTracker;
-
-/**
- * DriverSelectorTracker class. This class tracks all DriverSelector services.
- *
- */
-public class DriverSelectorTracker extends ServiceTracker {
- /** Driver service name */
- protected final static String clazz = "org.osgi.service.device.DriverSelector"; //$NON-NLS-1$
-
- /** LogService object */
- protected LogService log;
-
- /** DeviceManager object. */
- protected Activator manager;
-
- /**
- * Create the DriverTracker.
- *
- * @param manager DeviceManager object.
- * @param device DeviceTracker we are working for.
- */
- public DriverSelectorTracker(Activator manager) {
- super(manager.context, clazz, null);
-
- this.manager = manager;
- log = manager.log;
-
- if (Activator.DEBUG) {
- log.log(log.LOG_DEBUG, "DriverSelectorTracker constructor"); //$NON-NLS-1$
- }
-
- open();
- }
-
- /**
- * Select the matching driver.
- *
- * @param device Device service being matched.
- * @param matches Array of the successful matches from Driver services.
- * @return ServiceReference to best matched Driver or null of their is no match.
- */
- public ServiceReference select(ServiceReference device, Match[] matches) {
- if (Activator.DEBUG) {
- log.log(device, log.LOG_DEBUG, "DriverSelector select called"); //$NON-NLS-1$
- }
-
- //This should give us the highest ranking DriverSelector (if available)
- ServiceReference selector = getServiceReference();
-
- if (selector != null) {
- DriverSelector service = (DriverSelector) getService(selector);
-
- try {
- int index = service.select(device, matches);
-
- if (index == DriverSelector.SELECT_NONE) {
- return null;
- }
-
- return matches[index].getDriver();
- } catch (Throwable t) {
- log.log(selector, log.LOG_ERROR, DeviceMsg.DriverSelector_error_during_match, t);
- }
- }
-
- return defaultSelection(matches);
- }
-
- /**
- * Default match selection algorithm from OSGi SPR2 spec.
- *
- * @param matchArray An array of the successful matches.
- * @return ServiceReference to the selected Driver service
- */
- public ServiceReference defaultSelection(Match[] matches) {
- int size = matches.length;
-
- int max = Device.MATCH_NONE;
- ServiceReference reference = null;
-
- for (int i = 0; i < size; i++) {
- Match driver = matches[i];
-
- int match = driver.getMatchValue();
-
- if (match >= max) {
- if (match == max) /* we must break the tie */
- {
- reference = breakTie(reference, driver.getDriver());
- } else {
- max = match;
- reference = driver.getDriver();
- }
- }
- }
-
- return reference;
- }
-
- /**
- * Select the service with the highest service.ranking. Break ties
- * buy selecting the lowest service.id.
- *
- */
- public ServiceReference breakTie(ServiceReference ref1, ServiceReference ref2) {
- //first we check service rankings
- Object property = ref1.getProperty(org.osgi.framework.Constants.SERVICE_RANKING);
-
- int ref1Ranking = (property instanceof Integer) ? ((Integer) property).intValue() : 0;
-
- property = ref2.getProperty(org.osgi.framework.Constants.SERVICE_RANKING);
-
- int ref2Ranking = (property instanceof Integer) ? ((Integer) property).intValue() : 0;
-
- if (ref1Ranking > ref2Ranking) {
- return ref1;
- } else if (ref2Ranking > ref1Ranking) {
- return ref2;
- } else // The rankings must match here
- {
- //we now check service ids
- long ref1ID = ((Long) (ref1.getProperty(org.osgi.framework.Constants.SERVICE_ID))).longValue();
-
- long ref2ID = ((Long) (ref2.getProperty(org.osgi.framework.Constants.SERVICE_ID))).longValue();
-
- if (ref1ID < ref2ID) {
- return ref1;
- }
-
- return ref2;
- }
- }
-}
diff --git a/bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/DriverTracker.java b/bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/DriverTracker.java
deleted file mode 100644
index a7026c401..000000000
--- a/bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/DriverTracker.java
+++ /dev/null
@@ -1,485 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.device;
-
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.Hashtable;
-import java.util.Vector;
-import org.eclipse.osgi.util.NLS;
-import org.osgi.framework.*;
-import org.osgi.service.device.Device;
-import org.osgi.service.device.Driver;
-import org.osgi.service.log.LogService;
-import org.osgi.util.tracker.ServiceTracker;
-
-/**
- * DriverTracker class. This class tracks all Driver services.
- *
- */
-public class DriverTracker extends ServiceTracker {
- /** Driver service name */
- protected final static String clazz = "org.osgi.service.device.Driver"; //$NON-NLS-1$
-
- /** LogService object */
- protected LogService log;
-
- /** Dictionary mapping DRIVER_ID strings <==> Driver ServiceReferences */
- protected Hashtable drivers;
-
- /** DeviceManager object. */
- protected Activator manager;
-
- /** Dictionary mapping Driver ID String =>
- * Hashtable (Device ServiceReference => cached Match objects) */
- protected Hashtable matches;
-
- /** Dictionary mapping Driver ID String =>
- * Hashtable (Device ServiceReference => cached referral String) */
- protected Hashtable referrals;
-
- /**
- * Create the DriverTracker.
- *
- * @param manager DeviceManager object.
- * @param device DeviceTracker we are working for.
- */
- public DriverTracker(Activator manager) {
- super(manager.context, clazz, null);
-
- this.manager = manager;
- log = manager.log;
-
- drivers = new Hashtable(37);
- matches = new Hashtable(37);
- referrals = new Hashtable(37);
-
- if (Activator.DEBUG) {
- log.log(LogService.LOG_DEBUG, this + " constructor"); //$NON-NLS-1$
- }
-
- open();
- }
-
- /**
- * A service is being added to the ServiceTracker.
- *
- * <p>This method is called before a service which matched
- * the search parameters of the ServiceTracker is
- * added to the ServiceTracker. This method should return the
- * service object to be tracked for this ServiceReference.
- * The returned service object is stored in the ServiceTracker
- * and is available from the getService and getServices
- * methods.
- *
- * @param reference Reference to service being added to the ServiceTracker.
- * @return The service object to be tracked for the
- * ServiceReference or <tt>null</tt> if the ServiceReference should not
- * be tracked.
- */
- public Object addingService(ServiceReference reference) {
- if (Activator.DEBUG) {
- log.log(reference, LogService.LOG_DEBUG, this + " adding service"); //$NON-NLS-1$
- }
-
- String driver_id = getDriverID(reference);
-
- if (drivers.get(driver_id) != null) {
- log.log(reference, LogService.LOG_WARNING, NLS.bind(DeviceMsg.Multiple_Driver_services_with_the_same_DRIVER_ID, driver_id));
-
- return (null); /* don't track this driver */
- }
-
- drivers.put(driver_id, reference);
- drivers.put(reference, driver_id);
-
- manager.driverServiceRegistered = true;
-
- /* OSGi SPR2 Device Access 1.1
- * Section 8.4.3 - When a new Driver service is registered,
- * the Device Attachment Algorithm must be applied to all
- * idle Device services.
- *
- * We do not refine idle Devices when the manager has not fully
- * started or the Driver service is from a bundle just installed
- * by the devicemanager.
- */
- Bundle bundle = reference.getBundle();
-
- if (manager.running && !manager.locators.isUninstallCandidate(bundle)) {
- manager.refineIdleDevices();
- }
-
- return (context.getService(reference));
- }
-
- /**
- * A service tracked by the ServiceTracker has been modified.
- *
- * <p>This method is called when a service being tracked
- * by the ServiceTracker has had it properties modified.
- *
- * @param reference Reference to service that has been modified.
- * @param service The service object for the modified service.
- */
- public void modifiedService(ServiceReference reference, Object service) {
- if (Activator.DEBUG) {
- log.log(reference, LogService.LOG_DEBUG, this + " modified service"); //$NON-NLS-1$
- }
-
- String driver_id = getDriverID(reference);
-
- String old_id = (String) drivers.get(reference);
-
- if (!driver_id.equals(old_id)) {
- drivers.put(driver_id, reference);
- drivers.put(reference, driver_id);
- drivers.remove(old_id);
- }
- }
-
- /**
- * A service tracked by the ServiceTracker is being removed.
- *
- * <p>This method is called after a service is no longer being tracked
- * by the ServiceTracker.
- *
- * @param reference Reference to service that has been removed.
- * @param service The service object for the removed service.
- */
- public void removedService(ServiceReference reference, Object object) {
- if (Activator.DEBUG) {
- log.log(reference, LogService.LOG_DEBUG, this + " removing service"); //$NON-NLS-1$
- }
-
- String driver_id = getDriverID(reference);
- drivers.remove(driver_id);
- drivers.remove(reference);
-
- matches.remove(driver_id);
- referrals.remove(driver_id);
-
- context.ungetService(reference);
-
- /* OSGi SPR2 Device Access 1.1
- * Section 8.4.4 - When a Driver service is unregistered,
- * the Device Attachment Algorithm must be applied to all
- * idle Device services.
- *
- * We do not refine idle Devices when the manager has not fully
- * started or the Driver service is from a bundle just installed
- * by the devicemanager.
- */
-
- Bundle bundle = reference.getBundle();
-
- if (manager.running && !manager.locators.isUninstallCandidate(bundle)) {
- DriverUpdate update = new DriverUpdate(bundle, manager);
-
- Thread thread = (new SecureAction()).createThread(update, DeviceMsg.DeviceManager_Update_Wait);
-
- thread.start();
- }
- }
-
- /**
- * Return the DRIVER_ID string for a ServiceReference.
- *
- * Per Section 8.4.3 of the OSGi SP R2 spec,
- * "A Driver service registration must have a DRIVER_ID property"
- *
- * This method is somewhat more lenient. If no DRIVER_ID property
- * is set, it will use the Bundle's location instead.
- *
- * @param reference Reference to driver service.
- * @param log LogService object.
- * @return DRIVER_ID string.
- */
- public String getDriverID(final ServiceReference reference) {
- String driver_id = (String) reference.getProperty(org.osgi.service.device.Constants.DRIVER_ID);
-
- if (driver_id == null) {
- log.log(reference, LogService.LOG_WARNING, DeviceMsg.Driver_service_has_no_DRIVER_ID);
- driver_id = (String) AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- return reference.getBundle().getLocation();
- }
- });
- }
-
- return (driver_id);
- }
-
- /**
- * Get the ServiceReference for a given DRIVER_ID.
- *
- * @param driver_id
- * @return ServiceReference to a Driver service.
- */
- public ServiceReference getDriver(String driver_id) {
- return ((ServiceReference) drivers.get(driver_id));
- }
-
- /**
- * Search the driver list to find the best match for the device.
- *
- * @return ServiceReference to best matched Driver or null of their is no match.
- */
- public ServiceReference match(ServiceReference device, Vector exclude) {
- if (Activator.DEBUG) {
- log.log(device, LogService.LOG_DEBUG, this + ": Driver match called"); //$NON-NLS-1$
- }
-
- ServiceReference[] references = getServiceReferences();
-
- if (references != null) {
- int size = references.length;
-
- Vector successfulMatches = new Vector(size);
-
- for (int i = 0; i < size; i++) {
- ServiceReference driver = references[i];
-
- if (exclude.contains(driver)) {
- if (Activator.DEBUG) {
- log.log(driver, LogService.LOG_DEBUG, this + ": Driver match excluded: " + drivers.get(driver)); //$NON-NLS-1$
- }
- } else {
- if (Activator.DEBUG) {
- log.log(driver, LogService.LOG_DEBUG, this + ": Driver match called: " + drivers.get(driver)); //$NON-NLS-1$
- }
-
- Match match = getMatch(driver, device);
-
- if (match == null) {
- Driver service = (Driver) getService(driver);
-
- if (service == null) {
- continue;
- }
-
- int matchValue = Device.MATCH_NONE;
-
- try {
- matchValue = service.match(device);
- } catch (Throwable t) {
- log.log(driver, LogService.LOG_ERROR, DeviceMsg.Driver_error_during_match, t);
-
- continue;
- }
-
- if (Activator.DEBUG) {
- log.log(driver, LogService.LOG_DEBUG, this + ": Driver match value: " + matchValue); //$NON-NLS-1$
- }
-
- match = new Match(driver, matchValue);
-
- storeMatch(driver, device, match);
- }
-
- if (match.getMatchValue() > Device.MATCH_NONE) {
- successfulMatches.addElement(match);
- }
- }
- }
-
- size = successfulMatches.size();
-
- if (size > 0) {
- Match[] matchArray = new Match[size];
- successfulMatches.copyInto(matchArray);
-
- return manager.selectors.select(device, matchArray);
- }
- }
-
- return null;
- }
-
- public Match getMatch(ServiceReference driver, ServiceReference device) {
- String driverid = getDriverID(driver);
-
- Hashtable driverMatches = (Hashtable) matches.get(driverid);
-
- if (driverMatches == null) {
- return null;
- }
-
- return (Match) driverMatches.get(device);
- }
-
- public void storeMatch(ServiceReference driver, ServiceReference device, Match match) {
- String driverid = getDriverID(driver);
-
- Hashtable driverMatches = (Hashtable) matches.get(driverid);
-
- if (driverMatches == null) {
- driverMatches = new Hashtable(37);
-
- matches.put(driverid, driverMatches);
- }
-
- driverMatches.put(device, match);
- }
-
- /**
- * Attempt to attach the driver to the device. If the driver
- * refers, add the referred driver to the driver list.
- *
- * @param driver Driver to attach
- * @param device Device to be attached
- * @return true is the Driver successfully attached.
- */
- public boolean attach(ServiceReference driver, ServiceReference device, Vector exclude) {
- if (Activator.DEBUG) {
- log.log(driver, LogService.LOG_DEBUG, this + ": Driver attach called: " + drivers.get(driver)); //$NON-NLS-1$
- }
-
- Driver service = (Driver) getService(driver);
-
- if (service != null) {
- String referral = getReferral(driver, device);
-
- if (referral == null) {
- try {
- referral = service.attach(device);
- } catch (Throwable t) {
- log.log(driver, LogService.LOG_ERROR, DeviceMsg.Driver_error_during_attach, t);
-
- exclude.addElement(driver);
-
- return (false);
- }
-
- storeReferral(driver, device, (referral == null) ? "" : referral); //$NON-NLS-1$
- } else {
- if (referral.length() == 0) {
- referral = null;
- }
- }
-
- if (referral == null) {
- log.log(device, LogService.LOG_INFO, NLS.bind(DeviceMsg.Device_attached_by_DRIVER_ID, drivers.get(driver)));
-
- manager.locators.usingDriverBundle(driver.getBundle());
-
- return (true);
- }
-
- log.log(device, LogService.LOG_INFO, NLS.bind(DeviceMsg.Device_referred_to, referral));
- manager.locators.loadDriver(referral, this);
- }
-
- exclude.addElement(driver);
-
- return (false);
- }
-
- public String getReferral(ServiceReference driver, ServiceReference device) {
- String driverid = getDriverID(driver);
-
- Hashtable driverReferrals = (Hashtable) referrals.get(driverid);
-
- if (driverReferrals == null) {
- return null;
- }
-
- return (String) driverReferrals.get(device);
- }
-
- public void storeReferral(ServiceReference driver, ServiceReference device, String referral) {
- String driverid = getDriverID(driver);
-
- Hashtable driverReferrals = (Hashtable) referrals.get(driverid);
-
- if (driverReferrals == null) {
- driverReferrals = new Hashtable(37);
-
- referrals.put(driverid, driverReferrals);
- }
-
- driverReferrals.put(device, referral);
- }
-
- public String toString() {
- return "DriverTracker"; //$NON-NLS-1$
- }
-
- public class DriverUpdate implements Runnable, ServiceListener, BundleListener {
- private Activator manager;
- private Bundle bundle;
- private BundleContext context;
-
- /** if false the thread must terminate */
- private volatile boolean running;
-
- private long updatewait;
-
- DriverUpdate(Bundle bundle, Activator manager) {
- this.manager = manager;
- this.bundle = bundle;
-
- context = manager.context;
- updatewait = manager.updatewait;
- running = true;
-
- context.addBundleListener(this);
- try {
- context.addServiceListener(this, manager.driverFilter.toString());
- } catch (InvalidSyntaxException e) {
- /* this should not happen */
- }
- }
-
- public void run() {
- // 1. Wait for some time
- // 2. if bundle registers Driver; terminate
- // 3. if bundle uninstalls; cancel wait
- // 4. manager.refineIdleDevices()
-
- try {
- if (updatewait > 0) {
- synchronized (this) {
- wait(updatewait);
- }
- }
- } catch (InterruptedException e) {
- }
-
- context.removeServiceListener(this);
- context.removeBundleListener(this);
-
- if (running) {
- manager.refineIdleDevices();
- }
- }
-
- public void serviceChanged(ServiceEvent event) {
- if ((event.getType() == ServiceEvent.REGISTERED) && bundle.equals(event.getServiceReference().getBundle())) {
- context.removeServiceListener(this);
-
- running = false; /* cancel */
-
- /* should probably interrupt waiting thread here */
- }
- }
-
- public void bundleChanged(BundleEvent event) {
- if ((event.getType() == Bundle.UNINSTALLED) && bundle.equals(event.getBundle())) {
- context.removeBundleListener(this);
-
- updatewait = 0; /* avoid wait */
-
- /* should probably interrupt waiting thread here */
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/ExternalMessages.properties b/bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/ExternalMessages.properties
deleted file mode 100644
index 4bdd34be3..000000000
--- a/bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/ExternalMessages.properties
+++ /dev/null
@@ -1,31 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2005 IBM Corporation.
-# 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:
-# IBM Corporation - initial API and implementation
-###############################################################################
-# NLS_MESSAGEFORMAT_ALL
-DeviceManager_started=DeviceManager started
-Device_service_unregistered=Device service unregistered
-Device_noDriverFound_called=No matching driver found for device
-Multiple_Driver_services_with_the_same_DRIVER_ID=Multiple Driver services with the same DRIVER_ID: {0}
-DeviceManager_Update_Wait=DeviceManager Update Wait
-Driver_service_has_no_DRIVER_ID_property=Driver service has no DRIVER_ID property. Using bundle location as DRIVER_ID.
-Device_attached_by_DRIVER_ID=Device attached by DRIVER_ID={0}
-Device_referred_to=Device referred to {0}
-Unable_to_create_Filter_for_DeviceManager=Unable to create Filter for DeviceManager
-DeviceManager_has_thrown_an_error=DeviceManager has thrown an error
-Device_noDriverFound_error=Device noDriverFound error
-DriverLocator_unable_to_load_driver=DriverLocator unable to load driver: {0}
-DriverLocator_error_calling_findDrivers=DriverLocator error calling findDrivers
-Unable_to_install_or_start_driver_bundle=Unable to install or start driver bundle: {0}
-Unable_to_uninstall_driver_bundle=Unable to uninstall driver bundle
-Unable_to_uninstall_driver_bundle_number=Unable to uninstall driver bundle: {0}
-DriverSelector_error_during_match=DriverSelector error during match
-Driver_service_has_no_DRIVER_ID=Driver service has no DRIVER_ID property. Using bundle location as DRIVER_ID.
-Driver_error_during_match=Driver error during match
-Driver_error_during_attach=Driver error during attach \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/LogMessages.properties b/bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/LogMessages.properties
deleted file mode 100644
index 20ad44185..000000000
--- a/bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/LogMessages.properties
+++ /dev/null
@@ -1,15 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2005 IBM Corporation.
-# 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:
-# IBM Corporation - initial API and implementation
-###############################################################################
-# NLS_MESSAGEFORMAT_ALL
-Unknown_Log_level=Unknown Log Level
-Info=Log Info
-Warning=Log Warning
-Error=Log Error \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/LogTracker.java b/bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/LogTracker.java
deleted file mode 100644
index 25debd056..000000000
--- a/bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/LogTracker.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.device;
-
-import java.io.PrintStream;
-import java.text.DateFormat;
-import java.util.Calendar;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.log.LogService;
-import org.osgi.util.tracker.ServiceTracker;
-
-/**
- * LogTracker class. This class encapsulates the LogService
- * and handles all issues such as the service coming and going.
- */
-
-public class LogTracker extends ServiceTracker implements LogService {
- /** LogService interface class name */
- protected final static String clazz = "org.osgi.service.log.LogService"; //$NON-NLS-1$
-
- /** PrintStream to use if LogService is unavailable */
- protected PrintStream out;
-
- /** Calendar and DateFormat to user if LogService is unavailable */
- private static Calendar calendar;
- private static DateFormat dateFormat;
- private String timestamp;
-
- /**
- * Create new LogTracker.
- *
- * @param context BundleContext of parent bundle.
- * @param out Default PrintStream to use if LogService is unavailable.
- */
- public LogTracker(BundleContext context, PrintStream out) {
- super(context, clazz, null);
- this.out = out;
- calendar = Calendar.getInstance();
- dateFormat = DateFormat.getDateTimeInstance();
- open();
- }
-
- /*
- * ----------------------------------------------------------------------
- * LogService Interface implementation
- * ----------------------------------------------------------------------
- */
-
- public void log(int level, String message) {
- log(null, level, message, null);
- }
-
- public void log(int level, String message, Throwable exception) {
- log(null, level, message, exception);
- }
-
- public void log(ServiceReference reference, int level, String message) {
- log(reference, level, message, null);
- }
-
- public synchronized void log(ServiceReference reference, int level, String message, Throwable exception) {
- ServiceReference[] references = getServiceReferences();
-
- if (references != null) {
- int size = references.length;
-
- for (int i = 0; i < size; i++) {
- LogService service = (LogService) getService(references[i]);
- if (service != null) {
- try {
- service.log(reference, level, message, exception);
- } catch (Exception e) {
- }
- }
- }
-
- return;
- }
-
- noLogService(level, message, exception, reference);
- }
-
- /**
- * The LogService is not available so we write the message to a PrintStream.
- *
- * @param level Logging level
- * @param message Log message.
- * @param throwable Log exception or null if none.
- * @param reference ServiceReference associated with message or null if none.
- */
- protected void noLogService(int level, String message, Throwable throwable, ServiceReference reference) {
- if (out != null) {
- synchronized (out) {
- // Bug #113286. If no log service present and messages are being
- // printed to stdout, prepend message with a timestamp.
- timestamp = dateFormat.format(calendar.getTime());
- out.print(timestamp + " "); //$NON-NLS-1$
-
- switch (level) {
- case LOG_DEBUG : {
- out.print("Debug: "); //$NON-NLS-1$
-
- break;
- }
- case LOG_INFO : {
- out.print(LogTrackerMsg.Info);
-
- break;
- }
- case LOG_WARNING : {
- out.print(LogTrackerMsg.Warning);
-
- break;
- }
- case LOG_ERROR : {
- out.print(LogTrackerMsg.Error);
-
- break;
- }
- default : {
- out.print("["); //$NON-NLS-1$
- out.print(LogTrackerMsg.Unknown_Log_level);
- out.print("]: "); //$NON-NLS-1$
-
- break;
- }
- }
-
- out.println(message);
-
- if (reference != null) {
- out.println(reference);
- }
-
- if (throwable != null) {
- throwable.printStackTrace(out);
- }
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/LogTrackerMsg.java b/bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/LogTrackerMsg.java
deleted file mode 100644
index ad023bff4..000000000
--- a/bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/LogTrackerMsg.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.device;
-
-import org.eclipse.osgi.util.NLS;
-
-public class LogTrackerMsg extends NLS {
- private static final String BUNDLE_NAME = "org.eclipse.equinox.device.LogMessages"; //$NON-NLS-1$
-
- public static String Unknown_Log_level;
- public static String Info;
- public static String Warning;
- public static String Error;
-
- static {
- // initialize resource bundles
- NLS.initializeMessages(BUNDLE_NAME, LogTrackerMsg.class);
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/Match.java b/bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/Match.java
deleted file mode 100644
index 39482e87c..000000000
--- a/bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/Match.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.device;
-
-import org.osgi.framework.ServiceReference;
-
-/**
- * Match implementation class.
- *
- */
-public class Match implements org.osgi.service.device.Match {
-
- private ServiceReference driver;
- private int matchValue;
-
- Match(ServiceReference driver, int matchValue) {
- this.driver = driver;
- this.matchValue = matchValue;
- }
-
- public ServiceReference getDriver() {
- return driver;
- }
-
- public int getMatchValue() {
- return matchValue;
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/SecureAction.java b/bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/SecureAction.java
deleted file mode 100644
index 218eed759..000000000
--- a/bundles/org.eclipse.equinox.device/src/org/eclipse/equinox/device/SecureAction.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.equinox.device;
-
-import java.security.*;
-
-/**
- * Utility class to execute common privileged code.
- */
-public class SecureAction {
- // make sure we use the correct controlContext;
- private AccessControlContext controlContext;
-
- /**
- * Constructs a new SecureAction object. The constructed SecureAction object
- * uses the caller's AccessControlContext to perform security checks
- */
- public SecureAction() {
- // save the control context to be used.
- this.controlContext = AccessController.getContext();
- }
-
- /**
- * Creates a new Thread from a Runnable. Same as calling
- * new Thread(target,name).
- * @param target the Runnable to create the Thread from.
- * @param name The name of the Thread.
- * @return The new Thread
- */
- public Thread createThread(final Runnable target, final String name) {
- if (System.getSecurityManager() == null)
- return new Thread(target, name);
- return (Thread) AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- return new Thread(target, name);
- }
- }, controlContext);
- }
-
-
-}
diff --git a/bundles/org.eclipse.equinox.ds/.classpath b/bundles/org.eclipse.equinox.ds/.classpath
deleted file mode 100644
index 751c8f2e5..000000000
--- a/bundles/org.eclipse.equinox.ds/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/bundles/org.eclipse.equinox.ds/.cvsignore b/bundles/org.eclipse.equinox.ds/.cvsignore
deleted file mode 100644
index ba077a403..000000000
--- a/bundles/org.eclipse.equinox.ds/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
diff --git a/bundles/org.eclipse.equinox.ds/.project b/bundles/org.eclipse.equinox.ds/.project
deleted file mode 100644
index cdafa4400..000000000
--- a/bundles/org.eclipse.equinox.ds/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.equinox.ds</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/bundles/org.eclipse.equinox.ds/.settings/org.eclipse.jdt.core.prefs b/bundles/org.eclipse.equinox.ds/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index f1a5108df..000000000
--- a/bundles/org.eclipse.equinox.ds/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,49 +0,0 @@
-#Fri Dec 16 09:20:00 CST 2005
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
-org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
-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=warning
-org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
-org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
-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=warning
-org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
-org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
-org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
-org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
-org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
-org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
-org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore
-org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
-org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
-org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning
-org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
-org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
-org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
-org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.unusedImport=error
-org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
-org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
-org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
-org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
diff --git a/bundles/org.eclipse.equinox.ds/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.ds/META-INF/MANIFEST.MF
deleted file mode 100644
index 7ce688ae3..000000000
--- a/bundles/org.eclipse.equinox.ds/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,28 +0,0 @@
-Bundle-ManifestVersion: 2
-Bundle-SymbolicName: org.eclipse.equinox.ds
-Bundle-Version: 1.0.0.qualifier
-Bundle-Name: %bundleName
-Bundle-Vendor: %bundleVendor
-Bundle-Copyright: %bundleCopyright
-Bundle-Activator: org.eclipse.equinox.ds.Activator
-Bundle-Localization: plugin
-Import-Package: org.eclipse.osgi.util,
- org.osgi.framework;version="1.3.0",
- org.osgi.service.cm,
- org.osgi.service.component,
- org.osgi.service.log,
- org.osgi.service.packageadmin,
- org.osgi.service.useradmin,
- org.osgi.service.wireadmin,
- org.osgi.util.tracker,
- javax.xml.parsers,
- org.xml.sax,
- org.xml.sax.helpers
-Export-Package: org.eclipse.equinox.ds;x-internal:=true,
- org.eclipse.equinox.ds.instance;x-internal:=true,
- org.eclipse.equinox.ds.model;x-internal:=true,
- org.eclipse.equinox.ds.parser;x-internal:=true,
- org.eclipse.equinox.ds.resolver;x-internal:=true,
- org.eclipse.equinox.ds.service;x-internal:=true,
- org.eclipse.equinox.ds.tracker;x-internal:=true,
- org.eclipse.equinox.ds.workqueue;x-internal:=true
diff --git a/bundles/org.eclipse.equinox.ds/about.html b/bundles/org.eclipse.equinox.ds/about.html
deleted file mode 100644
index b2f1e6bad..000000000
--- a/bundles/org.eclipse.equinox.ds/about.html
+++ /dev/null
@@ -1,22 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
-<!-- saved from url=(0043)http://www.eclipse.org/legal/epl/about.html -->
-<HTML><HEAD><TITLE>About</TITLE>
-<META http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-<META content="MSHTML 6.00.2800.1498" name=GENERATOR></HEAD>
-<BODY lang=EN-US>
-<H2>About This Content</H2>
-<P>February 24, 2005</P>
-<H3>License</H3>
-<P>The Eclipse Foundation makes available all content in this plug-in
-("Content"). Unless otherwise indicated below, the Content is provided to you
-under the terms and conditions of the Eclipse Public License Version 1.0
-("EPL"). A copy of the EPL is available at <A
-href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</A>.
-For purposes of the EPL, "Program" will mean the Content.</P>
-<P>If you did not receive this Content directly from the Eclipse Foundation, the
-Content is being redistributed by another party ("Redistributor") and different
-terms and conditions may apply to your use of any object code in the Content.
-Check the Redistributor's license that was provided with the Content. If no such
-license exists, contact the Redistributor. Unless otherwise indicated below, the
-terms and conditions of the EPL still apply to any source code in the
-Content.</P></BODY></HTML>
diff --git a/bundles/org.eclipse.equinox.ds/build.properties b/bundles/org.eclipse.equinox.ds/build.properties
deleted file mode 100644
index 5d98e3008..000000000
--- a/bundles/org.eclipse.equinox.ds/build.properties
+++ /dev/null
@@ -1,17 +0,0 @@
-###############################################################################
-# Copyright (c) 2005 IBM Corporation.
-# 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:
-# IBM Corporation - initial API and implementation
-###############################################################################
-bin.includes = META-INF/,\
- plugin*.properties,\
- about.html,\
- .
-src.includes = about.html
-source.. = src/
-output.. = bin/ \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.ds/plugin.properties b/bundles/org.eclipse.equinox.ds/plugin.properties
deleted file mode 100644
index 9676e2481..000000000
--- a/bundles/org.eclipse.equinox.ds/plugin.properties
+++ /dev/null
@@ -1,13 +0,0 @@
-###############################################################################
-# Copyright (c) 2005 IBM Corporation.
-# 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:
-# IBM Corporation - initial API and implementation
-###############################################################################
-bundleVendor = Eclipse.org
-bundleName = Declarative Services
-bundleCopyright = Copyright (c) IBM Corp. 2005
diff --git a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/AbstractReflector.java b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/AbstractReflector.java
deleted file mode 100644
index 78a378e67..000000000
--- a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/AbstractReflector.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.ds;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-/**
- * Base class which provides reflection support methods.
- *
- * @version $Revision: 1.2 $
- */
-abstract class AbstractReflector {
-
- /**
- * Locate and invoke the specified method.
- *
- * @param object Object or Class upon which to call the method.
- * @param methodName The name of the method.
- * @param params The formal parameter types of the method.
- * @param args The arguments for the method call.
- * @return The return value of the method.
- */
- protected Object invokeMethod(Object object, String methodName, Class[] params, Object[] args) {
- Class clazz;
- if (object instanceof Class) {
- clazz = (Class) object;
- object = null;
- } else {
- clazz = object.getClass();
- }
-
- Method method = getMethod(clazz, methodName, params);
- try {
- return method.invoke(object, args);
- } catch (IllegalAccessException e) {
- reflectionException(e);
- } catch (InvocationTargetException e) {
- reflectionException(e);
- }
-
- return null;
- }
-
- /**
- * Locate the specified method.
- *
- * @param clazz Class upon which to locate the method.
- * @param methodName The name of the method.
- * @param params The formal parameter types of the method.
- * @return The method.
- */
- private Method getMethod(Class clazz, String methodName, Class[] params) {
- Exception exception = null;
- for (; clazz != null; clazz = clazz.getSuperclass()) {
- try {
- Method method = clazz.getDeclaredMethod(methodName, params);
- // enable us to access the method if not public
- method.setAccessible(true);
- return method;
- } catch (NoSuchMethodException e) {
- exception = e;
- continue;
- }
- }
-
- reflectionException(exception);
- return null;
- }
-
- //
- // /**
- // * Locate and return the value of the specified field.
- // *
- // * @param object Object or Class upon which to locate the field.
- // * @param fieldName The name of the field.
- // * @return The value of the field.
- // */
- // protected Object getFieldValue(Object object, String fieldName) {
- // Class clazz;
- // if (object instanceof Class) {
- // clazz = (Class) object;
- // object = null;
- // }
- // else {
- // clazz = object.getClass();
- // }
- //
- // Field field = getField(clazz, fieldName);
- // try {
- // return field.get(object);
- // }
- // catch (IllegalAccessException e) {
- // reflectionException(e);
- // }
- //
- // return null;
- // }
- //
- // /**
- // * Locate the specified field.
- // *
- // * @param clazz Class upon which to locate the field.
- // * @param fieldName The name of the field.
- // * @return The field.
- // */
- // private Field getField(Class clazz, String fieldName) {
- // Exception exception = null;
- // for (; clazz != null; clazz = clazz.getSuperclass()) {
- // try {
- // Field field = clazz.getDeclaredField(fieldName);
- // // enable us to access the field if not public
- // field.setAccessible(true);
- // return field;
- // }
- // catch (NoSuchFieldException e) {
- // exception = e;
- // continue;
- // }
- // }
- //
- // reflectionException(exception);
- // return null;
- // }
-
- /**
- * Abstract method called when a reflection exception occurs.
- *
- * @param e Exception which indicates the reflection logic is confused.
- */
- protected abstract void reflectionException(Exception e);
-
-}
diff --git a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/Activator.java b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/Activator.java
deleted file mode 100644
index b939f0eb4..000000000
--- a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/Activator.java
+++ /dev/null
@@ -1,390 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.ds;
-
-import java.util.*;
-import org.eclipse.equinox.ds.model.ComponentDescription;
-import org.eclipse.equinox.ds.model.ComponentDescriptionCache;
-import org.eclipse.equinox.ds.resolver.Resolver;
-import org.eclipse.equinox.ds.tracker.BundleTracker;
-import org.eclipse.equinox.ds.tracker.BundleTrackerCustomizer;
-import org.eclipse.equinox.ds.workqueue.WorkDispatcher;
-import org.eclipse.equinox.ds.workqueue.WorkQueue;
-import org.osgi.framework.*;
-import org.osgi.service.packageadmin.PackageAdmin;
-import org.osgi.util.tracker.ServiceTracker;
-
-/**
- *
- * Main class for the SCR. This class will start the SCR bundle and begin
- * processing other bundles.
- *
- * @version $Revision: 1.1 $
- */
-public class Activator implements BundleActivator, BundleTrackerCustomizer, WorkDispatcher {
-
- public BundleContext context;
- private FrameworkHook framework;
- private ComponentDescriptionCache cache;
- private BundleTracker bundleTracker;
- public Resolver resolver;
- private ServiceTracker packageAdminTracker;
- public WorkQueue workQueue;
-
- private Hashtable bundleToComponentDescriptions;
- private Hashtable bundleToLastModified;
-
- /**
- * New Service Components (ComponentDescription)s are added
- */
- public static final int ADD = 1;
-
- /**
- * Start the SCR bundle.
- *
- * @param bundleContext BundleContext for SCR implementation.
- */
- public void start(BundleContext bundleContext) {
- this.context = bundleContext;
- framework = new FrameworkHook();
- Log.init(context);
- cache = new ComponentDescriptionCache(this);
- bundleToComponentDescriptions = new Hashtable();
- bundleToLastModified = new Hashtable();
-
- packageAdminTracker = new ServiceTracker(context, PackageAdmin.class.getName(), null);
- packageAdminTracker.open();
-
- //notify this object when bundles enter (or exit) the Bundle.ACTIVE state
- bundleTracker = new BundleTracker(context, Bundle.ACTIVE, this);
-
- workQueue = new WorkQueue("SCR Work Queue"); //$NON-NLS-1$
- workQueue.setDaemon(true); // make sure the work queue is daemon
- resolver = new Resolver(this);
- workQueue.start();
- bundleTracker.open();
- }
-
- /**
- * Stop the SCR bundle.
- *
- * @param bundleContext BundleContext for SCR implementation.
- */
- public void stop(BundleContext bundleContext) {
-
- bundleTracker.close();
-
- //process all remaining events in queue and then shut it down
- workQueue.closeAndJoin();
-
- resolver.dispose();
- packageAdminTracker.close();
-
- //shut down cache (write to disk)
- cache.dispose();
-
- Log.dispose();
-
- cache = null;
- framework = null;
- resolver = null;
- bundleToComponentDescriptions = null;
- bundleToLastModified = null;
- this.context = null;
- }
-
- /**
- * Returns the bundle's Service-Component manifest header. If the bundle
- * has header, then the bundle will be tracked. If not, null is returned
- * and the bundle will not be tracked.
- *
- * If the bundle contains service components, parse the service component xml
- * file(s) and create an {@link ComponentDescription ComponentDescription} object for every service
- * component in the bundle. Add the {@link ComponentDescription ComponentDescriptions} to
- * the queue to be sent to the resolver.
- *
- * @param bundle Candidate bundle to be tracked.
- * @return the bundle's Service-Component manifest header or null if the
- * bundle does not specify the header.
- */
- public Object addingBundle(Bundle bundle) {
-
- List enableComponentDescriptions = new ArrayList();
-
- PackageAdmin packageAdmin = (PackageAdmin) packageAdminTracker.getService();
- if (packageAdmin.getBundleType(bundle) != 0) {
- return null; // don't process fragments.
- }
-
- Long bundleID = new Long(bundle.getBundleId());
-
- // get the bundle's last modified date
- Long bundleLastModified = new Long(bundle.getLastModified());
-
- // get the last saved value for the bundle's last modified date
- Long bundleOldLastModified = (Long) bundleToLastModified.get(bundleID);
-
- // compare the two and if changed ( or if first time ) update the maps
- if ((!bundleLastModified.equals(bundleOldLastModified)) || (bundleOldLastModified == null)) {
-
- // get the BundleContext for this bundle (framework impl dependent)
- BundleContext bundleContext = framework.getBundleContext(bundle);
-
- // get all ComponentDescriptions for this bundle
- List componentDescriptions = cache.getComponentDescriptions(bundleContext);
-
- // update map of bundle to ComponentDescriptions
- bundleToComponentDescriptions.put(bundleID, componentDescriptions);
-
- // update bundle:lastModifiedDate map
- bundleToLastModified.put(bundleID, bundleLastModified);
-
- // for each CD in bundle set enable flag based on autoenable
-
- Iterator it = componentDescriptions.iterator();
- while (it.hasNext()) {
- ComponentDescription componentDescription = (ComponentDescription) it.next();
- validate(componentDescription);
- if (componentDescription.isAutoenable() && componentDescription.isValid()) {
- componentDescription.setEnabled(true);
- enableComponentDescriptions.add(componentDescription);
- }
- }
- }
-
- // publish all CDs to be enabled, to resolver (add to the workqueue and
- // publish event)
- if (!enableComponentDescriptions.isEmpty()) {
- workQueue.enqueueWork(this, ADD, enableComponentDescriptions);
- }
- return bundleID;
- }
-
- /**
- * Empty implementation. No work is needed for modifiedBundle.
- *
- * @param bundle
- * @param object
- */
- public void modifiedBundle(Bundle bundle, Object object) {
-
- Long bundleID = new Long(bundle.getBundleId());
-
- // flush map
- bundleToComponentDescriptions.remove(bundleID);
-
- // flush map
- bundleToLastModified.remove(bundleID);
-
- }
-
- /**
- * A bundle is going to an in-ACTIVE state. Dispose and remove it's service
- * components from the system. Disposal is done synchronously so all of the
- * service components have been disposed before this method returns.
- *
- * @param bundle Bundle becoming untracked.
- * @param object Value returned by addingBundle.
- */
-
- public void removedBundle(Bundle bundle, Object object) {
-
- List disableComponentDescriptions = new ArrayList();
- Long bundleID = new Long(bundle.getBundleId());
-
- // get CD's for this bundle
- List ComponentDescriptions = (List) bundleToComponentDescriptions.get(new Long(bundle.getBundleId()));
- if (ComponentDescriptions != null) {
- Iterator it = ComponentDescriptions.iterator();
-
- // for each CD in bundle
- while (it.hasNext()) {
- ComponentDescription ComponentDescription = (ComponentDescription) it.next();
-
- // check if enabled && satisfied
- if ((ComponentDescription.isEnabled())) {
-
- // add to disabled list
- disableComponentDescriptions.add(ComponentDescription);
-
- // mark disabled
- ComponentDescription.setEnabled(false);
- }
- }
- }
-
- // remove the bundle from the lists/maps
- bundleToComponentDescriptions.remove(bundleID);
- bundleToLastModified.remove(bundleID);
-
- resolver.disableComponents(disableComponentDescriptions);
- return;
- }
-
- /**
- * Called by Service Component code via ComponentContext
- *
- * Enable the component(s) and put them on the queue for the resolver.
- *
- * @param name The name of a component or <code>null</code> to indicate
- * all components in the bundle.
- *
- * @param bundle The bundle which contains the Service Component to be
- * enabled
- */
- public void enableComponent(String name, Bundle bundle) {
-
- // get all ComponentDescriptions for this bundle
- List componentDescriptions = (List) bundleToComponentDescriptions.get(new Long(bundle.getBundleId()));
-
- // Create the list of CD's to be enabled
- List enableCDs = new ArrayList();
-
- if (componentDescriptions != null) {
- Iterator it = componentDescriptions.iterator();
-
- // for each CD in list
- while (it.hasNext()) {
- ComponentDescription componentDescription = (ComponentDescription) it.next();
- validate(componentDescription);
-
- // if name is null then enable ALL Component Descriptions in
- // this bundle
- if (name == null) {
-
- // if CD is valid and is disabled then enable it
- if (componentDescription.isValid() && !componentDescription.isEnabled()) {
-
- // add to list of CDs to enable
- enableCDs.add(componentDescription);
-
- // set CD enabled
- componentDescription.setEnabled(true);
- }
- } else {
- if (componentDescription.getName().equals(name)) {
-
- // if CD is valid and is disabled then enable it
- if (componentDescription.isValid() && !componentDescription.isEnabled()) {
-
- // add to list of CDs to enable
- enableCDs.add(componentDescription);
-
- // set CD enabled
- componentDescription.setEnabled(true);
- }
- }
- }
- // else it is either not valid or it is already enabled - do
- // nothing
- }
- }
-
- // publish to resolver the list of CDs to enable
- if (!enableCDs.isEmpty())
- workQueue.enqueueWork(this, ADD, enableCDs);
- }
-
- /**
- * Disable a Service Component - The specified component name must be in the
- * bundle as this component. Called by Service Component via ComponentContext.
- *
- * Synchronously disable the component. All component configurations (CDPs)
- * are disposed before this method returns.
- *
- * @param name The name of a component to disable
- *
- * @param bundle The bundle which contains the Service Component to be
- * disabled
- */
-
- public void disableComponent(String name, Bundle bundle) {
-
- List disableComponentDescriptions = new ArrayList();
-
- // Get the list of CDs for this bundle
- List componentDescriptionsList = (List) bundleToComponentDescriptions.get(new Long(bundle.getBundleId()));
-
- if (componentDescriptionsList != null) {
- Iterator it = componentDescriptionsList.iterator();
-
- // for each ComponentDescription in list
- while (it.hasNext()) {
- ComponentDescription componentDescription = (ComponentDescription) it.next();
-
- // find the ComponentDescription with the specified name
- if (componentDescription.getName().equals(name)) {
-
- // if enabled then add to disabled list and mark disabled
- if (componentDescription.isEnabled()) {
-
- disableComponentDescriptions.add(componentDescription);
-
- componentDescription.setEnabled(false);
-
- }
- }
- }
- }
-
- // publish to resolver the list of CDs to disable
- resolver.disableComponents(disableComponentDescriptions);
- return;
- }
-
- /**
- * Put a job on the work queue to be done later (asynchronously) by the work
- * queue thread.
- * @param workAction currently only valid value is Main.ADD
- * @param workObject work object to be acted upon
- * @see org.eclipse.equinox.ds.workqueue.WorkDispatcher#dispatchWork(int,
- * java.lang.Object)
- */
- public void dispatchWork(int workAction, Object workObject) {
-
- List descriptions;
- descriptions = (List) workObject;
- switch (workAction) {
- case ADD :
- resolver.enableComponents(descriptions);
- break;
- }
- }
-
- /**
- * Validate the Component Description
- *
- * If error is found log and throw exception.
- *
- * @param cd to be validated
- * @throws Throwable if fatal problem is found
- */
- private void validate(ComponentDescription componentDescription) {
-
- if ((componentDescription.getFactory() != null) && (componentDescription.getService() != null) && (componentDescription.getService().isServicefactory())) {
- componentDescription.setValid(false);
- Log.log(1, "validate cd: ", new Throwable("invalid to specify both ComponentFactory and ServiceFactory"));
- } else if ((componentDescription.isImmediate()) && (componentDescription.getService() != null) && (componentDescription.getService().isServicefactory())) {
- componentDescription.setValid(false);
- Log.log(1, "validate cd: ", new Throwable("invalid to specify both immediate and ServiceFactory"));
- } else if ((componentDescription.isImmediate()) && (componentDescription.getFactory() != null)) {
- componentDescription.setValid(false);
- Log.log(1, "validate cd: ", new Throwable("invalid to specify both immediate and ComponentFactory"));
- } else if ((!componentDescription.isImmediate()) && (componentDescription.getService() == null) && (componentDescription.getFactory() == null)) {
- componentDescription.setValid(false);
- Log.log(1, "validate cd: ", new Throwable("invalid set immediate to false and provide no Service"));
- } else {
- componentDescription.setValid(true);
- }
-
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/FrameworkHook.java b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/FrameworkHook.java
deleted file mode 100644
index e372521b8..000000000
--- a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/FrameworkHook.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.ds;
-
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-
-/**
- * This class provide implementation hooks into the Eclipse OSGi framework
- * implementation. This class must be modified to connect SCR with other
- * framework implementations.
- *
- * @version $Revision: 1.2 $
- */
-class FrameworkHook extends AbstractReflector {
- /**
- * Return the BundleContext for the specified bundle.
- *
- * @param bundle The bundle whose BundleContext is desired.
- * @return The BundleContext for the specified bundle.
- */
- BundleContext getBundleContext(final Bundle bundle) {
- if (System.getSecurityManager() == null) {
- return (BundleContext) invokeMethod(bundle, "getContext", null, null); //$NON-NLS-1$
- }
- return (BundleContext) AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- return invokeMethod(bundle, "getContext", null, null); //$NON-NLS-1$
- }
- });
- }
-
- /**
- * Throws an IllegalStateException if the reflection logic cannot find what
- * it is looking for. This probably means this class does not properly
- * recognize the framework implementation.
- *
- * @param e Exception which indicates the reflection logic is confused.
- */
- protected void reflectionException(Exception e) {
- throw new IllegalStateException("FrameworkHook does not recognize the framework implementation: " + e.getMessage());
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/Log.java b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/Log.java
deleted file mode 100644
index 94f00bf8f..000000000
--- a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/Log.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.ds;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.service.log.LogService;
-import org.osgi.util.tracker.ServiceTracker;
-
-/**
- * Utility class with static methods for logging to LogService, if available
- *
- * @version $Revision: 1.2 $
- */
-public class Log {
- static private ServiceTracker logTracker;
-
- private Log() {
- };
-
- static void init(BundleContext bc) {
- logTracker = new ServiceTracker(bc, LogService.class.getName(), null);
- logTracker.open();
- }
-
- static void dispose() {
- if (logTracker != null) {
- logTracker.close();
- }
- logTracker = null;
- }
-
- public static void log(int level, String message) {
- log(level, message, null);
- }
-
- public static void log(int level, String message, Throwable e) {
- LogService logService = (LogService) logTracker.getService();
- if (logService != null) {
- logService.log(level, message, e);
- }
- }
-
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/instance/BuildDispose.java b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/instance/BuildDispose.java
deleted file mode 100644
index 6a6e11769..000000000
--- a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/instance/BuildDispose.java
+++ /dev/null
@@ -1,717 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.ds.instance;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.*;
-import org.eclipse.equinox.ds.Activator;
-import org.eclipse.equinox.ds.Log;
-import org.eclipse.equinox.ds.model.*;
-import org.eclipse.equinox.ds.resolver.Reference;
-import org.eclipse.equinox.ds.resolver.Resolver;
-import org.eclipse.equinox.ds.service.ComponentContextImpl;
-import org.eclipse.equinox.ds.service.ComponentInstanceImpl;
-import org.osgi.framework.*;
-import org.osgi.service.component.*;
-
-/**
- * This class provides the following function
- *
- * Build of a component instance - includes activate, bind, instantiate. Dispose
- * of a component instance - includes deactivate, unbind, unreference.
- *
- */
-public class BuildDispose {
-
- private InvokeMethod invoke;
-
- /**
- * Counts re-entry in to the
- * {@link BuildDispose#buildComponentConfigInstance(Bundle, ComponentDescriptionProp)} method. This
- * is used to handle circular dependencies.
- */
- private int stackCount;
-
- /**
- * Used with stackCount to handle circular dependencies in the
- * {@link BuildDispose#buildComponentConfigInstance(Bundle, ComponentDescriptionProp)} method.
- */
- private List delayedBindList;
-
- /** Main SCR class */
- private Activator main;
-
- /**
- * @param main Main SCR class
- */
- BuildDispose(Activator main) {
- invoke = new InvokeMethod(this);
- this.main = main;
- stackCount = 0;
- delayedBindList = new ArrayList();
- }
-
- /**
- * dispose - cleanup since the SCR is shutting down
- */
- void dispose() {
- synchronized (this) {
- invoke = null;
- main = null;
- }
- }
-
- /**
- * Create an instance of a Component Configuration ({@link ComponentDescriptionProp}).
- * Instantiate the Service Component implementation class and create a
- * {@link ComponentInstanceImpl} to track it. Create a
- * {@link ComponentContext},
- * {@link BuildDispose#bind(ComponentDescriptionProp, ComponentInstanceImpl) bind}
- * the Service Component's references and call the implementation class'
- * "activate" method.
- *
- * This method also handles possible circluarities. The method is re-entrant
- * and tracks how many times we have entered the method. If a possible
- * circularity is encountered while binding references (it is detected
- * earlier by the resolver) then the bind action is delayed until the last
- * time we exit this method to "break" the cirularity. See the OSGi R4
- * specification section 112.3.5 for more information about Cirular
- * References.
- *
- * @param usingBundle - if this Component Instance is being created to
- * return from a BundleContext.getService() call, this is the bundle
- * which is "using" this instance. Otherwise null.
- *
- * @param cdp - Component Configuration to create an instance of
- *
- * @throws ComponentException
- *
- * @return ComponentInstance
- *
- */
-
- public ComponentInstance buildComponentConfigInstance(Bundle usingBundle, ComponentDescriptionProp cdp) throws ComponentException {
-
- synchronized (this) {
-
- // keep track of how many times we have re-entered this method
- stackCount++;
-
- ComponentInstanceImpl componentInstance = null;
-
- try {
- ComponentDescription componentDescription = cdp.getComponentDescription();
-
- Object instance = createInstance(componentDescription);
-
- componentInstance = instantiate(cdp, instance);
-
- createComponentContext(usingBundle, componentInstance);
-
- bind(componentInstance);
-
- activate(componentInstance);
-
- cdp.addInstance(componentInstance);
-
- } catch (ComponentException e) {
- Log.log(1, "[SCR] Error attempting to build component ", e);
- throw e;
-
- } finally {
-
- // keep track of how many times we have re-entered this method
- stackCount--;
-
- }
-
- // if this is the last time in this method and we have "delayed"
- // bind
- // actions to do (there was a circularity during bind)
- if (stackCount == 0 && !delayedBindList.isEmpty()) {
- // put delayed dynamic binds on the queue.
- // (this is used to handle circularity)
- main.resolver.instanceProcess.workQueue.enqueueWork(main.resolver, Resolver.DYNAMICBIND, ((ArrayList) delayedBindList).clone());
- delayedBindList.clear();
- }
-
- return componentInstance;
- } // end synchronized(this)
- }
-
- /**
- * Dispose of a Component Configuration.
- *
- * Unregister this Component Configuration's service, if it has one.
- *
- * Call
- * {@link BuildDispose#disposeComponentInstance(ComponentDescriptionProp, ComponentInstance)}
- * for each instance of this Component Configuration. * Dispose of the
- * {@link ComponentDescriptionProp} object.
- *
- * Synchronously dispose of this Component Configuration. This method will
- * not return until all instances of this Component Configuration are
- * disposed.
- *
- * @param cdp Component Configuration to dispose
- */
- void disposeComponentConfig(ComponentDescriptionProp cdp) {
-
- synchronized (this) {
- // unregister this cdp's service
- ServiceRegistration serviceRegistration = cdp.getServiceRegistration();
- if (serviceRegistration != null) {
- try {
- serviceRegistration.unregister();
- } catch (IllegalStateException e) {
- // service has already been unregistered, no problem
- }
- }
-
- // get all instances for this component
- Iterator it = cdp.getInstances().iterator();
- while (it.hasNext()) {
- disposeComponentInstance((ComponentInstanceImpl) it.next());
- }
- cdp.removeAllInstances();
-
- // clean up this CDP object
- it = cdp.getReferences().iterator();
- while (it.hasNext()) {
- Reference reference = (Reference) it.next();
-
- reference.clearServiceReferences();
- }
- cdp.clearDelayActivateCDPNames();
- }
- }
-
- /**
- * Dispose of the Component Instance.
- *
- * Deactivate the instance, call unbind methods, and release any services it
- * was using.
- *
- * Synchronously disposes of a Component Configuration instance. This method
- * does not return until the instance has been deactivated and unbound, and
- * any services used by the instance have been released.
- *
- * @param ci instance of cdp to dispose
- */
- public void disposeComponentInstance(ComponentInstance ci) {
-
- synchronized (this) {
- ComponentInstanceImpl componentInstance = (ComponentInstanceImpl) ci;
- deactivate(componentInstance);
- unbind(componentInstance);
-
- // if this was the last instance of the CDP, make sure we unget
- // any lingering references, just in case
- ComponentDescriptionProp cdp = componentInstance.getComponentDescriptionProp();
- if (cdp.getInstances().isEmpty()) {
- BundleContext context = cdp.getComponentDescription().getBundleContext();
- Iterator referenceItr = cdp.getReferences().iterator();
- while (referenceItr.hasNext()) {
- Reference reference = (Reference) referenceItr.next();
-
- Iterator serviceReferenceItr = reference.getServiceReferences().iterator();
- while (serviceReferenceItr.hasNext()) {
- context.ungetService((ServiceReference) serviceReferenceItr.next());
-
- }
- }
- }
-
- componentInstance = null;
- }
- }
-
- /**
- * Instantiate an instance of the implementation class of this Service
- * Component
- *
- * @param cd Service Component
- *
- * @return an instance of the implementation class of cd
- *
- * @throws ComponentException and logs an error if there is an exception
- * loading the class or instantiating the instance
- *
- */
-
- private Object createInstance(ComponentDescription cd) throws ComponentException {
- Object instance = null;
- String classname = cd.getImplementation().getClassname();
- try {
- instance = cd.getBundleContext().getBundle().loadClass(classname).newInstance();
- } catch (IllegalAccessException e) {
- Log.log(1, "[SCR] IllegalAccessException attempting to create instance ", e);
- throw new ComponentException(e.getMessage());
- } catch (ClassNotFoundException e) {
- Log.log(1, "[SCR] ClassNotFoundException attempting to create instance. ", e);
- throw new ComponentException(e.getMessage());
- } catch (InstantiationException e) {
- Log.log(1, "[SCR] InstantiationException attempting to create instance. ", e);
- throw new ComponentException(e.getMessage());
- }
-
- return instance;
- }
-
- /**
- * Create a ComponentInstanceImpl object to track an instance of a Component
- * Configuration's implementation class.
- *
- * @param cdp Component Configuration
- *
- * @param instance instance of Component Configuration's implementation
- * class to track
- *
- * @return ComponentInstanceImpl
- *
- */
- private ComponentInstanceImpl instantiate(ComponentDescriptionProp cdp, Object instance) {
- return new ComponentInstanceImpl(main, cdp, instance);
- }
-
- /**
- * Acquire and bind services for this Component Configuration instance.
- *
- * Calls
- * {@link BuildDispose#bindReference(Reference, ComponentInstanceImpl)} for
- * each reference in the Component Configuration that has a bind method.
- *
- * @param componentInstance instance to bind
- *
- */
- private void bind(ComponentInstanceImpl componentInstance) {
- // Get all the required service Reference Descriptions for this Service
- // Component
- // bind them in order
- List references = componentInstance.getComponentDescriptionProp().getReferences();
- // call the Bind method if the Reference Description includes one
- Iterator itr = references.iterator();
- while (itr.hasNext()) {
- Reference reference = (Reference) itr.next();
- if (reference.getReferenceDescription().getBind() != null) {
- bindReference(reference, componentInstance);
- }
- }
- }
-
- /**
- * Try to acquire a service and call the bind method on a Component
- * Configuration instance for a reference.
- *
- * If the reference's cardinality is 0..n or 1..n, bind will be called for
- * each registered service which satisfies the reference. If the cardinality
- * is 0..1 or 1..1, bind will be called with the service that has the
- * highest service.ranking and service.id
- *
- * If an exception occurs during bind, we log an error and continue.
- *
- * @param reference Reference to bind
- *
- * @param componentInstance Component Configuration instance to call bind
- * methods on.
- *
- */
- void bindReference(Reference reference, ComponentInstanceImpl componentInstance) {
- synchronized (this) {
- ServiceReference[] serviceReferences = null;
- // if there is a published service, then get the ServiceObject and
- // call bind
- try {
- // get All Registered services using this target filter
- serviceReferences = componentInstance.getComponentContext().getBundleContext().getServiceReferences(reference.getReferenceDescription().getInterfacename(), reference.getTarget());
-
- // If a bind method throws an exception, SCR must log an error
- // message containing the exception with the Log Service but
- // the activation of the component configuration does not fail.
- } catch (InvalidSyntaxException e) {
- Log.log(1, "[SCR] InvalidSyntaxException attempting to bindReference ", e);
- }
-
- // if cardinality is 0..1 or 0..n, it is OK if there is nothing to
- // bind with
- if (!reference.getReferenceDescription().isRequired() && serviceReferences == null) {
- // that's OK
- return;
- }
-
- // sort by service ranking and service id
- Arrays.sort(serviceReferences);
-
- // we only want to bind one service
- if (reference.getReferenceDescription().getCardinalityHigh() == 1) {
- bindServiceToReference(reference, serviceReferences[0], componentInstance);
- // here we can bind more than one service, if availible
- } else {
- for (int j = 0; j < serviceReferences.length; j++) {
- bindServiceToReference(reference, serviceReferences[j], componentInstance);
- }
- }
- } // end synchronized(this)
-
- }
-
- /**
- * Bind a Component Configuration instance to a particular
- * {@link ServiceReference}.
- *
- * @param reference
- *
- * @param serviceReference
- *
- * @param componentInstance
- *
- */
- private void bindServiceToReference(Reference reference, ServiceReference serviceReference, ComponentInstanceImpl componentInstance) {
- ReferenceDescription rd = reference.getReferenceDescription();
- // make sure we have not already bound this object
- if (!reference.bindedToServiceReference(serviceReference) && rd.getBind() != null) {
-
- try {
- //only look up bind method once
- Method method = rd.getBindMethod();
- if (method == null) {
- method = invoke.findBindOrUnbindMethod(componentInstance, reference, serviceReference, rd.getBind());
- rd.setBindMethod(method);
- }
- if (method == null) {
- // could be circularity break
- return;
- }
- Object param = null;
- if (method.getParameterTypes()[0].equals(ServiceReference.class)) {
- param = serviceReference;
- } else {
- // componentInstance.getServiceObject(...) is populated by
- // the findBindOrUnbindMethod function
- param = reference.getServiceObject(serviceReference);
-
- // ... but not if the bind method was cached
- if (param == null) {
- param = getService(reference, serviceReference);
- if (param == null) {
- // could be circularity break
- return;
- }
- reference.addServiceReference(serviceReference, param);
- }
- }
-
- invoke.bindComponent(method, componentInstance.getInstance(), param);
- // If a bind method throws an exception, SCR must log an error
- // message containing
- // the exception with the Log Service but the activation of the
- // component configuration does not fail.
- } catch (IllegalAccessException e) {
- Log.log(1, "[SCR] IllegalAccessException attempting to bind Service to Reference ", e);
- } catch (InvocationTargetException e) {
- Log.log(1, "[SCR] InvocationTargetException attempting to bind Service to Reference ", e);
-
- }
-
- // track this serviceReference so we know to unbind it later
- reference.addServiceReference(serviceReference);
- }
- }
-
- /**
- * Acquire a service object from a {@link ServiceReference}.
- *
- * This method checks if "getting" the service could cause a cycle. If so,
- * it breaks the cycle and returns null.
- *
- * @param consumerCDP Component Configuration which wants to acquire the
- * service
- * @param reference
- * @param serviceReference
- *
- * @return the service object or null if it would cause a circularity
- */
- public Object getService(Reference reference, ServiceReference serviceReference) {
- // check if getting this service would cause a circularity
- if (couldCauseCycle(reference, serviceReference)) {
- return null;
- }
-
- // getting this service will not cause a circularity
- return reference.getComponentDescriptionProp().getComponentDescription().getBundleContext().getService(serviceReference);
-
- }
-
- /**
- * Check the "cycle list" put in the cdp by the resolver to see if getting
- * this reference would cause a circularity.
- *
- * A circularity is only possible if the "producer" of the service is also a
- * service component.
- *
- * If getting the service could cause a circularity and the reference's
- * policy is "dynamic", add an entry to the "delayed bind table" which is
- * processed farther up the call stack by the
- * {@link BuildDispose#buildComponentConfigInstance(Bundle, ComponentDescriptionProp)} method.
- *
- * @param consumerCDP
- * @param reference
- * @param serviceReference
- * @return if getting the service could cause a circularity
- */
- private boolean couldCauseCycle(Reference reference, ServiceReference serviceReference) {
-
- ComponentDescriptionProp consumerCDP = reference.getComponentDescriptionProp();
- // if we are not building a component, no cycles possible
- if (stackCount == 0) {
- return false;
- }
-
- String producerComponentName = (String) serviceReference.getProperty(ComponentConstants.COMPONENT_NAME);
-
- // if producer is not a service component, no cycles possible
- if (producerComponentName == null) {
- return false;
- }
-
- // check if producer is on our "do not activate" list
- if (!consumerCDP.getDelayActivateCDPNames().contains(producerComponentName)) {
- return false;
- }
-
- // find producer cdp
- ComponentDescriptionProp producerCDP = null;
- Iterator it = main.resolver.satisfiedCDPs.iterator();
- while (it.hasNext()) {
- ComponentDescriptionProp cdp = (ComponentDescriptionProp) it.next();
- if (producerComponentName.equals(cdp.getComponentDescription().getName())) {
- // found the producer cdp
- producerCDP = cdp;
- break;
- }
- }
-
- if (producerCDP.getComponentDescription().getService().isServicefactory()) {
- // producer is a service factory - there is a new instance for every
- // bundle, so see if one of the instances is used by this bundle
- it = producerCDP.getInstances().iterator();
- Bundle bundle = consumerCDP.getComponentDescription().getBundleContext().getBundle();
- while (it.hasNext()) {
- ComponentInstanceImpl producerComponentInstance = (ComponentInstanceImpl) it.next();
- if (producerComponentInstance.getComponentContext().getUsingBundle().equals(bundle)) {
- // a producer already exists, so no cycle possible
- return false;
- }
- }
- } else {
- // producer is not a service factory - there will only ever be one
- // instance - if it exists then no cycle possible
- if (!producerCDP.getInstances().isEmpty()) {
- return false;
- }
- }
-
- // producer cdp is not active - do not activate it because that could
- // cause circularity
-
- // if reference has bind method and policy=dynamic, activate later and
- // bind
- if (reference.getReferenceDescription().getBind() != null && reference.getReferenceDescription().getPolicy().equalsIgnoreCase("dynamic")) {
- // delay bind by putting on the queue later
- delayedBindList.add(reference);
- }
-
- // can't get service now because of circularity - we will bind later
- // (dynamically) if the reference had a bind method and was dynamic
- return true;
- }
-
- /**
- * Call the unbind method for each of the Referenced Services in a Component
- * Configuration instance
- *
- * @param componentInstance
- */
- private void unbind(ComponentInstanceImpl componentInstance) {
- // Get all the required service reference descriptions for this Service
- // Component
- List references = componentInstance.getComponentDescriptionProp().getReferences();
- // call the unBind method if the Reference Description includes one
- // unbind in reverse order
- ListIterator itr = references.listIterator(references.size());
- while (itr.hasPrevious()) {
- unbindReference((Reference) itr.previous(), componentInstance);
- }
- }
-
- /**
- * Call the unbind method for each {@link ServiceReference} bound to a
- * Reference for a Component Configuration instance
- *
- * @param reference
- * @param componentInstance
- */
- private void unbindReference(Reference reference, ComponentInstanceImpl componentInstance) {
- Iterator itr = reference.getServiceReferences().iterator();
- while (itr.hasNext()) {
- ServiceReference serviceReference = (ServiceReference) itr.next();
- unbindServiceFromReference(reference, componentInstance, serviceReference);
- }
- }
-
- /**
- * Dynamically unbind a reference from a Component Configuration instance.
- *
- * First try to re-bind to a new reference as described in the OSGi R4
- * specification section 112.5.10 "Bound Service Replacement"
- *
- * @param reference
- * @param componentInstance
- * @param serviceReference
- */
- void unbindDynamicReference(Reference reference, ComponentInstanceImpl componentInstance, ServiceReference serviceReference) {
- synchronized (this) {
- // rebind if we can
- bindReference(reference, componentInstance);
-
- unbindServiceFromReference(reference, componentInstance, serviceReference);
-
- }
-
- }
-
- /**
- * Unbind a {@link ServiceReference} from a Component Configuration
- * instance.
- *
- * Find the unbind method and call it if a method exists. If the
- * {@link ServiceReference} was acquired, call
- * {@link BundleContext#ungetService(org.osgi.framework.ServiceReference)}
- * using the Service Component's bundle context.
- *
- * @param reference
- * @param componentInstance
- * @param serviceReference
- */
- private void unbindServiceFromReference(Reference reference, ComponentInstanceImpl componentInstance, ServiceReference serviceReference) {
- ReferenceDescription rd = reference.getReferenceDescription();
- String unbind = rd.getUnbind();
- Object serviceObject = null;
- Method method = null;
- if (unbind != null) {
- //only look up unbind method once
- method = rd.getUnbindMethod();
- if (method == null) {
- method = invoke.findBindOrUnbindMethod(componentInstance, reference, serviceReference, unbind);
- rd.setUnbindMethod(method);
- }
- }
- if (method != null) {
- Object param = null;
- if (method.getParameterTypes()[0].equals(ServiceReference.class)) {
- param = serviceReference;
- } else {
- // componentInstance.getServiceObject(...) is populated by
- // the findBindOrUnbindMethod function
- serviceObject = reference.getServiceObject(serviceReference);
-
- // ... but not if the bind method was cached
- if (serviceObject == null) {
- serviceObject = getService(reference, serviceReference);
- if (serviceObject == null) {
- // could be circularity break
- return;
- }
- reference.addServiceReference(serviceReference, serviceObject);
- }
- param = serviceObject;
- }
- // If an unbind method throws an exception, SCR must log an error
- // message
- // containing the exception with the Log Service and the
- // deactivation of the component configuration will continue.
- try {
- invoke.unbindComponent(method, componentInstance.getInstance(), param);
- } catch (InvocationTargetException e) {
- Log.log(1, "[SCR] InvocationTargetException attempting to unbind reference.", e);
- } catch (IllegalAccessException e) {
- Log.log(1, "[SCR] IllegalAccessException attempting to unbind reference.", e);
- }
- } // end if (method != null)
-
- // release service object
- if (serviceObject != null) {
- componentInstance.getComponentContext().getBundleContext().ungetService(serviceReference);
- }
- reference.removeServiceReference(serviceReference);
- }
-
- /**
- * Invoke the activate method on a Component Configuration instance, if it
- * exists.
- *
- * @param componentInstance
- * @throws ComponentException
- */
- private void activate(ComponentInstanceImpl componentInstance) throws ComponentException {
-
- // If the activate method throws an exception, SCR must log an error
- // message
- // containing the exception with the Log Service and the component
- // configuration is not activated.
- try {
- invoke.activateComponent(componentInstance.getInstance(), componentInstance.getComponentContext());
- } catch (IllegalAccessException e) {
- Log.log(1, "[SCR] IllegalAccessException attempting to activate component ", e);
- throw new ComponentException(e.getMessage());
- } catch (InvocationTargetException e) {
- Log.log(1, "[SCR] InvocationTargetException attempting to activate component ", e);
- throw new ComponentException(e.getMessage());
- }
- }
-
- /**
- * Invoke the deactivate method on a Component Configuration instance, if it
- * exists.
- *
- * @param componentInstance
- */
- private void deactivate(ComponentInstanceImpl componentInstance) {
-
- // If the deactivate method throws an exception, SCR must log an error
- // message
- // containing the exception with the Log Service and the component
- // configuration will continue.
- try {
- invoke.deactivateComponent(componentInstance.getInstance(), componentInstance.getComponentContext());
- } catch (InvocationTargetException e) {
- Log.log(1, "[SCR] InvocationTargetException attempting to deactivate component.", e);
- } catch (IllegalAccessException e) {
- Log.log(1, "[SCR] IllegalAccessException attempting to deactivate component. ", e);
- }
-
- }
-
- /**
- * Create and return a new ComponentContext for a Component Configuration
- * instance
- *
- * @param usingBundle
- * @param componentInstance
- *
- */
- private void createComponentContext(Bundle usingBundle, ComponentInstanceImpl componentInstance) {
- ComponentContext context = new ComponentContextImpl(main, usingBundle, componentInstance);
- componentInstance.setComponentContext(context);
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/instance/InstanceProcess.java b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/instance/InstanceProcess.java
deleted file mode 100644
index 836e8a967..000000000
--- a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/instance/InstanceProcess.java
+++ /dev/null
@@ -1,365 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.ds.instance;
-
-import java.io.IOException;
-import java.util.*;
-import org.eclipse.equinox.ds.Activator;
-import org.eclipse.equinox.ds.Log;
-import org.eclipse.equinox.ds.model.ComponentDescription;
-import org.eclipse.equinox.ds.model.ComponentDescriptionProp;
-import org.eclipse.equinox.ds.resolver.Reference;
-import org.eclipse.equinox.ds.service.ComponentFactoryImpl;
-import org.eclipse.equinox.ds.service.ComponentInstanceImpl;
-import org.eclipse.equinox.ds.workqueue.WorkQueue;
-import org.osgi.framework.*;
-import org.osgi.service.cm.*;
-import org.osgi.service.component.ComponentException;
-import org.osgi.service.component.ComponentFactory;
-
-/**
- * Register services for satisfied Component Configurations and listen for
- * configuration changes from ConfigAdmin
- *
- */
-public class InstanceProcess implements ConfigurationListener {
-
- /* set this to true to compile in debug messages */
- private static final boolean DEBUG = false;
-
- /** Main SCR class */
- private Activator main;
-
- /* Actually does the work of building and disposing of instances */
- public BuildDispose buildDispose;
-
- protected WorkQueue workQueue;
-
- //configListener service registered by this class
- private ServiceRegistration configListener;
-
- /**
- * Handle Instance processing
- *
- * @param main - the Main class of the SCR
- */
- public InstanceProcess(Activator main) {
-
- this.main = main;
-
- // use Main's workqueue
- workQueue = main.workQueue;
- buildDispose = new BuildDispose(main);
-
- configListener = main.context.registerService(ConfigurationListener.class.getName(), this, null);
-
- }
-
- /**
- * dispose cleanup, the SCR is shutting down
- */
- public void dispose() {
-
- if (configListener != null) {
- main.context.ungetService(configListener.getReference());
- }
-
- buildDispose.dispose();
- buildDispose = null;
- main = null;
- workQueue = null;
- }
-
- /**
- * Register and possibly activate Component Configurations.
- *
- * Activate each Service Component that has the attribute immediate=true.
- *
- * If Service Component has a service element, register the service or
- * service factory.
- *
- * If Service Component has the factory attribute set, register a
- * {@link org.osgi.service.component.ComponentFactory}.
- *
- * @param componentDescriptionProps - List of satisfied Component Configurations
- */
- public void registerComponentConfigs(List componentDescriptionProps) {
-
- ComponentDescriptionProp cdp;
- ComponentDescription cd;
- String factoryPid = null;
-
- // loop through CD+P list
-
- Iterator it = componentDescriptionProps.iterator();
- while (it.hasNext()) {
- cdp = (ComponentDescriptionProp) it.next();
- cd = cdp.getComponentDescription();
- if (DEBUG)
- System.out.println("InstanceProcess: buildInstances: component name = " + cd.getName());
-
- // if component is immediate - create instance immediately
- if (cd.isImmediate()) {
- try {
- buildDispose.buildComponentConfigInstance(null, cdp);
- } catch (ComponentException e) {
- Log.log(1, "[SCR] Error attempting to build Component.", e);
- }
- }
-
- // ComponentFactory
- if (cdp.isComponentFactory()) {
- if (DEBUG)
- System.out.println("InstanceProcess: buildInstances: ComponentFactory");
- // check if MSF
- ConfigurationAdmin configurationAdmin = (ConfigurationAdmin) main.resolver.configAdminTracker.getService();
-
- if (configurationAdmin != null) {
- try {
- Configuration config = configurationAdmin.getConfiguration(cd.getName());
- if (config != null)
- factoryPid = config.getFactoryPid();
- } catch (IOException e) {
- Log.log(1, "[SCR] Error attempting to create componentFactory. ", e);
- }
- }
-
- // if MSF throw exception - can't be ComponentFactory and
- // MSF
- if (factoryPid != null) {
- throw new org.osgi.service.component.ComponentException("ManagedServiceFactory and ConfigurationFactory are incompatible");
- }
-
- // if the factory attribute is set on the component element
- // then register a component factory service
- // for the Service Component on behalf of the Service
- // Component.
- cdp.setServiceRegistration(cd.getBundleContext().registerService(ComponentFactory.class.getName(), new ComponentFactoryImpl(cdp, main), cdp.getProperties()));
-
- // if ServiceFactory or Service
- } else if (cd.getService() != null) {
- RegisterComponentService.registerService(this, cdp);
- }
-
- }// end while(more componentDescriptionProps)
- }
-
- /**
- *
- * Dispose of Component Configurations
- *
- * @param componentDescriptionProps - list of Component Configurations to be
- * disposed
- */
-
- public void disposeComponentConfigs(List componentDescriptionProps) {
-
- // loop through CD+P list to be disposed
- Iterator it = componentDescriptionProps.iterator();
- while (it.hasNext()) {
- ComponentDescriptionProp cdp = (ComponentDescriptionProp) it.next();
-
- // dispose component
- buildDispose.disposeComponentConfig(cdp);
- }
- }
-
- /**
- * Dynamically bind references.
- *
- * @param references List of {@link Reference}s to dynamically bind
- */
- public void dynamicBind(List references) {
- Iterator it = references.iterator();
- while (it.hasNext()) {
- Reference reference = (Reference) it.next();
- List instances = reference.getComponentDescriptionProp().getInstances();
- Iterator it2 = instances.iterator();
- while (it2.hasNext()) {
- ComponentInstanceImpl compInstance = (ComponentInstanceImpl) it2.next();
- buildDispose.bindReference(reference, compInstance);
- }
- }
- }
-
- /**
- * Dynamically unbind references.
- *
- * @param unbindJobs Map of {@link Reference}:{@link ServiceReference}
- * to be unbound
- */
- public void dynamicUnBind(Map unbindJobs) {
- // for each unbind job
- Iterator itr = unbindJobs.entrySet().iterator();
- while (itr.hasNext()) {
- Map.Entry unbindJob = (Map.Entry) itr.next();
- Reference reference = (Reference) unbindJob.getKey();
- ComponentDescriptionProp cdp = reference.getComponentDescriptionProp();
- ServiceReference serviceReference = (ServiceReference) unbindJob.getValue();
-
- // get the list of instances created
- List instances = cdp.getInstances();
- Iterator it = instances.iterator();
- while (it.hasNext()) {
- ComponentInstanceImpl compInstance = (ComponentInstanceImpl) it.next();
- Object instance = compInstance.getInstance();
- if (instance != null) {
- try {
- buildDispose.unbindDynamicReference(reference, compInstance, serviceReference);
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- }
-
- // all instances are now unbound
- reference.removeServiceReference(serviceReference);
- }
- }
-
- /**
- * Listen for configuration changes
- *
- * Service Components can receive properties from the Configuration Admin
- * service. If a Component Configuration is activated and it’s properties are
- * updated in the Configuration Admin service, the SCR must deactivate the
- * component and activate the component again using the new properties.
- *
- * @param event ConfigurationEvent
- *
- * @see ConfigurationListener#configurationEvent(org.osgi.service.cm.ConfigurationEvent)
- */
- public void configurationEvent(ConfigurationEvent event) {
-
- Configuration[] config = null;
-
- String pid = event.getPid();
- if (DEBUG)
- System.out.println("pid = " + pid);
-
- String fpid = event.getFactoryPid();
- if (DEBUG)
- System.out.println("fpid = " + fpid);
-
- //See if this configuration event is for declarative services
- ComponentDescription cd;
- if (fpid != null) {
- // find the fpid == component name in the CD list
- cd = (ComponentDescription) main.resolver.enabledCDsByName.get(fpid);
- } else {
- // find the spid == component name in the CD list
- cd = (ComponentDescription) main.resolver.enabledCDsByName.get(pid);
- }
- if (cd == null) {
- //this configuration event has nothing to do with declarative services
- return;
- }
-
- switch (event.getType()) {
- case ConfigurationEvent.CM_UPDATED :
-
- String filter = (fpid != null ? "(&" : "") + "(" + Constants.SERVICE_PID + "=" + pid + ")" + (fpid != null ? ("(" + ConfigurationAdmin.SERVICE_FACTORYPID + "=" + fpid + "))") : "");
-
- // Get the config for this service.pid
- ConfigurationAdmin cm = (ConfigurationAdmin) main.resolver.configAdminTracker.getService();
- try {
- config = cm.listConfigurations(filter);
- } catch (IOException e) {
- Log.log(1, "[SCR] Error attempting to list CM Configurations ", e);
- } catch (InvalidSyntaxException e) {
- Log.log(1, "[SCR] Error attempting to list CM Configurations ", e);
- }
-
- // if NOT a factory
- if (fpid == null) {
-
- // there is only one CDP for this CD, so we can disable the
- // CD
- main.resolver.disableComponents(Collections.singletonList(cd));
-
- // now re-enable the CD - the resolver will pick up the new
- // config
- workQueue.enqueueWork(main, Activator.ADD, Collections.singletonList(cd));
-
- // If a MSF
- // create a new CDP or update an existing one
- } else {
-
- // get cdp with this PID
- ComponentDescriptionProp cdp = cd.getComponentDescriptionPropByPID(pid);
-
- // if only the no-props cdp exists, replace it
- if (cdp == null && cd.getComponentDescriptionProps().size() == 1 && ((ComponentDescriptionProp) cd.getComponentDescriptionProps().get(0)).getProperties().get(Constants.SERVICE_PID) == null) {
- cdp = (ComponentDescriptionProp) cd.getComponentDescriptionProps().get(0);
- }
-
- // if old cdp exists, dispose of it
- if (cdp != null) {
- // config already exists - dispose of it
- cd.removeComponentDescriptionProp(cdp);
- main.resolver.disposeComponentConfigs(Collections.singletonList(cdp));
- }
-
- // create a new cdp (adds to resolver enabledCDPs list)
- main.resolver.map(cd, config[0].getProperties());
-
- // kick the resolver to figure out if CDP is satisfied, etc
- workQueue.enqueueWork(main, Activator.ADD, Collections.EMPTY_LIST);
-
- }
-
- break;
- case ConfigurationEvent.CM_DELETED :
-
- // if not a factory
- if (fpid == null) {
-
- // there is only one CDP for this CD, so we can disable the
- // CD
- main.resolver.disableComponents(Collections.singletonList(cd));
-
- // now re-enable the CD - the resolver will create CDP with
- // no
- // configAdmin properties
- workQueue.enqueueWork(main, Activator.ADD, Collections.singletonList(cd));
- } else {
- // config is a factory
-
- // get CDP created for this config (with this PID)
- ComponentDescriptionProp cdp = cd.getComponentDescriptionPropByPID(pid);
-
- // if this was the last CDP created for this factory
- if (cd.getComponentDescriptionProps().size() == 1) {
-
- // there is only one CDP for this CD, so we can disable
- // the CD
- main.resolver.disableComponents(Collections.singletonList(cd));
-
- // now re-enable the CD - the resolver will create CDP
- // with no
- // configAdmin properties
- workQueue.enqueueWork(main, Activator.ADD, Collections.singletonList(cd));
-
- } else {
-
- // we can just dispose this CDP
- cd.removeComponentDescriptionProp(cdp);
- disposeComponentConfigs(Collections.singletonList(cdp));
- main.resolver.satisfiedCDPs.remove(cdp);
- main.resolver.enabledCDPs.remove(cdp);
-
- }
- }
- break;
- }
-
- }
-}
diff --git a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/instance/InvokeMethod.java b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/instance/InvokeMethod.java
deleted file mode 100644
index 1000da687..000000000
--- a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/instance/InvokeMethod.java
+++ /dev/null
@@ -1,322 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.ds.instance;
-
-import java.lang.reflect.*;
-import org.eclipse.equinox.ds.Log;
-import org.eclipse.equinox.ds.model.ComponentDescription;
-import org.eclipse.equinox.ds.model.ComponentDescriptionProp;
-import org.eclipse.equinox.ds.resolver.Reference;
-import org.eclipse.equinox.ds.service.ComponentInstanceImpl;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.component.ComponentContext;
-import org.osgi.service.log.LogService;
-
-/**
- * Invoke a method on a Service Component implementation class instance:
- * activate, deactivate, bind or unbind
- *
- * @version $Revision: 1.2 $
- */
-
-class InvokeMethod {
-
- private BuildDispose buildDispose;
-
- InvokeMethod(BuildDispose buildDispose) {
- this.buildDispose = buildDispose;
- }
-
- /**
- * Invoke the activate method of the Service Component if one exists
- *
- * @param instance The instance of the component
- * @param context The component context
- */
- void activateComponent(Object instance, ComponentContext context) throws IllegalAccessException, InvocationTargetException {
-
- //cache activate method
- ComponentDescription cd = ((ComponentInstanceImpl) context.getComponentInstance()).getComponentDescriptionProp().getComponentDescription();
- Method method = cd.getActivateMethod();
- if (method == null && !cd.isActivateMethodInitialized()) {
- method = findActivateOrDeactivateMethod("activate", instance.getClass());
- //also sets cd.activateMethodInitialized flag
- cd.setActivateMethod(method);
- }
-
- // Create an array of parameters to pass to the method
- // The activate method requires the ComponentContext
- Object[] parameterTypes = new Object[] {context};
-
- if (method != null) {
- invokeMethod(method, instance, parameterTypes);
- }
- }
-
- /**
- * Invoke the deactivate method of the Service Component if one exists
- *
- * @param instance The instance of the component
- * @param context The component context
- */
- void deactivateComponent(Object instance, ComponentContext context) throws IllegalAccessException, InvocationTargetException {
-
- //cache deactivate method
- ComponentDescription cd = ((ComponentInstanceImpl) context.getComponentInstance()).getComponentDescriptionProp().getComponentDescription();
- Method method = cd.getDeactivateMethod();
- if (method == null && !cd.isDeactivateMethodInitialized()) {
- method = findActivateOrDeactivateMethod("deactivate", instance.getClass());
- //also sets cd.deactivateMethodInitialized flag
- cd.setDeactivateMethod(method);
- }
-
- // Create an array of parameters to pass to the method
- // The deactivate method requires the ComponentContext
- Object[] parameterTypes = new Object[] {context};
-
- if (method != null) {
- invokeMethod(method, instance, parameterTypes);
- }
- }
-
- /**
- * Invoke a bind method of a Service Component
- *
- * @param bind
- * @param instance
- * @param param service object or {@link ServiceReference}
- *
- * @throws IllegalAccessException
- * @throws InvocationTargetException
- */
- void bindComponent(Method bindMethod, Object instance, Object param) throws IllegalAccessException, InvocationTargetException {
- // Create an array of parameters to pass to the method
- Object[] parameterTypes = new Object[] {param};
- invokeMethod(bindMethod, instance, parameterTypes);
- }
-
- /**
- * unbind method of the Service Component
- *
- * @param unbind
- * @param instance
- * @param param service object or {@link ServiceReference}
- *
- * @throws IllegalAccessException
- * @throws InvocationTargetException
- */
- void unbindComponent(Method unbindMethod, Object instance, Object param) throws IllegalAccessException, InvocationTargetException {
- // Create an array of parameters to pass to the method
- Object[] parameterTypes = new Object[] {param};
- invokeMethod(unbindMethod, instance, parameterTypes);
- }
-
- /**
- * invokeMethod - invoke a Method on the Service Compoent via reflection
- *
- * @param method- the method name to invoke
- * @param instance - instance to invoke method on
- * @param parameterTypes - array of parameters to pass to the method
- *
- * @throws IllegalAccessException
- * @throws InvocationTargetException
- */
-
- private void invokeMethod(Method method, Object instance, Object[] parameterTypes) throws IllegalAccessException, InvocationTargetException {
-
- // If the method is declared protected or public, SCR will call the
- // method
- int mod = method.getModifiers();
- if ((Modifier.isProtected(mod)) || (Modifier.isPublic(mod))) {
- // if the method is protected must set accessibility(true) to invoke
- // it
- if (Modifier.isProtected(mod))
- method.setAccessible(true);
- // invoke the method
- method.invoke(instance, parameterTypes);
- }
- }
-
- private static final Class[] PARAM_COMPONENTCONTEXT = new Class[] {ComponentContext.class};
- private static final Class[] PARAM_SERVICEREFERENCE = new Class[] {ServiceReference.class};
-
- /**
- * Search through class and the superclasses for an activate or deactivate
- * method.
- *
- * If method if found but not public or protected, log an error and return null
- *
- * @param methodName name of method to look for
- * @param consumerClass Object to look in
- * @return method or null if not found
- */
- private Method findActivateOrDeactivateMethod(String methodName, Class consumerClass) {
- Method method = null;
- while (!consumerClass.equals(java.lang.Object.class) && method == null) {
-
- // search this class' methods
- try {
- method = consumerClass.getDeclaredMethod(methodName, PARAM_COMPONENTCONTEXT);
- } catch (NoSuchMethodException e) {
- // we'll try the superclass
- }
- if (method != null)
- break;
-
- // we couldn't find the method - try the superclass
- consumerClass = consumerClass.getSuperclass();
- }
-
- // if method is not protected or public, log error message
- if (method != null) {
- int modifier = method.getModifiers();
- if (!(Modifier.isProtected(modifier) || Modifier.isPublic(modifier))) {
- // log error
- Log.log(LogService.LOG_ERROR, "[SCR] Method " + methodName + " is not protected or public.");
- method = null;
- }
- }
-
- return method;
- }
-
- /**
- * Search through class and the superclasses for a bind or unbind method.
- *
- * See OSGi R4 Specification section 112.3.1 "Accessing Services" for an
- * explanation of the method search algorithm used for bind and unbind
- * methods.
- *
- * Searching for the bind or unbind method may require a service object. If
- * the object has not already been acquired, this method may call
- * {@link BuildDispose#getService(ComponentDescriptionProp, Reference, ServiceReference)}
- * to get it.
- *
- * If method can not be found we log an error and return null.
- *
- * @param componentInstance Object to look in
- * @param reference Reference object
- * @param serviceReference
- * @param methodName name of method to look for
- *
- * @return the method or null if no method was found
- *
- */
- Method findBindOrUnbindMethod(ComponentInstanceImpl componentInstance, Reference reference, ServiceReference serviceReference, String methodName) {
- Class consumerClass = componentInstance.getInstance().getClass();
- Object serviceObject = null;
- Class serviceObjectClass = null;
- Class interfaceClass = null;
- Class[] param_interfaceClass = null;
- Method method = null;
- while (consumerClass != null) {
-
- // search this class' methods
- // look for various forms of bind methods
-
- // 1) check for bind(ServiceReference) method
- try {
- method = consumerClass.getDeclaredMethod(methodName, PARAM_SERVICEREFERENCE);
- } catch (NoSuchMethodException e) {
- }
- if (method != null)
- break;
-
- // we need a serviceObject to keep looking, create one if necessary
- if (serviceObject == null) {
- serviceObject = reference.getServiceObject(serviceReference);
- if (serviceObject == null) {
- serviceObject = buildDispose.getService(reference, serviceReference);
- }
- if (serviceObject == null) {
- // we could not create a serviceObject because of
- // circularity
- return null;
- }
- reference.addServiceReference(serviceReference, serviceObject);
- serviceObjectClass = serviceObject.getClass();
-
- // figure out the interface class - this is guaranteed to
- // succeed or else
- // the framework would not have let us have the service object
- Class searchForInterfaceClass = serviceObjectClass;
- String interfaceName = reference.getReferenceDescription().getInterfacename();
- while (searchForInterfaceClass != null) {
- // first look through interfaces
- Class[] interfaceClasses = searchForInterfaceClass.getInterfaces();
- for (int i = 0; i < interfaceClasses.length; i++) {
- if (interfaceClasses[i].getName().equals(interfaceName)) {
- interfaceClass = interfaceClasses[i];
- break;
- }
- }
- if (interfaceClass != null) {
- break;
- }
-
- // also check the class itself
- if (searchForInterfaceClass.getName().equals(interfaceName)) {
- interfaceClass = searchForInterfaceClass;
- break;
- }
-
- // advance up the superclasses
- searchForInterfaceClass = searchForInterfaceClass.getSuperclass();
- }
-
- param_interfaceClass = new Class[] {interfaceClass};
-
- } // end if(serviceObject == null)
-
- // 2) check for bind(Service interface) method
- try {
- method = consumerClass.getDeclaredMethod(methodName, param_interfaceClass);
- } catch (NoSuchMethodException e) {
- }
- if (method != null)
- break;
-
- // 3) check for bind(class.isAssignableFrom(serviceObjectClass))
- // method
- Method[] methods = consumerClass.getDeclaredMethods();
- for (int i = 0; i < methods.length; i++) {
- Class[] params = methods[i].getParameterTypes();
- if (params.length == 1 && methods[i].getName().equals(methodName) && params[0].isAssignableFrom(serviceObjectClass)) {
-
- method = methods[i];
- break;
- }
- }
- if (method != null)
- break;
-
- // we couldn't find the method - try the superclass
- consumerClass = consumerClass.getSuperclass();
- }
-
- if (method == null) {
- // log error = we could not find the method
- Log.log(LogService.LOG_ERROR, "[SCR] Could not find method " + methodName + ".");
- return null;
- }
-
- // if method is not protected or public, log error message
- int modifier = method.getModifiers();
- if (!(Modifier.isProtected(modifier) || Modifier.isPublic(modifier))) {
- // log error
- Log.log(LogService.LOG_ERROR, "[SCR] Method " + methodName + " is not protected or public.");
- return null;
- }
-
- return method;
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/instance/RegisterComponentService.java b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/instance/RegisterComponentService.java
deleted file mode 100644
index 751880e47..000000000
--- a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/instance/RegisterComponentService.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.ds.instance;
-
-import java.util.Hashtable;
-import java.util.List;
-import org.eclipse.equinox.ds.Log;
-import org.eclipse.equinox.ds.model.ComponentDescription;
-import org.eclipse.equinox.ds.model.ComponentDescriptionProp;
-import org.osgi.framework.*;
-import org.osgi.service.component.ComponentException;
-import org.osgi.service.component.ComponentInstance;
-
-/**
- * Static utility class to register a Component Configuration's provided service.
- * A ServiceFactory is used to enable lazy activation
- *
- * @version $Revision: 1.2 $
- */
-abstract class RegisterComponentService {
-
- /* set this to true to compile in debug messages */
- private static final boolean DEBUG = false;
-
- // cannot instantiate - this is a utility class
- private RegisterComponentService() {
- }
-
- /**
- * Register the Component Configuration's service
- *
- * @param ip - InstanceProcess
- * @param cdp - ComponentDescription plus Properties
- */
- static void registerService(InstanceProcess instanceProcess, ComponentDescriptionProp cdp) {
-
- ComponentDescription cd = cdp.getComponentDescription();
-
- //make final references for use by anonymous inner class
- final InstanceProcess finalInstanceProcess = instanceProcess;
- final ComponentDescriptionProp finalCDP = cdp;
-
- List servicesProvided = cd.getServicesProvided();
- String[] servicesProvidedArray = (String[]) servicesProvided.toArray(new String[servicesProvided.size()]);
-
- // register the service using a ServiceFactory
- ServiceRegistration serviceRegistration = null;
- if (cd.getService().isServicefactory()) {
- // register the service using a ServiceFactory
- serviceRegistration = cd.getBundleContext().registerService(servicesProvidedArray, new ServiceFactory() {
- // map of Bundle:componentInstance
- Hashtable instances;
-
- // ServiceFactory.getService method.
- public Object getService(Bundle bundle, ServiceRegistration registration) {
- if (DEBUG)
- System.out.println("RegisterComponentServiceFactory:getService: registration:" + registration);
-
- ComponentInstance componentInstance = null;
- try {
- componentInstance = finalInstanceProcess.buildDispose.buildComponentConfigInstance(bundle, finalCDP);
- } catch (ComponentException e) {
- Log.log(1, "[SCR] Error attempting to register a Service Factory.", e);
- }
-
- if (componentInstance != null) {
- // save so we can dispose later
- synchronized (this) {
- if (instances == null) {
- instances = new Hashtable();
- }
- }
- instances.put(bundle, componentInstance);
- }
- return componentInstance.getInstance();
- }
-
- // ServiceFactory.ungetService method.
- public void ungetService(Bundle bundle, ServiceRegistration registration, Object service) {
- if (DEBUG)
- System.out.println("RegisterComponentServiceFactory:ungetService: registration = " + registration);
- ((ComponentInstance) instances.get(bundle)).dispose();
- instances.remove(bundle);
- synchronized (this) {
- if (instances.isEmpty()) {
- instances = null;
- }
- }
- }
- }, cdp.getProperties());
- } else {
- // servicefactory=false
- // always return the same instance
- serviceRegistration = cd.getBundleContext().registerService(servicesProvidedArray, new ServiceFactory() {
-
- int references = 0;
-
- //keep track of whether the componentInstance was created
- //by this class' getService method or if it already
- //existed - if we create it then we have to dispose
- //of it when it is no longer in use (references == 0)
- boolean disposeComponentInstance = false;
-
- // ServiceFactory.getService method.
- public Object getService(Bundle bundle, ServiceRegistration registration) {
- if (DEBUG)
- System.out.println("RegisterComponentService: getService: registration = " + registration);
-
- synchronized (this) {
-
- if (finalCDP.getInstances().isEmpty()) {
- try {
- //track that we created this instance
- //so we know to dispose of it later
- finalInstanceProcess.buildDispose.buildComponentConfigInstance(null, finalCDP);
- disposeComponentInstance = true;
- } catch (ComponentException e) {
- Log.log(1, "[SCR] Error attempting to register Service.", e);
- return null;
- }
- }
- references++;
- }
- return ((ComponentInstance) finalCDP.getInstances().get(0)).getInstance();
- }
-
- // ServiceFactory.ungetService method.
- public void ungetService(Bundle bundle, ServiceRegistration registration, Object service) {
- if (DEBUG)
- System.out.println("RegisterComponentService: ungetService: registration = " + registration);
-
- synchronized (this) {
- references--;
- if (references < 1 && disposeComponentInstance) {
- // if disposeComponentInstance then we
- // created it in getService so we should
- // dispose of it now
- ((ComponentInstance) finalCDP.getInstances().get(0)).dispose();
- disposeComponentInstance = false;
- }
- }
- }
- }, cdp.getProperties());
- }
-
- if (DEBUG)
- System.out.println("RegisterComponentService: register: " + serviceRegistration);
-
- cdp.setServiceRegistration(serviceRegistration);
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/model/ComponentDescription.java b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/model/ComponentDescription.java
deleted file mode 100644
index fa6e6cf48..000000000
--- a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/model/ComponentDescription.java
+++ /dev/null
@@ -1,388 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.ds.model;
-
-import java.io.*;
-import java.lang.reflect.Method;
-import java.net.URL;
-import java.util.*;
-import org.eclipse.equinox.ds.Log;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.service.component.ComponentException;
-import org.osgi.service.log.LogService;
-
-/**
- *
- * Memory model of the Service Component xml
- *
- * @version $Revision: 1.2 $
- */
-public class ComponentDescription implements Serializable {
- /**
- * Eclipse-generated <code>serialVersionUID</code>
- */
- private static final long serialVersionUID = -6131574862715499271L;
-
- transient private BundleContext bundleContext;
- private String name;
- private boolean autoenable;
- private boolean immediate;
- private boolean enabled;
- private boolean valid;
- private String factory;
-
- private ImplementationDescription implementation;
- private List propertyDescriptions;
- private ServiceDescription service;
- private List servicesProvided;
-
- private List referenceDescriptions;
-
- transient private List componentDescriptionProps;
-
- transient private boolean activateMethodInitialized;
- transient private Method activateMethod;
- transient private boolean deactivateMethodInitialized;
- transient private Method deactivateMethod;
-
- //does this really need to be transient?
- transient private Map properties;
-
- /**
- * Map of Component Configurations created for this Service Component keyed
- * by ConfigurationAdmin PID
- */
- transient private Map cdpsByPID;
-
- /**
- * Constructor
- *
- * @param bundleContext The bundle to set.
- */
- public ComponentDescription(BundleContext bundleContext) {
- this.bundleContext = bundleContext;
- autoenable = true;
- immediate = false;
- propertyDescriptions = new ArrayList();
- referenceDescriptions = new ArrayList();
- componentDescriptionProps = new ArrayList();
- cdpsByPID = new Hashtable();
- servicesProvided = Collections.EMPTY_LIST;
- }
-
- /**
- * Return true if autoenable is set
- *
- * @return Returns autoenable
- */
- public boolean isAutoenable() {
- return autoenable;
- }
-
- /**
- * @param autoenable The autoenable value to set.
- */
- public void setAutoenable(boolean autoenable) {
- this.autoenable = autoenable;
- }
-
- /**
- * @return Returns true if immediate is set
- */
- public boolean isImmediate() {
- return immediate;
- }
-
- /**
- * Set the specified value for immediate
- *
- * @param immediate
- */
- public void setImmediate(boolean immediate) {
- this.immediate = immediate;
- }
-
- /**
- * @return Returns the bundleContext
- */
- public BundleContext getBundleContext() {
- return bundleContext;
- }
-
- /**
- * Set the bundle context for this service component (note package private
- * visibility)
- */
- void setBundleContext(BundleContext context) {
- this.bundleContext = context;
- }
-
- /**
- * @return Returns the factory.
- */
- public String getFactory() {
- return factory;
- }
-
- /**
- * @param factory The factory to set.
- */
- public void setFactory(String factory) {
- this.factory = factory;
- }
-
- /**
- * @return Returns the implementation.
- */
- public ImplementationDescription getImplementation() {
- return implementation;
- }
-
- /**
- * @param implementation The implementation to set.
- */
- public void setImplementation(ImplementationDescription implementation) {
- this.implementation = implementation;
- }
-
- /**
- * @return Returns the name.
- */
- public String getName() {
- return name;
- }
-
- /**
- * @param name The name to set.
- */
- public void setName(String name) {
- this.name = name;
- }
-
- /**
- * @return Returns the XML properties.
- */
- public Map getProperties() {
- if (properties == null) {
- //the first time this method is called load the properties
- //(possibly from files) - for subsequent calls we do not
- //load again
- if (propertyDescriptions.isEmpty()) {
- properties = Collections.EMPTY_MAP;
- } else {
- properties = new Hashtable(propertyDescriptions.size());
- }
-
- //get properties from Service Component XML, in parse order
- Iterator it = propertyDescriptions.iterator();
- while (it.hasNext()) {
- PropertyDescription propertyDescription = (PropertyDescription) it.next();
- if (propertyDescription instanceof PropertyValueDescription) {
- PropertyValueDescription propvalue = (PropertyValueDescription) propertyDescription;
- properties.put(propvalue.getName(), propvalue.getValue());
- } else {
- // read from seperate properties file
- properties.putAll(loadPropertyFile(((PropertyResourceDescription) propertyDescription).getEntry()));
- }
- }
- }
-
- return properties;
- }
-
- /**
- * @param propertyDescription The properties to set.
- */
- public void addPropertyDescription(PropertyDescription propertyDescription) {
- propertyDescriptions.add(propertyDescription);
- }
-
- /**
- * Get the Service Component properties from a properties entry file
- *
- * @param propertyEntryName - the name of the properties file
- */
- private Hashtable loadPropertyFile(String propertyEntryName) {
-
- URL url = null;
- Properties props = new Properties();
-
- url = this.getBundleContext().getBundle().getEntry(propertyEntryName);
- if (url == null) {
- throw new ComponentException("Properties entry file " + propertyEntryName + " cannot be found");
- }
-
- try {
- InputStream in = null;
- File file = new File(propertyEntryName);
-
- if (file.exists()) {
- // throws FileNotFoundException if it's not there or no read
- // access
- in = new FileInputStream(file);
- } else {
- in = url.openStream();
- }
- if (in != null) {
- props.load(new BufferedInputStream(in));
- in.close();
- } else {
- Log.log(LogService.LOG_WARNING, "Unable to find properties file " + propertyEntryName);
- }
- } catch (IOException e) {
- throw new ComponentException("Properties entry file " + propertyEntryName + " cannot be read");
- }
-
- return props;
-
- }
-
- /**
- * @return Returns the service.
- */
- public ServiceDescription getService() {
- return service;
- }
-
- /**
- * return a handly list of the serviceInterfaces provided
- */
- public List getServicesProvided() {
- return servicesProvided;
- }
-
- /**
- * @param service The service to set.
- */
- public void setService(ServiceDescription service) {
- this.service = service;
-
- if (service != null) {
- servicesProvided = new ArrayList();
- ProvideDescription[] provideDescription = service.getProvides();
- for (int i = 0; i < provideDescription.length; i++) {
- servicesProvided.add(provideDescription[i].getInterfacename());
- }
- } else {
- servicesProvided = Collections.EMPTY_LIST;
- }
-
- }
-
- /**
- * @return Returns the reference Descriptions.
- */
- public List getReferenceDescriptions() {
- return referenceDescriptions;
- }
-
- /**
- * @param reference The references to set.
- */
- public void addReferenceDescription(ReferenceDescription reference) {
- referenceDescriptions.add(reference);
- }
-
- /**
- * @return Returns true if enabled
- */
- public boolean isEnabled() {
- return enabled;
- }
-
- /**
- * @param enabled set the value
- */
- public void setEnabled(boolean enabled) {
- this.enabled = enabled;
- }
-
- /**
- * @return Returns true if valid
- */
- public boolean isValid() {
- return valid;
- }
-
- /**
- * @param valid - set the value
- */
- public void setValid(boolean valid) {
- this.valid = valid;
- }
-
- public void addComponentDescriptionProp(ComponentDescriptionProp cdp) {
- componentDescriptionProps.add(cdp);
- String pid = (String) cdp.getProperties().get(Constants.SERVICE_PID);
- if (pid != null) {
- cdpsByPID.put(pid, cdp);
- }
- }
-
- public List getComponentDescriptionProps() {
- return componentDescriptionProps;
- }
-
- public ComponentDescriptionProp getComponentDescriptionPropByPID(String pid) {
- return (ComponentDescriptionProp) cdpsByPID.get(pid);
- }
-
- public void clearComponentDescriptionProps() {
- componentDescriptionProps.clear();
- cdpsByPID.clear();
- }
-
- public void removeComponentDescriptionProp(ComponentDescriptionProp cdp) {
- componentDescriptionProps.remove(cdp);
- }
-
- /**
- * Called by the (de)serialization logic to create an object of this class
- * from a serialized file record
- *
- * @see Serializable
- */
- private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
- //do standard deserialization
- in.defaultReadObject();
-
- //initialize transient collections
- this.componentDescriptionProps = new ArrayList();
- this.cdpsByPID = new Hashtable();
- }
-
- public Method getActivateMethod() {
- return activateMethod;
- }
-
- public void setActivateMethod(Method activateMethod) {
- activateMethodInitialized = true;
- this.activateMethod = activateMethod;
- }
-
- public boolean isActivateMethodInitialized() {
- return activateMethodInitialized;
- }
-
- public Method getDeactivateMethod() {
- return deactivateMethod;
- }
-
- public void setDeactivateMethod(Method deactivateMethod) {
- deactivateMethodInitialized = true;
- this.deactivateMethod = deactivateMethod;
- }
-
- public boolean isDeactivateMethodInitialized() {
- return deactivateMethodInitialized;
- }
-}
diff --git a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/model/ComponentDescriptionCache.java b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/model/ComponentDescriptionCache.java
deleted file mode 100644
index bc4050009..000000000
--- a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/model/ComponentDescriptionCache.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.ds.model;
-
-import java.io.*;
-import java.util.*;
-import org.eclipse.equinox.ds.Activator;
-import org.eclipse.equinox.ds.Log;
-import org.eclipse.equinox.ds.parser.Parser;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.service.log.LogService;
-
-/**
- *
- * Cache of component descriptions.
- *
- * @version $Revision: 1.2 $
- */
-public class ComponentDescriptionCache {
-
- private static final String CACHE_FILE = "cdcache.ser";
- private static final String CACHE_XML_PROPERTY = "declarativeservices.cacheXML";
-
- private File cacheFile;
- private final boolean CACHE_XML;
- private Activator main;
- /**
- * Cache of BundleId:CD
- */
- private Map cdCache;
-
- /**
- * Cache of BundleId:BundleLastModifiedTime
- */
- private Map lastModifiedTimes;
-
- /**
- * Parser object to use if the bundle's information is not in the cache or
- * is stale.
- */
- private Parser parser;
-
- /**
- * Create the cache object.
- *
- * @param main Main object.
- */
- public ComponentDescriptionCache(Activator main) {
- this.main = main;
- parser = new Parser(main);
-
- //check if we're supposed to cache the XML (defaults to true)
- CACHE_XML = Boolean.valueOf(System.getProperty(CACHE_XML_PROPERTY, "true")).booleanValue();
-
- //load cache
- cacheFile = main.context.getDataFile(CACHE_FILE);
- if (cacheFile.exists() && CACHE_XML) {
- try {
- FileInputStream in = new FileInputStream(cacheFile);
- ObjectInputStream cacheStream = new ObjectInputStream(in);
- cdCache = (Hashtable) cacheStream.readObject();
- lastModifiedTimes = (Hashtable) cacheStream.readObject();
- cacheStream.close();
- in.close();
- } catch (Exception e) {
- //should this be an info, warning, or error?
- //some devices don't have filesystems
- Log.log(LogService.LOG_WARNING, "Could not read Service Component XML cache", e);
-
- cdCache = new Hashtable();
- lastModifiedTimes = new Hashtable();
- }
- } else {
- cdCache = new Hashtable();
- lastModifiedTimes = new Hashtable();
- }
- }
-
- /**
- * Return the component descriptions for the specified bundle.
- *
- * @param bundle Bundle for which component description are to be returns
- * @return An array list of the component descriptions for the specified
- * bundle.
- */
- public List getComponentDescriptions(BundleContext bundleContext) {
- //check to see if we already have the cds for this bundle up-to-date in cache
- Bundle bundle = bundleContext.getBundle();
- Long bundleId = new Long(bundle.getBundleId());
- Long cacheTime = (Long) lastModifiedTimes.get(bundleId);
- Long lastModified = new Long(bundle.getLastModified());
-
- List cds = null;
- if (cacheTime != null && cacheTime.equals(lastModified)) {
- //we have the bundle cached
- cds = (List) cdCache.get(bundleId);
- } else {
- //not cached or out of date
- cds = parser.getComponentDescriptions(bundleContext);
- if (!cds.isEmpty()) {
- lastModifiedTimes.put(bundleId, lastModified);
- cdCache.put(bundleId, cds);
- }
- }
-
- //set the bundle context of each CD - these can not be cached because
- //a bundle gets a new bundle context every time it is initialized (started)
- Iterator it = cds.iterator();
- while (it.hasNext()) {
- ((ComponentDescription) it.next()).setBundleContext(bundleContext);
- }
-
- return cds;
- }
-
- public void dispose() {
- parser.dispose();
-
- //write cache
- if (CACHE_XML) {
-
- //clean out cache - only save entries for bundles that are
- //still installed
- Bundle[] installedBundles = main.context.getBundles();
- Set installedBundleIDs = new HashSet(installedBundles.length);
- for (int i = 0; i < installedBundles.length; i++) {
- installedBundleIDs.add(new Long(installedBundles[i].getBundleId()));
- }
- cdCache.keySet().retainAll(installedBundleIDs);
- lastModifiedTimes.keySet().retainAll(installedBundleIDs);
-
- //write to disk
- try {
- FileOutputStream out = new FileOutputStream(cacheFile);
- ObjectOutputStream cacheStream = new ObjectOutputStream(out);
- cacheStream.writeObject(cdCache);
- cacheStream.writeObject(lastModifiedTimes);
- cacheStream.flush();
- cacheStream.close();
- out.close();
- } catch (Exception e) {
- //should this be an info, warning, or error?
- //some devices don't have filesystems
- Log.log(LogService.LOG_WARNING, "Could not write Service Component XML cache", e);
-
- //delete the cache file if possible
- try {
- cacheFile.delete();
- } catch (Exception e2) {
- Log.log(LogService.LOG_INFO, "Could not delete Service Component XML cache", e2);
- }
- }
- } //end if(CACHE_XML)
- cacheFile = null;
- cdCache = null;
- lastModifiedTimes = null;
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/model/ComponentDescriptionProp.java b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/model/ComponentDescriptionProp.java
deleted file mode 100644
index 1cfe145cc..000000000
--- a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/model/ComponentDescriptionProp.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.ds.model;
-
-import java.util.*;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.component.ComponentInstance;
-
-/**
- *
- * Component Description with properties
- *
- * Component Configuration – A component configuration represents a component
- * description parameterized by component properties.
- *
- * @version $Revision: 1.2 $
- */
-public class ComponentDescriptionProp {
-
- private ComponentDescription cd;
- private Hashtable properties;
- private ServiceRegistration serviceRegistration;
-
- /**
- * List of {@link org.eclipse.equinox.ds.resolver.Reference Reference} objects
- */
- private List references;
-
- /**
- * List of {@link ComponentInstance} objects
- */
- private List instances;
-
- /**
- * List of names (Strings) of Component Configurations we should not cause to
- * activate during the activation of this Component Configuration. This is
- * populated by the {@link org.eclipse.equinox.ds.resolver.Resolver Resolver}
- * and used by {@link org.eclipse.equinox.ds.instance.BuildDispose BuildDispose}.
- */
- protected List delayActivateCDPNames;
-
- /**
- * Flag to indicate that this Component Configuration registers
- * the {@link org.osgi.service.component.ComponentFactory}
- * service.
- *
- * (A Service Component that has the "factory" attribute will have
- * one Component Configuration that registers
- * {@link org.osgi.service.component.ComponentFactory} and then a Component
- * Configuration for every factory instance that registers a different service
- * or none at all).
- */
- protected boolean componentFactory;
-
- /**
- * Create a new Component Configuration for this Service Component with
- * it's own Reference objects, and properties.
- *
- * @param cd the Service Component
- *
- * @param references a List of
- * {@link org.eclipse.equinox.ds.resolver.Reference Reference}
- * objects
- *
- * @param properties Properties associated with this Component Configuration
- *
- * @param componentFactory "Component Factory" flag - see
- * {@link ComponentDescriptionProp#componentFactory}
- */
- public ComponentDescriptionProp(ComponentDescription cd, List references, Hashtable properties, boolean componentFactory) {
-
- this.cd = cd;
- this.references = references;
- this.properties = properties;
-
- delayActivateCDPNames = new ArrayList();
- instances = new ArrayList();
-
- this.componentFactory = componentFactory;
- }
-
- /**
- * Get the properties of this Component Configuration
- */
- public Hashtable getProperties() {
- return properties;
- }
-
- public ComponentDescription getComponentDescription() {
- return cd;
- }
-
- /**
- * Add a new Component Configuration name we should beware of activating to
- * prevent a cycle.
- *
- * @see ComponentDescriptionProp#delayActivateCDPNames
- */
- public void setDelayActivateCDPName(String cdpName) {
- if (!delayActivateCDPNames.contains(cdpName))
- delayActivateCDPNames.add(cdpName);
- }
-
- public ServiceRegistration getServiceRegistration() {
- return serviceRegistration;
- }
-
- public void setServiceRegistration(ServiceRegistration serviceRegistration) {
- this.serviceRegistration = serviceRegistration;
- }
-
- public List getDelayActivateCDPNames() {
- return delayActivateCDPNames;
- }
-
- public void clearDelayActivateCDPNames() {
- delayActivateCDPNames.clear();
- }
-
- public List getReferences() {
- return references;
- }
-
- public void addInstance(ComponentInstance instance) {
- instances.add(instance);
- }
-
- public List getInstances() {
- return instances;
- }
-
- public void removeInstance(Object object) {
- instances.remove(object);
- }
-
- public void removeAllInstances() {
- instances.clear();
- }
-
- public boolean isComponentFactory() {
- return componentFactory;
- }
-}
diff --git a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/model/ImplementationDescription.java b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/model/ImplementationDescription.java
deleted file mode 100644
index b06729731..000000000
--- a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/model/ImplementationDescription.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.ds.model;
-
-import java.io.Serializable;
-
-/**
- *
- * This class models the implementation element.
- * The implementation element is required and defines the name of the component
- * implementation class.
- *
- * @version $Revision: 1.2 $
- */
-public class ImplementationDescription implements Serializable {
- /**
- * Eclipse-generated <code>serialVersionUID</code>
- */
- private static final long serialVersionUID = -5348855154850323280L;
-
- private String classname;
-
- public ImplementationDescription() {
- }
-
- /**
- * @return Returns the classname.
- */
- public String getClassname() {
- return classname;
- }
-
- /**
- * @param classname set this class name.
- */
- public void setClassname(String classname) {
- this.classname = classname;
- }
-}
diff --git a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/model/PropertyDescription.java b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/model/PropertyDescription.java
deleted file mode 100644
index 81ec99ff6..000000000
--- a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/model/PropertyDescription.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.ds.model;
-
-import java.io.Serializable;
-
-/**
- *
- * Abstract class for modeling the property and properties elements.
- *
- * @version $Revision: 1.2 $
- */
-public abstract class PropertyDescription implements Serializable {
-
-}
diff --git a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/model/PropertyResourceDescription.java b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/model/PropertyResourceDescription.java
deleted file mode 100644
index 885b4b276..000000000
--- a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/model/PropertyResourceDescription.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.ds.model;
-
-/**
- *
- * This class models the properties element.
- * The properties element reads a set of properties from a bundle entry.
- *
- * @version $Revision: 1.2 $
- */
-public class PropertyResourceDescription extends PropertyDescription {
-
- /**
- * Eclipse-generated <code>serialVersionUID</code>
- */
- private static final long serialVersionUID = -6094597960839333734L;
-
- private String entry;
-
- /**
- * @return Returns the entry.
- */
- public String getEntry() {
- return entry;
- }
-
- /**
- * @param entry The entry to set.
- */
- public void setEntry(String entry) {
- this.entry = entry;
- }
-}
diff --git a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/model/PropertyValueDescription.java b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/model/PropertyValueDescription.java
deleted file mode 100644
index 317e52ad5..000000000
--- a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/model/PropertyValueDescription.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.ds.model;
-
-/**
- *
- * This class models the property element.
- * The property element defines a single property.
- *
- * @version $Revision: 1.2 $
- */
-public class PropertyValueDescription extends PropertyDescription {
-
- /**
- * Eclipse-generated <code>serialVersionUID</code>
- */
- private static final long serialVersionUID = 8680436828645485510L;
-
- private String name;
- private String type;
- private Object value;
-
- /**
- * @return Returns the name.
- */
- public String getName() {
- return name;
- }
-
- /**
- * @param name The name to set.
- */
- public void setName(String name) {
- this.name = name;
- }
-
- /**
- * @return Returns the type.
- */
- public String getType() {
- return type == null ? "String" : type;
- }
-
- /**
- * @param type The type to set.
- */
- public void setType(String type) {
- this.type = type;
- }
-
- /**
- * @return Returns the value.
- */
- public Object getValue() {
- return value;
- }
-
- /**
- * @param value The value to set.
- */
- public void setValue(Object value) {
- this.value = value;
- }
-}
diff --git a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/model/ProvideDescription.java b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/model/ProvideDescription.java
deleted file mode 100644
index 35007f934..000000000
--- a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/model/ProvideDescription.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.ds.model;
-
-import java.io.Serializable;
-
-/**
- *
- * This class models the provide element.
- * The service element must have one or more provide elements that define
- * the service interfaces. The provide element has a single attribute:
- * interface
- *
- * @version $Revision: 1.2 $
- */
-public class ProvideDescription implements Serializable {
- /**
- * Eclipse-generated <code>serialVersionUID</code>
- */
- private static final long serialVersionUID = -8301435779729338880L;
-
- private String interfacename;
-
- /**
- * @return Returns the interfacename.
- */
- public String getInterfacename() {
- return interfacename;
- }
-
- /**
- * @param interfacename The interfacename to set.
- */
- public void setInterfacename(String interfacename) {
- this.interfacename = interfacename;
- }
-}
diff --git a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/model/ReferenceDescription.java b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/model/ReferenceDescription.java
deleted file mode 100644
index ba5cfaf1b..000000000
--- a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/model/ReferenceDescription.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.ds.model;
-
-import java.io.Serializable;
-import java.lang.reflect.Method;
-
-/**
- *
- * This class models the reference element.
- * A reference declares a dependency that a component has on a set
- * of target services.
- *
- * @see org.eclipse.equinox.ds.resolver.Reference
- *
- * @version $Revision: 1.2 $
- */
-public class ReferenceDescription implements Serializable {
-
- /**
- * Eclipse-generated <code>serialVersionUID</code>
- */
- private static final long serialVersionUID = -6454039348113422074L;
-
- private static final int CARDINALITY_HIGH_DEFAULT = 1;
- private static final int CARDINALITY_LOW_DEFAULT = 1;
- private static final String POLICY_DEFAULT = "static";
-
- private String name;
- private String interfacename;
-
- // Cardinality indicates the number of services, matching this
- // reference,
- // which will bind to this Service Component. Possible values are:
- // 0..1, 0..n, 1..1 (i.e. exactly one), 1..n (i.e. at least one).
- // This attribute is optional. If it is not specified, then a
- // cardinality
- // of “1..1� is used.
- private int cardinalityHigh;
- private int cardinalityLow;
- private String policy;
- private String target;
- private String bind;
- private String unbind;
-
- //Cache bind and unbind methods
- transient private Method bindMethod;
- transient private Method unbindMethod;
-
- public ReferenceDescription() {
- // set defaults
- cardinalityHigh = CARDINALITY_HIGH_DEFAULT;
- cardinalityLow = CARDINALITY_LOW_DEFAULT;
- policy = POLICY_DEFAULT;
- }
-
- /**
- * @return Returns the bind method.
- */
- public String getBind() {
- return bind;
- }
-
- /**
- * @param bind The bind method.
- */
- public void setBind(String bind) {
- this.bind = bind;
- }
-
- /**
- * @return Returns the cardinality.
- */
- public int getCardinalityHigh() {
- return cardinalityHigh;
- }
-
- /**
- * @param cardinality
- */
- public void setCardinality(String cardinality) {
- if (cardinality.equals("0..1")) {
- cardinalityLow = 0;
- cardinalityHigh = 1;
- } else if (cardinality.equals("0..n")) {
- cardinalityLow = 0;
- cardinalityHigh = 999999999; // infinite
- } else if (cardinality.equals("1..1")) {
- cardinalityLow = 1;
- cardinalityHigh = 1;
- } else if (cardinality.equals("1..n")) {
- cardinalityLow = 1;
- cardinalityHigh = 999999999;
- } else {
- // TODO throw exception?
- }
- }
-
- /**
- * @return Returns the interfacename.
- */
- public String getInterfacename() {
- return interfacename;
- }
-
- /**
- * @param interfacename The interfacename to set.
- */
- public void setInterfacename(String interfacename) {
- this.interfacename = interfacename;
- }
-
- /**
- * @return Returns the name.
- */
- public String getName() {
- return name;
- }
-
- /**
- * @param name The name to set.
- */
- public void setName(String name) {
- this.name = name;
- }
-
- /**
- * @return Returns the policy.
- */
- public String getPolicy() {
- return policy;
- }
-
- /**
- * @param policy The policy to set.
- */
- public void setPolicy(String policy) {
- // TODO validate
- this.policy = policy;
- }
-
- /**
- * @return Returns the target.
- */
- public String getTarget() {
- return target;
- }
-
- /**
- * @param target The target to set.
- */
- public void setTarget(String target) {
- // TODO validate
- this.target = target;
- }
-
- /**
- * @return Returns the unbind method
- */
- public String getUnbind() {
- return unbind;
- }
-
- /**
- * @param unbind The unbind method to set.
- */
- public void setUnbind(String unbind) {
- this.unbind = unbind;
- }
-
- // if the cardinality is "1..1" or "1..n" then this reference is required
- public boolean isRequired() {
- return (cardinalityLow == 1);
- }
-
- //Cache bind and unbind methods
-
- /**
- * @return Returns the bind method.
- */
- public Method getBindMethod() {
- return bindMethod;
- }
-
- /**
- * @param bind The bind method.
- */
- public void setBindMethod(Method method) {
- this.bindMethod = method;
- }
-
- /**
- * @return Returns the unbind method
- */
- public Method getUnbindMethod() {
- return unbindMethod;
- }
-
- /**
- * @param unbind The unbind method to set.
- */
- public void setUnbindMethod(Method method) {
- this.unbindMethod = method;
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/model/ServiceDescription.java b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/model/ServiceDescription.java
deleted file mode 100644
index 9e161a5fb..000000000
--- a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/model/ServiceDescription.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.ds.model;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * This class models the service element.
- * The service element is optional. It describes the service information to be
- * used when a component configuration is to be registered as a service. *
- *
- * @version $Revision: 1.2 $
- */
-public class ServiceDescription implements Serializable {
- /**
- * Eclipse-generated <code>serialVersionUID</code>
- */
- private static final long serialVersionUID = -4376202637155295067L;
-
- private boolean servicefactory;
- private List provides;
-
- public ServiceDescription() {
- servicefactory = false;
- provides = new ArrayList();
- }
-
- /**
- * @param servicefactory indicates if servicefactory is set
- */
- public void setServicefactory(boolean servicefactory) {
- this.servicefactory = servicefactory;
- }
-
- /**
- * @return Returns true is servicefactory is set
- */
- public boolean isServicefactory() {
- return servicefactory;
- }
-
- /**
- * @param provide add this provide element to the array of provide elements.
- */
- public void addProvide(ProvideDescription provide) {
- provides.add(provide);
- }
-
- /**
- * @return Returns the array of provide elements.
- */
- public ProvideDescription[] getProvides() {
- int size = provides.size();
- ProvideDescription[] result = new ProvideDescription[size];
- provides.toArray(result);
- return result;
- }
-}
diff --git a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/parser/ComponentElement.java b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/parser/ComponentElement.java
deleted file mode 100644
index 2c4085d9e..000000000
--- a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/parser/ComponentElement.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.ds.parser;
-
-import org.eclipse.equinox.ds.model.ComponentDescription;
-import org.eclipse.equinox.ds.model.PropertyValueDescription;
-import org.osgi.service.component.ComponentConstants;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.DefaultHandler;
-
-class ComponentElement extends DefaultHandler {
- private ParserHandler root;
- private ParserHandler parent;
- private ComponentDescription component;
- private boolean immediateSet;
-
- ComponentElement(ParserHandler root, Attributes attributes) {
- this.root = root;
- this.parent = root;
- component = new ComponentDescription(root.bundleContext);
- immediateSet = false;
-
- int size = attributes.getLength();
- for (int i = 0; i < size; i++) {
- String key = attributes.getQName(i);
- String value = attributes.getValue(i);
-
- if (key.equals(ParserConstants.NAME_ATTRIBUTE)) {
- component.setName(value);
- PropertyValueDescription nameProperty = new PropertyValueDescription();
- nameProperty.setName(ComponentConstants.COMPONENT_NAME);
- nameProperty.setValue(value);
- component.addPropertyDescription(nameProperty);
- continue;
- }
- if (key.equals(ParserConstants.ENABLED_ATTRIBUTE)) {
- component.setAutoenable(value.equalsIgnoreCase("true"));
- continue;
- }
- if (key.equals(ParserConstants.FACTORY_ATTRIBUTE)) {
- component.setFactory(value);
- continue;
- }
- if (key.equals(ParserConstants.IMMEDIATE_ATTRIBUTE)) {
- component.setImmediate(value.equalsIgnoreCase("true"));
- immediateSet = true;
- continue;
- }
- root.logError("unrecognized component element attribute: " + key);
- }
-
- if (component.getName() == null) {
- root.logError("component name not specified");
- }
- }
-
- ComponentDescription getComponentDescription() {
- return component;
- }
-
- public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
- if (localName.equals(ParserConstants.IMPLEMENTATION_ELEMENT)) {
- root.setHandler(new ImplementationElement(root, this, attributes));
- return;
- }
-
- if (localName.equals(ParserConstants.PROPERTY_ELEMENT)) {
- root.setHandler(new PropertyElement(root, this, attributes));
- return;
- }
-
- if (localName.equals(ParserConstants.PROPERTIES_ELEMENT)) {
- root.setHandler(new PropertiesElement(root, this, attributes));
- return;
- }
-
- if (localName.equals(ParserConstants.SERVICE_ELEMENT)) {
- root.setHandler(new ServiceElement(root, this, attributes));
- return;
- }
-
- if (localName.equals(ParserConstants.REFERENCE_ELEMENT)) {
- root.setHandler(new ReferenceElement(root, this, attributes));
- return;
- }
- root.logError("unrecognized element of component: " + localName);
- }
-
- public void characters(char[] ch, int start, int length) {
- int end = start + length;
- for (int i = start; i < end; i++) {
- if (!Character.isWhitespace(ch[i])) {
- root.logError("element body must be empty");
- }
- }
- }
-
- public void endElement(String uri, String localName, String qName) {
-
- // if unset, immediate attribute is false if service element is
- // specified or true otherwise
- // if component factory then immediate by default is false
- if (!immediateSet && (component.getFactory() == null)) {
- component.setImmediate(component.getService() == null);
- }
-
- if (component.getImplementation() == null) {
- root.logError("no implementation element");
- }
-
- if (root.isError()) {
- root.setError(false);
- } else {
- parent.addComponentDescription(component);
- }
-
- root.setHandler(parent);
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/parser/ImplementationElement.java b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/parser/ImplementationElement.java
deleted file mode 100644
index 0e6f5aced..000000000
--- a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/parser/ImplementationElement.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.ds.parser;
-
-import org.eclipse.equinox.ds.model.ComponentDescription;
-import org.eclipse.equinox.ds.model.ImplementationDescription;
-import org.xml.sax.Attributes;
-import org.xml.sax.helpers.DefaultHandler;
-
-class ImplementationElement extends DefaultHandler {
- private ParserHandler root;
- private ComponentElement parent;
- private ImplementationDescription implementation;
-
- ImplementationElement(ParserHandler root, ComponentElement parent, Attributes attributes) {
- this.root = root;
- this.parent = parent;
- implementation = new ImplementationDescription();
-
- int size = attributes.getLength();
- for (int i = 0; i < size; i++) {
- String key = attributes.getQName(i);
- String value = attributes.getValue(i);
-
- if (key.equals(ParserConstants.CLASS_ATTRIBUTE)) {
- implementation.setClassname(value);
- continue;
- }
- root.logError("unrecognized implementation element attribute: " + key);
- }
-
- if (implementation.getClassname() == null) {
- root.logError("implementation class not specified");
- }
- }
-
- public void startElement(String uri, String localName, String qName, Attributes attributes) {
- root.logError("implementation does not support nested elements");
- }
-
- public void characters(char[] ch, int start, int length) {
- int end = start + length;
- for (int i = start; i < end; i++) {
- if (!Character.isWhitespace(ch[i])) {
- root.logError("element body must be empty");
- }
- }
- }
-
- public void endElement(String uri, String localName, String qName) {
- ComponentDescription component = parent.getComponentDescription();
- if (component.getImplementation() != null) {
- root.logError("more than one implementation element");
- }
-
- component.setImplementation(implementation);
- root.setHandler(parent);
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/parser/Parser.java b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/parser/Parser.java
deleted file mode 100644
index 45df43178..000000000
--- a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/parser/Parser.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.ds.parser;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.*;
-import javax.xml.parsers.*;
-import org.eclipse.equinox.ds.Activator;
-import org.eclipse.equinox.ds.Log;
-import org.eclipse.osgi.util.ManifestElement;
-import org.osgi.framework.*;
-import org.osgi.service.component.ComponentConstants;
-import org.osgi.util.tracker.ServiceTracker;
-import org.xml.sax.SAXException;
-
-/**
- *
- * Parse the component description xml
- *
- * @version $Revision: 1.2 $
- */
-public class Parser {
-
- /* ServiceTracker for parser */
- private ServiceTracker parserTracker;
-
- /**
- * Create and open a ServiceTracker which will track registered XML parsers
- *
- * @param main Main object.
- */
- public Parser(Activator main) {
- parserTracker = new ServiceTracker(main.context, ParserConstants.SAX_FACTORY_CLASS, null);
- parserTracker.open();
- }
-
- public void dispose() {
- parserTracker.close();
- }
-
- public List getComponentDescriptions(BundleContext bundleContext) {
- ManifestElement[] xml = parseManifestHeader(bundleContext.getBundle());
-
- List result;
-
- if (xml != null) {
- result = new ArrayList(xml.length);
- for (int i = 0; i < xml.length; i++) {
- List components = parseComponentDescription(bundleContext, xml[i].getValue());
- result.addAll(components);
- }
- } else {
- result = Collections.EMPTY_LIST;
- }
-
- return result;
- }
-
- /*
- * Get the xml files from the bundle
- *
- * @param bundle Bundle @return Vector holding all the xmlfiles for the
- * specifed Bundle
- */
- private ManifestElement[] parseManifestHeader(Bundle bundle) {
-
- Dictionary headers = bundle.getHeaders();
- String files = (String) headers.get(ComponentConstants.SERVICE_COMPONENT);
-
- try {
- return ManifestElement.parseHeader(ComponentConstants.SERVICE_COMPONENT, files);
- } catch (BundleException e) {
- Log.log(1, "[SCR] Error attempting parse Manifest Element Header. ", e);
- return new ManifestElement[0];
- }
- }
-
- /**
- * Given the bundle and the xml filename, parset it!
- *
- * @param bundle Bundle
- * @param xml String
- */
- private List parseComponentDescription(BundleContext bundleContext, String xml) {
- List result = new ArrayList();
- int fileIndex = xml.lastIndexOf('/');
- String path = fileIndex != -1 ? xml.substring(0, fileIndex) : "/";
- try {
- Enumeration urls = bundleContext.getBundle().findEntries(path, xml.substring(fileIndex + 1), false);
- if (urls == null || !urls.hasMoreElements()) {
- throw new BundleException("resource not found: " + xml);
- }
- URL url = (URL) urls.nextElement();
- InputStream is = url.openStream();
- SAXParserFactory parserFactory = (SAXParserFactory) parserTracker.getService();
- parserFactory.setNamespaceAware(true);
- parserFactory.setValidating(false);
- SAXParser saxParser = parserFactory.newSAXParser();
- saxParser.parse(is, new ParserHandler(bundleContext, result));
- } catch (IOException e) {
- Log.log(1, "[SCR] IOException attempting to parse ComponentDescription XML. ", e);
- } catch (BundleException e) {
- Log.log(1, "[SCR] BundleException attempting to parse ComponentDescription XML. ", e);
- } catch (SAXException e) {
- Log.log(1, "[SCR] SAXException attempting to parse ComponentDescription XML. ", e);
- } catch (ParserConfigurationException e) {
- Log.log(1, "[SCR] ParserConfigurationException attempting to parse ComponentDescription XML. ", e);
- }
-
- return result;
- }
-}
diff --git a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/parser/ParserConstants.java b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/parser/ParserConstants.java
deleted file mode 100644
index 8206810e5..000000000
--- a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/parser/ParserConstants.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.ds.parser;
-
-/**
- *
- * Define Constants
- *
- * @version $Revision: 1.2 $
- */
-
-interface ParserConstants {
-
- // Define the Service Component XML Tags
- static final String SCR_NAMESPACE = "http://www.osgi.org/xmlns/scr/v1.0.0";
- static final String COMPONENT_ELEMENT = "component";
- static final String IMPLEMENTATION_ELEMENT = "implementation";
- static final String REFERENCE_ELEMENT = "reference";
- static final String SERVICE_ELEMENT = "service";
- static final String PROPERTY_ELEMENT = "property";
- static final String PROPERTIES_ELEMENT = "properties";
- static final String NAME_ATTRIBUTE = "name";
- static final String IMMEDIATE_ATTRIBUTE = "immediate";
- static final String VALUE_ATTRIBUTE = "value";
- static final String TYPE_ATTRIBUTE = "type";
- static final String ENTRY_ATTRIBUTE = "entry";
- static final String PROVIDE_ELEMENT = "provide";
- static final String ENABLED_ATTRIBUTE = "enabled";
- static final String FACTORY_ATTRIBUTE = "factory";
- static final String SERVICEFACTORY_ATTRIBUTE = "servicefactory";
- static final String CLASS_ATTRIBUTE = "class";
- static final String INTERFACE_ATTRIBUTE = "interface";
- static final String CARDINALITY_ATTRIBUTE = "cardinality";
- static final String POLICY_ATTRIBUTE = "policy";
- static final String TARGET_ATTRIBUTE = "target";
- static final String BIND_ATTRIBUTE = "bind";
- static final String UNBIND_ATTRIBUTE = "unbind";
-
- /* SAX Parser class name */
- static final String SAX_FACTORY_CLASS = "javax.xml.parsers.SAXParserFactory"; //$NON-NLS-1$
-}
diff --git a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/parser/ParserHandler.java b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/parser/ParserHandler.java
deleted file mode 100644
index ce0a61263..000000000
--- a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/parser/ParserHandler.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.ds.parser;
-
-import java.util.List;
-import org.eclipse.equinox.ds.Log;
-import org.eclipse.equinox.ds.model.ComponentDescription;
-import org.osgi.framework.BundleContext;
-import org.xml.sax.*;
-import org.xml.sax.helpers.DefaultHandler;
-
-/**
- * ParserHandler implements the methods for the DefaultHandler of the SAX
- * parser. Each Service Component bundle contains a set of xml files which are
- * parsed.
- *
- * @version $Revision: 1.2 $
- */
-
-class ParserHandler extends DefaultHandler {
-
- /* set this to true to compile in debug messages */
- private static final boolean DEBUG = false;
-
- private DefaultHandler handler;
- private List components;
- protected BundleContext bundleContext;
- private int depth;
- private boolean error;
-
- ParserHandler(BundleContext bundleContext, List components) {
- this.bundleContext = bundleContext;
- this.components = components;
- }
-
- public void setHandler(DefaultHandler handler) {
- this.handler = handler;
- }
-
- public void addComponentDescription(ComponentDescription component) {
- components.add(component);
- }
-
- public void setError(boolean error) {
- this.error = error;
- }
-
- public boolean isError() {
- return error;
- }
-
- public void logError(String msg) {
- error = true;
- Log.log(1, "[SCR] Parser Error. ", new SAXException(msg));
- }
-
- public void startDocument() throws SAXException {
- handler = this;
- depth = 0;
- }
-
- public void startPrefixMapping(String prefix, String uri) throws SAXException {
-
- if (DEBUG) {
- System.out.println("[startPrefixMapping:prefix]" + prefix);
- System.out.println("[startPrefixMapping:uri]" + uri);
- }
- }
-
- public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
- depth++;
-
- if (DEBUG) {
- System.out.println("[startElement:begin]");
- System.out.println(" [uri]" + uri);
- System.out.println(" [localName]" + localName);
- System.out.println(" [qName]" + qName);
-
- int size = attributes.getLength();
- for (int i = 0; i < size; i++) {
- String key = attributes.getQName(i);
- String value = attributes.getValue(i);
- System.out.println(" [attr:" + i + ":localName]" + attributes.getLocalName(i));
- System.out.println(" [attr:" + i + ":qName]" + attributes.getQName(i));
- System.out.println(" [attr:" + i + ":type]" + attributes.getType(i));
- System.out.println(" [attr:" + i + ":URI]" + attributes.getURI(i));
- System.out.println(" [attr:" + i + ":value]" + attributes.getValue(i));
- }
- System.out.println("[startElement:end]");
- }
-
- if (handler != this) {
- handler.startElement(uri, localName, qName, attributes);
- return;
- }
-
- if (localName.equals(ParserConstants.COMPONENT_ELEMENT)) {
- if (((depth == 1) && (uri.length() == 0)) || uri.equals(ParserConstants.SCR_NAMESPACE)) {
- setHandler(new ComponentElement(this, attributes));
- }
- }
- }
-
- public void characters(char[] ch, int start, int length) throws SAXException {
-
- if (DEBUG) {
- System.out.print("[characters:begin]");
- System.out.print(new String(ch, start, length));
- System.out.println("[characters:end]");
- }
-
- if (handler != this) {
- handler.characters(ch, start, length);
- }
- }
-
- public void endElement(String uri, String localName, String qName) throws SAXException {
-
- if (DEBUG) {
- System.out.println("[endElement:uri]" + uri);
- System.out.println("[endElement:localName]" + localName);
- System.out.println("[endElement:qName]" + qName);
- }
-
- if (handler != this) {
- handler.endElement(uri, localName, qName);
- }
-
- depth--;
- }
-
- public void endPrefixMapping(String prefix) throws SAXException {
- if (DEBUG) {
- System.out.println("[endPrefixMapping:prefix]" + prefix);
- }
- }
-
- public void endDocument() throws SAXException {
- if (DEBUG) {
- System.out.println("[endDocument]");
- }
- }
-
- public void warning(SAXParseException e) throws SAXException {
- if (DEBUG) {
- System.out.println("[warning]");
- e.printStackTrace();
- }
- }
-
- public void error(SAXParseException e) throws SAXException {
- if (DEBUG) {
- System.out.println("[error]");
- e.printStackTrace();
- }
- }
-
- public void fatalError(SAXParseException e) throws SAXException {
- if (DEBUG) {
- System.out.println("[fatalError]");
- e.printStackTrace();
- }
- throw e;
- }
-}
diff --git a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/parser/PropertiesElement.java b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/parser/PropertiesElement.java
deleted file mode 100644
index 883ab55d1..000000000
--- a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/parser/PropertiesElement.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.ds.parser;
-
-import org.eclipse.equinox.ds.model.ComponentDescription;
-import org.eclipse.equinox.ds.model.PropertyResourceDescription;
-import org.xml.sax.Attributes;
-import org.xml.sax.helpers.DefaultHandler;
-
-class PropertiesElement extends DefaultHandler {
- private ParserHandler root;
- private ComponentElement parent;
- private PropertyResourceDescription properties;
-
- PropertiesElement(ParserHandler root, ComponentElement parent, Attributes attributes) {
- this.root = root;
- this.parent = parent;
- properties = new PropertyResourceDescription();
-
- int size = attributes.getLength();
- for (int i = 0; i < size; i++) {
- String key = attributes.getQName(i);
- String value = attributes.getValue(i);
-
- if (key.equals(ParserConstants.ENTRY_ATTRIBUTE)) {
- properties.setEntry(value);
- continue;
- }
- root.logError("unrecognized properties element attribute: " + key);
- }
-
- if (properties.getEntry() == null) {
- root.logError("properties entry not specified");
- }
- }
-
- public void startElement(String uri, String localName, String qName, Attributes attributes) {
- root.logError("properties does not support nested elements");
- }
-
- public void characters(char[] ch, int start, int length) {
- int end = start + length;
- for (int i = start; i < end; i++) {
- if (!Character.isWhitespace(ch[i])) {
- root.logError("element body must be empty");
- }
- }
- }
-
- public void endElement(String uri, String localName, String qName) {
- ComponentDescription component = parent.getComponentDescription();
- component.addPropertyDescription(properties);
- root.setHandler(parent);
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/parser/PropertyElement.java b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/parser/PropertyElement.java
deleted file mode 100644
index 4055cc88c..000000000
--- a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/parser/PropertyElement.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.ds.parser;
-
-import java.util.*;
-import org.eclipse.equinox.ds.model.ComponentDescription;
-import org.eclipse.equinox.ds.model.PropertyValueDescription;
-import org.xml.sax.Attributes;
-import org.xml.sax.helpers.DefaultHandler;
-
-class PropertyElement extends DefaultHandler {
- private ParserHandler root;
- private ComponentElement parent;
- private PropertyValueDescription property;
- private List values;
-
- PropertyElement(ParserHandler root, ComponentElement parent, Attributes attributes) {
- this.root = root;
- this.parent = parent;
- property = new PropertyValueDescription();
- values = new ArrayList();
-
- int size = attributes.getLength();
- for (int i = 0; i < size; i++) {
- String key = attributes.getQName(i);
- String value = attributes.getValue(i);
-
- if (key.equals(ParserConstants.NAME_ATTRIBUTE)) {
- property.setName(value);
- continue;
- }
-
- if (key.equals(ParserConstants.VALUE_ATTRIBUTE)) {
- property.setValue(value);
- continue;
- }
-
- if (key.equals(ParserConstants.TYPE_ATTRIBUTE)) {
- property.setType(value);
- continue;
- }
- root.logError("unrecognized properties element attribute: " + key);
- }
-
- if (property.getName() == null) {
- root.logError("property name not specified");
- }
- }
-
- public void startElement(String uri, String localName, String qName, Attributes attributes) {
- root.logError("property does not support nested elements");
- }
-
- public void characters(char[] ch, int start, int length) {
- int end = start + length;
- int cursor = start;
- while (cursor < end) {
- if (ch[cursor] == '\n') {
- charLine(ch, start, cursor - start);
- start = cursor;
- }
- cursor++;
- }
- charLine(ch, start, cursor - start);
- }
-
- private void charLine(char[] ch, int start, int length) {
- if (length > 0) {
- String line = new String(ch, start, length).trim();
- if (line.length() > 0) {
- values.add(line);
- }
- }
- }
-
- public void endElement(String uri, String localName, String qName) {
-
- int size = values.size();
-
- // If the value attribute is specified, then body of the property
- // element is ignored.
- if (property.getValue() != null) {
- if (size > 0) {
-
- root.logError("If the value attribute is specified, the body of the property element is ignored. key = " + property.getName() + " value = " + property.getValue());
- }
-
- //parse the value according to the type
- String type = property.getType();
- if (type == null || type.equals("String")) {
- //value is already a string
- } else if (type.equals("Long")) {
- property.setValue(Long.valueOf((String) property.getValue(), 10));
- } else if (type.equals("Double")) {
- property.setValue(Double.valueOf((String) property.getValue()));
- } else if (type.equals("Float")) {
- property.setValue(Float.valueOf((String) property.getValue()));
- } else if (type.equals("Integer")) {
- property.setValue(Integer.valueOf((String) property.getValue()));
- } else if (type.equals("Byte")) {
- property.setValue(Byte.valueOf((String) property.getValue(), 10));
- } else if (type.equals("Char")) {
- property.setValue(new Character(((String) property.getValue()).charAt(0)));
- } else if (type.equals("Boolean")) {
- property.setValue(Boolean.valueOf((String) property.getValue()));
- } else if (type.equals("Short")) {
- property.setValue(Short.valueOf((String) property.getValue(), 10));
- }
-
- // if characters were specified ( values are specifed in the body of
- // the property element )
- } else if (size > 0) {
- // if String then store as String[]
- if (property.getType().equals("String")) {
- String[] result = new String[size];
- values.toArray(result);
- property.setValue(result);
- } else if (property.getType().equals("Integer")) {
- int[] result = new int[size];
- if (values != null) {
- Iterator it = values.iterator();
- int i = 0;
- while (it.hasNext()) {
- Integer value = new Integer((String) it.next());
- result[i++] = value.intValue();
- }
- property.setValue(result);
- }
- } else if (property.getType().equals("Long")) {
- long[] result = new long[size];
- if (values != null) {
- Iterator it = values.iterator();
- int i = 0;
- while (it.hasNext()) {
- Long value = new Long((String) it.next());
- result[i++] = value.longValue();
- }
- property.setValue(result);
- }
- } else if (property.getType().equals("Double")) {
- double[] result = new double[size];
- if (values != null) {
- Iterator it = values.iterator();
- int i = 0;
- while (it.hasNext()) {
- Double value = new Double((String) it.next());
- result[i++] = value.doubleValue();
- }
- property.setValue(result);
- }
- } else if (property.getType().equals("Float")) {
- float[] result = new float[size];
- if (values != null) {
- Iterator it = values.iterator();
- int i = 0;
- while (it.hasNext()) {
- Float value = new Float((String) it.next());
- result[i++] = value.floatValue();
- }
- property.setValue(result);
- }
- } else if (property.getType().equals("Byte")) {
- byte[] result = new byte[size];
- if (values != null) {
- Iterator it = values.iterator();
- int i = 0;
- while (it.hasNext()) {
- Byte value = new Byte((String) it.next());
- result[i++] = value.byteValue();
- }
- property.setValue(result);
- }
- } else if (property.getType().equals("Char")) {
- char[] result = new char[size];
- if (values != null) {
- Iterator it = values.iterator();
- int i = 0;
- while (it.hasNext()) {
- char[] value = ((String) it.next()).toCharArray();
- result[i++] = value[0];
- }
- property.setValue(result);
- }
- } else if (property.getType().equals("Boolean")) {
- boolean[] result = new boolean[size];
- if (values != null) {
- Iterator it = values.iterator();
- int i = 0;
- while (it.hasNext()) {
- Boolean value = new Boolean((String) it.next());
- result[i++] = value.booleanValue();
- }
- property.setValue(result);
- }
- } else if (property.getType().equals("Short")) {
- short[] result = new short[size];
- if (values != null) {
- Iterator it = values.iterator();
- int i = 0;
- while (it.hasNext()) {
- Short value = new Short((String) it.next());
- result[i++] = value.shortValue();
- }
- property.setValue(result);
- }
- }
-
- }
-
- ComponentDescription component = parent.getComponentDescription();
- component.addPropertyDescription(property);
- root.setHandler(parent);
- }
-}
diff --git a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/parser/ProvideElement.java b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/parser/ProvideElement.java
deleted file mode 100644
index bc7ce8b3d..000000000
--- a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/parser/ProvideElement.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.ds.parser;
-
-import org.eclipse.equinox.ds.model.ProvideDescription;
-import org.eclipse.equinox.ds.model.ServiceDescription;
-import org.xml.sax.Attributes;
-import org.xml.sax.helpers.DefaultHandler;
-
-class ProvideElement extends DefaultHandler {
- private ParserHandler root;
- private ServiceElement parent;
- private ProvideDescription provide;
-
- ProvideElement(ParserHandler root, ServiceElement parent, Attributes attributes) {
- this.root = root;
- this.parent = parent;
- provide = new ProvideDescription();
-
- int size = attributes.getLength();
- for (int i = 0; i < size; i++) {
- String key = attributes.getQName(i);
- String value = attributes.getValue(i);
-
- if (key.equals(ParserConstants.INTERFACE_ATTRIBUTE)) {
- provide.setInterfacename(value);
- continue;
- }
- root.logError("unrecognized provide element attribute: " + key);
- }
-
- if (provide.getInterfacename() == null) {
- root.logError("provide interface not specified");
- }
- }
-
- public void startElement(String uri, String localName, String qName, Attributes attributes) {
- root.logError("provide does not support nested elements");
- }
-
- public void characters(char[] ch, int start, int length) {
- int end = start + length;
- for (int i = start; i < end; i++) {
- if (!Character.isWhitespace(ch[i])) {
- root.logError("element body must be empty");
- }
- }
- }
-
- public void endElement(String uri, String localName, String qName) {
- ServiceDescription service = parent.getServiceDescription();
-
- service.addProvide(provide);
- root.setHandler(parent);
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/parser/ReferenceElement.java b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/parser/ReferenceElement.java
deleted file mode 100644
index f43a641b3..000000000
--- a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/parser/ReferenceElement.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.ds.parser;
-
-import org.eclipse.equinox.ds.model.ComponentDescription;
-import org.eclipse.equinox.ds.model.ReferenceDescription;
-import org.xml.sax.Attributes;
-import org.xml.sax.helpers.DefaultHandler;
-
-class ReferenceElement extends DefaultHandler {
- private ParserHandler root;
- private ComponentElement parent;
- private ReferenceDescription reference;
-
- ReferenceElement(ParserHandler root, ComponentElement parent, Attributes attributes) {
- this.root = root;
- this.parent = parent;
- reference = new ReferenceDescription();
-
- int size = attributes.getLength();
- for (int i = 0; i < size; i++) {
- String key = attributes.getQName(i);
- String value = attributes.getValue(i);
-
- if (key.equals(ParserConstants.NAME_ATTRIBUTE)) {
- reference.setName(value);
- continue;
- }
-
- if (key.equals(ParserConstants.INTERFACE_ATTRIBUTE)) {
- reference.setInterfacename(value);
- continue;
- }
-
- if (key.equals(ParserConstants.CARDINALITY_ATTRIBUTE)) {
- reference.setCardinality(value);
- continue;
- }
-
- if (key.equals(ParserConstants.POLICY_ATTRIBUTE)) {
- reference.setPolicy(value);
- continue;
- }
-
- if (key.equals(ParserConstants.TARGET_ATTRIBUTE)) {
- reference.setTarget(value);
- continue;
- }
-
- if (key.equals(ParserConstants.BIND_ATTRIBUTE)) {
- reference.setBind(value);
- continue;
- }
-
- if (key.equals(ParserConstants.UNBIND_ATTRIBUTE)) {
- reference.setUnbind(value);
- continue;
- }
- root.logError("unrecognized reference element attribute: " + key);
- }
-
- if (reference.getName() == null) {
- root.logError("reference name not specified");
- }
- if (reference.getInterfacename() == null) {
- root.logError("reference interface not specified");
- }
- }
-
- public void startElement(String uri, String localName, String qName, Attributes attributes) {
- root.logError("reference does not support nested elements");
- }
-
- public void characters(char[] ch, int start, int length) {
- int end = start + length;
- for (int i = start; i < end; i++) {
- if (!Character.isWhitespace(ch[i])) {
- root.logError("element body must be empty");
- }
- }
- }
-
- public void endElement(String uri, String localName, String qName) {
- ComponentDescription component = parent.getComponentDescription();
- component.addReferenceDescription(reference);
- root.setHandler(parent);
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/parser/ServiceElement.java b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/parser/ServiceElement.java
deleted file mode 100644
index 0039192e5..000000000
--- a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/parser/ServiceElement.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.ds.parser;
-
-import org.eclipse.equinox.ds.model.ComponentDescription;
-import org.eclipse.equinox.ds.model.ServiceDescription;
-import org.xml.sax.Attributes;
-import org.xml.sax.helpers.DefaultHandler;
-
-class ServiceElement extends DefaultHandler {
- private ParserHandler root;
- private ComponentElement parent;
- private ServiceDescription service;
-
- public ServiceElement(ParserHandler root, ComponentElement parent, Attributes attributes) {
- this.root = root;
- this.parent = parent;
- service = new ServiceDescription();
-
- int size = attributes.getLength();
- for (int i = 0; i < size; i++) {
- String key = attributes.getQName(i);
- String value = attributes.getValue(i);
-
- if (key.equals(ParserConstants.SERVICEFACTORY_ATTRIBUTE)) {
- service.setServicefactory(value.equalsIgnoreCase("true"));
- continue;
- }
- root.logError("unrecognized service element attribute: " + key);
- }
- }
-
- ServiceDescription getServiceDescription() {
- return service;
- }
-
- public void startElement(String uri, String localName, String qName, Attributes attributes) {
- if (localName.equals(ParserConstants.PROVIDE_ELEMENT)) {
- root.setHandler(new ProvideElement(root, this, attributes));
- return;
- }
- root.logError("unrecognized element of service: " + localName);
- }
-
- public void characters(char[] ch, int start, int length) {
- int end = start + length;
- for (int i = start; i < end; i++) {
- if (!Character.isWhitespace(ch[i])) {
- root.logError("element body must be empty");
- }
- }
- }
-
- public void endElement(String uri, String localName, String qName) {
- ComponentDescription component = parent.getComponentDescription();
- if (component.getService() != null) {
- root.logError("more than one service element");
- }
-
- if (service.getProvides().length == 0) {
- root.logError("no provide elements specified");
- }
-
- if ((component.getFactory() != null) && service.isServicefactory()) {
- root.logError("component factory is incompatible with Service factory ");
- }
-
- component.setService(service);
- root.setHandler(parent);
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/resolver/CircularityException.java b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/resolver/CircularityException.java
deleted file mode 100644
index 42bae5aee..000000000
--- a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/resolver/CircularityException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.ds.resolver;
-
-import org.eclipse.equinox.ds.model.ComponentDescriptionProp;
-
-/**
- *
- */
-class CircularityException extends Exception {
-
- /**
- * Eclipse-generated <code>serialVersionUID</code>
- */
- private static final long serialVersionUID = 8249461007142713618L;
-
- private ComponentDescriptionProp cdp;
-
- CircularityException(ComponentDescriptionProp cdp) {
- this.cdp = cdp;
- }
-
- ComponentDescriptionProp getCircularDependency() {
- return cdp;
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/resolver/Reference.java b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/resolver/Reference.java
deleted file mode 100644
index 64e2ff7d5..000000000
--- a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/resolver/Reference.java
+++ /dev/null
@@ -1,247 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.ds.resolver;
-
-import java.util.*;
-import org.eclipse.equinox.ds.model.ComponentDescriptionProp;
-import org.eclipse.equinox.ds.model.ReferenceDescription;
-import org.osgi.framework.*;
-
-/**
- *
- * Wrapper for a {@link ReferenceDescription} that may have
- * a different target filter set by ConfigAdmin or ComponentFactory.newInstance()
- *
- * @see org.eclipse.equinox.ds.model.ReferenceDescription
- * @version $Revision: 1.2 $
- */
-public class Reference {
-
- private static final String TARGET = ".target";
- private ReferenceDescription referenceDescription;
- private ComponentDescriptionProp cdp;
- private String target;
-
- /**
- * The Set of {@link ServiceReference ServiceReferences} bound to this Reference
- */
- private Set serviceReferences = new HashSet();
-
- // ServiceReference:ServiceObject that binded to this instance
- private Map serviceReferenceToServiceObject = new Hashtable();
-
- /**
- * Create a new Reference object.
- *
- * If properties include a (reference name).target property, that overrides
- * the target in the {@link ReferenceDescription}.
- *
- * @param referenceDescription
- * @param properties Properties for this Component Configuration
- */
- Reference(ReferenceDescription referenceDescription, Hashtable properties) {
- this.referenceDescription = referenceDescription;
-
- //properties can override the Service Component XML
- this.target = (String) properties.get(referenceDescription.getName() + TARGET);
-
- this.target = this.target != null ? this.target : referenceDescription.getTarget();
-
- // RFC 80 section 5.3.1.3:
- // If [target] is not specified and there is no <reference-name>.target
- // component
- // property, then the selection filter used to select the desired
- // service is
- // “(objectClass=�+<interface-name>+�)�.
- this.target = this.target != null ? this.target : "(objectClass=" + referenceDescription.getInterfacename() + ")";
-
- }
-
- /**
- * Set the Component Configuration that this reference belongs to
- */
- void setComponentDescriptionProp(ComponentDescriptionProp parent) {
- cdp = parent;
- }
-
- /**
- * Get the Component Configuration that this reference belongs to
- */
- public ComponentDescriptionProp getComponentDescriptionProp() {
- return cdp;
- }
-
- /**
- * Check if there is at least one service registered that satisfies this
- * reference.
- *
- * Checks ServicePermission.GET.
- *
- * @param context Bundle context used to call
- * {@link BundleContext#getServiceReferences(java.lang.String, java.lang.String)}
- * @return whether this Reference can be satisfied by the currently registered services
- */
- boolean hasProvider(BundleContext context) {
-
- // Get all service references for this target filter
- try {
- ServiceReference[] providers = null;
- providers = context.getServiceReferences(referenceDescription.getInterfacename(), target);
- // if there is no service published that this Service
- // ComponentReferences
- if (providers != null) {
- return true;
- }
- return false;
- } catch (InvalidSyntaxException e) {
- //TODO log something?
- return false;
- }
- }
-
- public ReferenceDescription getReferenceDescription() {
- return referenceDescription;
- }
-
- public String getTarget() {
- return target;
- }
-
- /**
- * Check if a {@link ServiceReference} should be dynamically bound to this
- * Reference.
- *
- * @param serviceReference
- */
- public boolean dynamicBindReference(ServiceReference serviceReference) {
-
- //check policy
- if ("static".equals(referenceDescription.getPolicy())) {
- return false;
- }
-
- //check interface
- List provideList = Arrays.asList((String[]) (serviceReference.getProperty("objectClass")));
- if (!provideList.contains(this.getReferenceDescription().getInterfacename())) {
- return false;
- }
-
- //check target filter
- Filter filter;
- try {
- filter = FrameworkUtil.createFilter(target);
- } catch (InvalidSyntaxException e) {
- //TODO log something?
- return false;
- }
- if (!filter.match(serviceReference)) {
- return false;
- }
-
- //check cardinality
- int currentRefCount = serviceReferences.size();
- if (currentRefCount < referenceDescription.getCardinalityHigh()) {
- return true;
- }
- return false;
-
- }
-
- /**
- * Check if we need to be dynamically unbound from a {@link ServiceReference}
- *
- * @param serviceReference
- */
- boolean dynamicUnbindReference(ServiceReference serviceReference) {
-
- // nothing dynamic to do if static
- if ("static".equals(referenceDescription.getPolicy())) {
- return false;
- }
-
- // now check if the ServiceReference is found in the list of saved
- // ServiceReferences for this reference
- if (!serviceReferences.contains(serviceReference)) {
- return false;
- }
-
- return true;
-
- }
-
- public void addServiceReference(ServiceReference serviceReference) {
- serviceReferences.add(serviceReference);
- }
-
- public void removeServiceReference(ServiceReference serviceReference) {
- serviceReferences.remove(serviceReference);
- serviceReferenceToServiceObject.remove(serviceReference);
- }
-
- public void clearServiceReferences() {
- serviceReferences.clear();
- serviceReferenceToServiceObject.clear();
- }
-
- public Set getServiceReferences() {
- return serviceReferences;
- }
-
- public boolean bindedToServiceReference(ServiceReference serviceReference) {
- return serviceReferences.contains(serviceReference);
- }
-
- public void addServiceReference(ServiceReference serviceReference, Object serviceObject) {
- addServiceReference(serviceReference);
- serviceReferenceToServiceObject.put(serviceReference, serviceObject);
- }
-
- public Object getServiceObject(ServiceReference serviceReference) {
- return serviceReferenceToServiceObject.get(serviceReference);
- }
-
- /**
- * Check if this reference can be satisfied by the service provided by one
- * of a list of Component Configurations
- *
- * @param cdps a List of {@link ComponentDescriptionProp}s to search for providers
- * for this reference
- * @return the providing CDP or null if none
- */
- ComponentDescriptionProp findProviderCDP(List cdps) {
-
- Filter filter;
- try {
-
- filter = FrameworkUtil.createFilter(target);
- } catch (InvalidSyntaxException e) {
- //TODO log something?
- return null;
- }
-
- // loop thru cdps to search for provider of service
- Iterator it = cdps.iterator();
- while (it.hasNext()) {
- ComponentDescriptionProp providerCDP = (ComponentDescriptionProp) it.next();
- List provideList = providerCDP.getComponentDescription().getServicesProvided();
-
- if (provideList.contains(this.getReferenceDescription().getInterfacename())) {
- // check the target field
- if (filter.match(providerCDP.getProperties())) {
- return providerCDP;
- }
- }
- }
-
- return null;
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/resolver/Resolver.java b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/resolver/Resolver.java
deleted file mode 100644
index 5f6eab086..000000000
--- a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/resolver/Resolver.java
+++ /dev/null
@@ -1,946 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.ds.resolver;
-
-import java.io.IOException;
-import java.util.*;
-import org.eclipse.equinox.ds.Activator;
-import org.eclipse.equinox.ds.Log;
-import org.eclipse.equinox.ds.instance.InstanceProcess;
-import org.eclipse.equinox.ds.model.*;
-import org.eclipse.equinox.ds.workqueue.WorkDispatcher;
-import org.eclipse.equinox.ds.workqueue.WorkQueue;
-import org.osgi.framework.*;
-import org.osgi.service.cm.Configuration;
-import org.osgi.service.cm.ConfigurationAdmin;
-import org.osgi.service.component.ComponentConstants;
-import org.osgi.service.component.ComponentException;
-import org.osgi.service.log.LogService;
-import org.osgi.util.tracker.ServiceTracker;
-
-/**
- * Resolver - resolves the Service Components. This includes creating Component
- * Configurations, resolving the required referenced services, and checking for
- * circular dependencies.
- *
- * The Resolver implements AllServiceListener so it can be informed about service
- * changes in the framework.
- *
- * @version $Revision: 1.1 $
- */
-public class Resolver implements AllServiceListener, WorkDispatcher {
-
- /* set this to true to compile in debug messages */
- private static final boolean DEBUG = false;
-
- /**
- * next free component id.
- * See OSGi R4 Specification section 112.6 "Component Properties"
- */
- private static long componentid;
-
- /* ServiceTracker for configurationAdmin */
- public ServiceTracker configAdminTracker;
-
- /**
- * Service Component instances need to be built.
- */
- private static final int BUILD = 1;
-
- /**
- * Service Component instances to bind dynamically
- */
- public static final int DYNAMICBIND = 3;
-
- /**
- * Main class for the SCR
- */
- private Activator main;
-
- public InstanceProcess instanceProcess;
-
- /**
- * List of {@link ComponentDescriptionProp}s - the currently "enabled"
- * Component Configurations.
- */
- public List enabledCDPs;
-
- /**
- * List of {@link ComponentDescriptionProp}s - the currently "satisfied"
- * Component Configurations. Note that to be satisfied a Component
- * Configuration must first be enabled, so this list is a subset of
- * {@link Resolver#enabledCDPs enabledCDPs}.
- */
- public List satisfiedCDPs;
-
- /**
- * A map of name:Service Component (String):({@link ComponentDescription})
- */
- public Map enabledCDsByName;
-
- private WorkQueue workQueue;
-
- /**
- * Resolver constructor
- *
- * @param main Main class of SCR
- */
- public Resolver(Activator main) {
- this.main = main;
-
- componentid = 1;
-
- // for now use Main's workqueue
- workQueue = main.workQueue;
-
- enabledCDPs = new ArrayList();
- satisfiedCDPs = new ArrayList();
- enabledCDsByName = new HashMap();
-
- configAdminTracker = new ServiceTracker(main.context, ConfigurationAdmin.class.getName(), null);
- configAdminTracker.open();
-
- instanceProcess = new InstanceProcess(main);
-
- //start listening to ServiceChanged events
- main.context.addServiceListener(this);
-
- }
-
- /**
- * Clean up the SCR is shutting down
- */
- public void dispose() {
-
- //stop listening to ServiceChanged events
- main.context.removeServiceListener(this);
-
- instanceProcess.dispose();
- instanceProcess = null;
-
- configAdminTracker.close();
- configAdminTracker = null;
-
- enabledCDPs = null;
- satisfiedCDPs = null;
- enabledCDsByName = null;
-
- }
-
- /**
- * Enable Service Components - create Component Configuration(s) for the
- * Service Components and try to satisfy their dependencies.
- *
- * <p>
- * For each Service Component ({@link ComponentDescription}) check
- * ConfigurationAdmin for properties and create a Component Configuration
- * ({@link ComponentDescriptionProp}).
- * </p>
- *
- * <p>
- * If a {@link org.osgi.service.cm.ManagedServiceFactory ManagedServiceFactory}
- * is registered for the Service Component, we may create multiple Component
- * Configurations.
- * </p>
- *
- * <p>
- * After the Component Configuration(s) are created, call
- * {@link Resolver#resolve(ServiceEvent) getEligible(null)} to try to
- * satisfy them.
- * </p>
- *
- * @param componentDescriptions - a List of {@link ComponentDescription}s to
- * be enabled
- */
- public void enableComponents(List componentDescriptions) throws ComponentException {
-
- Iterator it = componentDescriptions.iterator();
- while (it.hasNext()) {
- ComponentDescription cd = (ComponentDescription) it.next();
-
- // add to our enabled lookup list
- enabledCDsByName.put(cd.getName(), cd);
-
- // check for a Configuration properties for this component
- Configuration config = null;
- try {
- ConfigurationAdmin configurationAdmin = (ConfigurationAdmin) configAdminTracker.getService();
- if (configurationAdmin != null) {
- config = configurationAdmin.getConfiguration(cd.getName(), cd.getBundleContext().getBundle().getLocation());
- }
- } catch (IOException e) {
- // Log it and continue
- Log.log(1, "[SCR] IOException when getting Configuration Properties. ", e);
- }
-
- // if no Configuration
- if (config == null) {
- // create ComponentDescriptionProp
- map(cd, null);
-
- } else {
-
- // if ManagedServiceFactory
- if (config.getFactoryPid() != null) {
-
- // if ComponentFactory is specified
- if (cd.getFactory() != null) {
- throw new ComponentException("incompatible to specify both ComponentFactory and ManagedServiceFactory are incompatible");
- }
-
- Configuration[] configs = null;
- try {
- ConfigurationAdmin cm = (ConfigurationAdmin) configAdminTracker.getService();
- configs = cm.listConfigurations("(service.factoryPid=" + config.getFactoryPid() + ")");
- } catch (InvalidSyntaxException e) {
- Log.log(1, "[SCR] InvalidSyntaxException when getting CM Configurations. ", e);
- } catch (IOException e) {
- Log.log(1, "[SCR] IOException when getting CM Configurations. ", e);
- }
-
- // for each MSF set of properties(P), map(CD,P)
- if (configs != null) {
- for (int i = 0; i < configs.length; i++) {
- map(cd, configs[i].getProperties());
- }
- }
- } else {
- // if Service
- map(cd, config.getProperties());
- }
- }
- }
- // resolve
- resolve(null);
- }
-
- /**
- * Combine ConfigAdmin properties with a Service Component
- * ({@link ComponentDescription}) to create a Component Configuration
- * ({@link ComponentConfiguration}), and add it to our list of enabled
- * Component Configurations ({@link Resolver#enabledCDPs}).
- *
- * The ConfigAdmin properties are combined with the properties from the
- * Service Component's XML.
- *
- * @param cd Service Component
- * @param configAdminProps ConfigAdmin properties for this Component
- * Configuration
- */
- public ComponentDescriptionProp map(ComponentDescription cd, Dictionary configAdminProps) {
- return doMap(cd, configAdminProps, cd.getFactory() != null);
- }
-
- /**
- * Create a Component Configuration of a Service Component that has the
- * "factory" attribute.
- *
- * @see Resolver#map(ComponentDescription, Dictionary)
- * @see ComponentDescriptionProp#componentFactory
- */
- public ComponentDescriptionProp mapFactoryInstance(ComponentDescription cd, Dictionary configAdminProps) {
- return doMap(cd, configAdminProps, false);
- }
-
- private ComponentDescriptionProp doMap(ComponentDescription cd, Dictionary configAdminProps, boolean componentFactory) {
-
- // Create CD+P
-
- // calculate the CDP's properties
- Hashtable properties = initProperties(cd, configAdminProps);
-
- // for each Reference Description, create a reference object
- List references = new ArrayList();
- Iterator it = cd.getReferenceDescriptions().iterator();
- while (it.hasNext()) {
- ReferenceDescription referenceDesc = (ReferenceDescription) it.next();
-
- // create new Reference Object
- Reference ref = new Reference(referenceDesc, properties);
- references.add(ref);
-
- }
- references = !references.isEmpty() ? references : Collections.EMPTY_LIST;
-
- ComponentDescriptionProp cdp = new ComponentDescriptionProp(cd, references, properties, componentFactory);
-
- //for each Reference, set it's "parent" (the CDP)
- it = cdp.getReferences().iterator();
- while (it.hasNext()) {
- Reference reference = (Reference) it.next();
-
- // set parent CDP
- reference.setComponentDescriptionProp(cdp);
- }
-
- cd.addComponentDescriptionProp(cdp);
-
- // add CD+P to set
- enabledCDPs.add(cdp);
-
- return cdp;
- }
-
- /**
- * Initialize Properties for a CD+P
- *
- * The property elements provide default or supplemental property values if
- * not overridden by the properties retrieved from Configuration Admin.
- *
- * The property and properties elements are processed in top to bottom
- * order. This allows later elements to override property values defined by
- * earlier elements. There can be many property and properties elements and
- * they may be interleaved.
- *
- * @return Dictionary properties
- */
- private Hashtable initProperties(ComponentDescription cd, Dictionary configAdminProps) {
-
- Hashtable properties = new Hashtable();
-
- // 0) add Reference target properties
- Iterator it = cd.getReferenceDescriptions().iterator();
- while (it.hasNext()) {
- ReferenceDescription referenceDesc = (ReferenceDescription) it.next();
- if (referenceDesc.getTarget() != null) {
- properties.put(referenceDesc.getName() + ".target", referenceDesc.getTarget());
- }
- }
-
- // 1) get properties from Service Component XML, in parse order
- properties.putAll(cd.getProperties());
-
- // 2) Add configAdmin properties
- if (configAdminProps != null) {
- Enumeration keys = configAdminProps.keys();
- while (keys.hasMoreElements()) {
- Object key = keys.nextElement();
- properties.put(key, configAdminProps.get(key));
- }
- }
-
- // add component.name and component.id (cannot be overridden)
- properties.put(ComponentConstants.COMPONENT_NAME, cd.getName());
- properties.put(ComponentConstants.COMPONENT_ID, new Long(getNextComponentId()));
-
- // add component.factory if it's a factory
- if (cd.getFactory() != null) {
- properties.put(ComponentConstants.COMPONENT_FACTORY, cd.getFactory());
- }
-
- // add ObjectClass so we can match target filters before actually being
- // registered
- List servicesProvided = cd.getServicesProvided();
- if (!servicesProvided.isEmpty()) {
- properties.put(Constants.OBJECTCLASS, servicesProvided.toArray(new String[servicesProvided.size()]));
- }
-
- return properties;
- }
-
- /**
- * Disable Service Components.
- *
- * For each Service Component ({@link ComponentDescription}),
- * dispose of all of it's Component Configurations
- * ({@link ComponentDescriptionProp}s).
- *
- * @see Resolver#disposeComponentConfigs(List)
- *
- * @param componentDescriptions List of {@link ComponentDescriptionProp}s to
- * disable
- */
- public void disableComponents(List componentDescriptions) {
-
- // Received list of CDs to disable
- Iterator it = componentDescriptions.iterator();
- while (it.hasNext()) {
-
- // get the CD
- ComponentDescription cd = (ComponentDescription) it.next();
-
- disposeComponentConfigs((List) ((ArrayList) cd.getComponentDescriptionProps()).clone());
-
- cd.clearComponentDescriptionProps();
-
- enabledCDsByName.remove(cd.getName());
- }
-
- }
-
- /**
- * Dispose of Component Configurations ({@link ComponentDescriptionProp}s).
- *
- * Remove Component Configurations from satisfied and enabled lists, and send
- * to InstanceProcess to be unregistered, deactivated, and unbound.
- *
- * @see InstanceProcess#disposeComponentConfigs(List)
- *
- * @param cdps List of {@link ComponentDescriptionProp}s
- */
- public void disposeComponentConfigs(List cdps) {
- // unregister, deactivate, and unbind
- satisfiedCDPs.removeAll(cdps);
- enabledCDPs.removeAll(cdps);
- instanceProcess.disposeComponentConfigs(cdps);
- }
-
- /**
- * Process a service change
- * <p>
- * A change has happened in the OSGi service environment, or new
- * Component Configurations have been added to the system.
- * </p>
- * Depending on the change, take the following actions:
- * <p>
- * If new Component Configurations were added (param event is null):
- * <ol>
- * <li>Check for circularity and mark cycles</li>
- * <li>Send newly satisfied Component Configurations to Instance
- * process</li>
- * </ol>
- * </p>
- * <p>
- * If a service was registered:
- * <ol>
- * <li>Put "Dynamic Bind" events on the queue for any Component
- * Configurations which should be bound to the new service</li>
- * <li>Send newly satisfied Component Configurations to Instance
- * process</li>
- * </ol>
- * </p>
- * <p>
- * If a service was modified:
- * <ol>
- * <li>Synchronously dispose of all Component Configurations that
- * become unsatisfied</li>
- * <li>Put "Dynamic Unbind Bind" events on the queue for any remaining
- * Component Configurations which should be unbound from the service</li>
- * <li>Put "Dynamic Bind" events on the queue for any Component
- * Configurations which should be bound to the modified service</li>
- * <li>Send newly satisfied Component Configurations to Instance
- * process</li>
- * </ol>
- * </p>
- * <p>
- * If a service was unregistered:
- * <ol>
- * <li>Synchronously dispose of all Component Configurations that
- * become unsatisfied</li>
- * <li>Put "Dynamic Unbind Bind" events on the queue for any remaining
- * Component Configurations which should be unbound from the service</li>
- * </ol>
- * </p>
- *
- * @param event the service event or null if new cdps were added to the enabled list
- */
- private void resolve(ServiceEvent event) {
-
- // if added CDPs
- if (event == null) {
- // we added a CDP, so check for circularity and mark
- // cycles
- resolveCycles();
-
- // get list of newly satisfied CDPs and build them
- List newlySatisfiedCDPs = resolveSatisfied();
- newlySatisfiedCDPs.removeAll(satisfiedCDPs);
-
- if (!newlySatisfiedCDPs.isEmpty()) {
- satisfiedCDPs.addAll(newlySatisfiedCDPs); // add to satisfiedCDPs before dispatch
- workQueue.enqueueWork(this, BUILD, newlySatisfiedCDPs);
- }
-
- }
- // if service registered
- else if (event.getType() == ServiceEvent.REGISTERED) {
-
- // dynamic bind
- List dynamicBind = selectDynamicBind(event.getServiceReference());
- if (!dynamicBind.isEmpty()) {
- workQueue.enqueueWork(this, DYNAMICBIND, dynamicBind);
- }
-
- // get list of newly satisfied CDPs and build them
- List newlySatisfiedCDPs = resolveSatisfied();
- newlySatisfiedCDPs.removeAll(satisfiedCDPs);
- if (!newlySatisfiedCDPs.isEmpty()) {
- satisfiedCDPs.addAll(newlySatisfiedCDPs); // add to satisfiedCDPs before dispatch
- workQueue.enqueueWork(this, BUILD, newlySatisfiedCDPs);
- }
-
- }
- // if service modified
- else if (event.getType() == ServiceEvent.MODIFIED) {
-
- // check for newly unsatisfied components and synchronously
- // dispose them
- List newlyUnsatisfiedCDPs = (List) ((ArrayList) satisfiedCDPs).clone();
- newlyUnsatisfiedCDPs.removeAll(resolveSatisfied());
- if (!newlyUnsatisfiedCDPs.isEmpty()) {
- satisfiedCDPs.removeAll(newlyUnsatisfiedCDPs);
-
- instanceProcess.disposeComponentConfigs(newlyUnsatisfiedCDPs);
- }
-
- // dynamic unbind
- // check each satisfied cdp - do we need to unbind
- Map dynamicUnBind = selectDynamicUnBind(event.getServiceReference());
- if (!dynamicUnBind.isEmpty()) {
- instanceProcess.dynamicUnBind(dynamicUnBind);
- }
-
- // dynamic bind
- List dynamicBind = selectDynamicBind(event.getServiceReference());
- if (!dynamicBind.isEmpty()) {
- workQueue.enqueueWork(this, DYNAMICBIND, dynamicBind);
- }
-
- // get list of newly satisfied CDPs and build them
- List newlySatisfiedCDPs = resolveSatisfied();
- newlySatisfiedCDPs.removeAll(satisfiedCDPs);
- if (!newlySatisfiedCDPs.isEmpty()) {
- satisfiedCDPs.addAll(newlySatisfiedCDPs); // add to satisfiedCDPs before dispatch
- workQueue.enqueueWork(this, BUILD, newlySatisfiedCDPs);
- }
-
- }
- // if service unregistering
- else if (event.getType() == ServiceEvent.UNREGISTERING) {
-
- // check for newly unsatisfied components and
- // synchronously dispose them
- List newlyUnsatisfiedCDPs = (List) ((ArrayList) satisfiedCDPs).clone();
- newlyUnsatisfiedCDPs.removeAll(resolveSatisfied());
- if (!newlyUnsatisfiedCDPs.isEmpty()) {
- satisfiedCDPs.removeAll(newlyUnsatisfiedCDPs);
-
- instanceProcess.disposeComponentConfigs(newlyUnsatisfiedCDPs);
- }
-
- // dynamic unbind
- Map dynamicUnBind = selectDynamicUnBind(event.getServiceReference());
- if (!dynamicUnBind.isEmpty()) {
- instanceProcess.dynamicUnBind(dynamicUnBind);
- }
-
- }
-
- }
-
- /**
- * Check if a particular CDP is satisfied. Also checks for circularity. If
- * cdp is satisfied it is added to satisfiedCDPs list, but not sent to
- * instance process
- *
- * @param cdp
- * @return
- */
- public boolean justResolve(ComponentDescriptionProp cdp) {
-
- // we added a CDP, so check for circularity and mark
- // cycles
- resolveCycles();
-
- // get list of newly satisfied CDPs and build them
- List newlySatisfiedCDPs = resolveSatisfied();
- newlySatisfiedCDPs.removeAll(satisfiedCDPs);
-
- if (!newlySatisfiedCDPs.contains(cdp)) {
- return false;
- }
- satisfiedCDPs.add(cdp);
- return true;
-
- }
-
- /**
- * Calculate which of the currently enabled Component Configurations
- * ({@link Resolver#enabledCDPs}) are "satisfied".
- *
- * <p>
- * An "enabled" Component
- * Configuration is "satisfied" if there is at least one OSGi Service
- * registered that has the correct interface and matches the target filter
- * for each of it's required (cardinality = "1..1" or "1..n") references.
- * </p>
- * <p>
- * If a Component Configuration will register a service and security is
- * enabled, check if the bundle it comes from has
- * {@link ServicePermission#REGISTER} for that service. If the Component
- * Configuration does not have the necessary permission it is not "satisfied".
- * </p>
- * @return List of {@link ComponentDescriptionProp}s that are "satisfied"
- */
- private List resolveSatisfied() {
- List resolvedSatisfiedCDPs = new ArrayList();
-
- Iterator it = enabledCDPs.iterator();
- while (it.hasNext()) {
- ComponentDescriptionProp cdp = (ComponentDescriptionProp) it.next();
- ComponentDescription cd = cdp.getComponentDescription();
-
- // check if all the services needed by the CDP are available
- List refs = cdp.getReferences();
- Iterator iterator = refs.iterator();
- boolean hasProviders = true;
- while (iterator.hasNext()) {
- Reference reference = (Reference) iterator.next();
- if (reference != null) {
- if (reference.getReferenceDescription().isRequired() && !reference.hasProvider(cdp.getComponentDescription().getBundleContext())) {
- hasProviders = false;
- break;
- }
- }
- }
- if (!hasProviders)
- continue;
-
- // check if the bundle providing the service has permission to
- // register the provided interface(s)
- // if a service is provided
- // TODO we can cache the ServicePermission objects
- if (cd.getService() != null && System.getSecurityManager() != null) {
- ProvideDescription[] provides = cd.getService().getProvides();
- Bundle bundle = cd.getBundleContext().getBundle();
- boolean hasPermission = true;
- for (int i = 0; i < provides.length; i++) {
- // make sure bundle has permission to register the service
- if (!bundle.hasPermission(new ServicePermission(provides[i].getInterfacename(), ServicePermission.REGISTER))) {
- hasPermission = false;
- break;
- }
- }
- if (!hasPermission)
- continue;
- }
-
- // we have providers and permission - this CDP is satisfied
- resolvedSatisfiedCDPs.add(cdp);
- } // end while (more enabled CDPs)
- return resolvedSatisfiedCDPs.isEmpty() ? Collections.EMPTY_LIST : resolvedSatisfiedCDPs;
- }
-
- /**
- * Listen for service change events
- *
- * @param event
- */
- public void serviceChanged(ServiceEvent event) {
-
- ServiceReference reference = event.getServiceReference();
- int eventType = event.getType();
-
- if (DEBUG) {
- System.out.println("ServiceChanged: serviceReference = " + reference);
- System.out.println("ServiceChanged: Event type = " + eventType + " , reference.getBundle() = " + reference.getBundle());
- }
-
- // if ((reference.getProperty(ComponentConstants.COMPONENT_ID) == null)
-
- switch (eventType) {
- case ServiceEvent.MODIFIED :
- case ServiceEvent.REGISTERED :
- case ServiceEvent.UNREGISTERING :
-
- resolve(event);
- break;
- }
-
- }
-
- /**
- * Called asynchronously by the work queue thread to perform work.
- * <p>
- * There are two possible work actions:
- * <ul>
- * <li>BUILD - workObject is a list of Component Configurations to be
- * sent to the Instance process. The Component Configurations have become
- * satisfied. Check that the Component Configurations are still satisfied
- * (system state may have changed while they were waiting on the work
- * queue) and send them to the instance process
- * ({@link InstanceProcess#registerComponentConfigs(List)}).
- * </li>
- * <li>DYNAMICBIND - workObject is a List of References that need to be
- * dynamically bound. Check that the Component Configurations are still
- * satisfied (system state may have changed while they were waiting on
- * the work queue) and send them to the instance process
- * ({@link InstanceProcess#dynamicBind(List)}).
- * </ul>
- * </p>
- * @param workAction {@link Resolver#BUILD} or {@link Resolver#DYNAMICBIND}
- * @param workObject a List of {@link ComponentDescriptionProp}s if workAction
- * is {@link Resolver#BUILD} or a List of {@link Reference}s if workAction
- * is {@link Resolver#DYNAMICBIND}
- * @see org.eclipse.equinox.ds.workqueue.WorkDispatcher#dispatchWork(int,
- * java.lang.Object)
- */
- public void dispatchWork(int workAction, Object workObject) {
- Iterator it;
- switch (workAction) {
- case BUILD :
- // only build if cdps are still satisfied
- List queueCDPs = (List) workObject;
- List cdps = new ArrayList(queueCDPs.size());
- it = queueCDPs.iterator();
- while (it.hasNext()) {
- ComponentDescriptionProp cdp = (ComponentDescriptionProp) it.next();
- if (this.satisfiedCDPs.contains(cdp)) {
- cdps.add(cdp);
- }
- }
- if (!cdps.isEmpty()) {
- instanceProcess.registerComponentConfigs(cdps);
- }
- break;
- case DYNAMICBIND :
- // only dynamicBind if cdps are still satisfied
- List references = (List) workObject;
- it = references.iterator();
- while (it.hasNext()) {
- if (!this.satisfiedCDPs.contains(((Reference) it.next()).getComponentDescriptionProp())) {
- // modifies underlying list
- it.remove();
- }
- }
- if (!references.isEmpty()) {
- instanceProcess.dynamicBind(references);
- }
- break;
- }
- }
-
- /**
- * Calculate which of the currently satisfied CDPs
- * ({@link Resolver#satisfiedCDPs}) need to be dynamically bound to an OSGi
- * service.
- *
- * @param serviceReference the service
- * @return a List of {@link Reference}s that need to be dynamically bound
- * to this service
- */
- private List selectDynamicBind(ServiceReference serviceReference) {
- List bindList = new ArrayList();
- Iterator it = satisfiedCDPs.iterator();
- while (it.hasNext()) {
- ComponentDescriptionProp cdp = (ComponentDescriptionProp) it.next();
- List references = cdp.getReferences();
- Iterator refIt = references.iterator();
- while (refIt.hasNext()) {
- Reference reference = (Reference) refIt.next();
- if (reference.dynamicBindReference(serviceReference)) {
- bindList.add(reference);
- }
- }
- }
- return bindList;
- }
-
- /**
- * An OSGi service is unregistering, calculate which of the satisfied
- * Component Configurations need to dynamically unbind from it.
- * <p>
- * A Component Configuration needs to dynamically unbind from a service
- * if it was bound to the service and the reference it was policy="dynamic".
- * </p>
- * @param serviceReference
- * @return a Map of {@link Reference}:{@link ServiceReference} to unbind
- */
- private Map selectDynamicUnBind(ServiceReference serviceReference) {
-
- Map unbindJobs = new Hashtable();
-
- Iterator it = satisfiedCDPs.iterator();
- while (it.hasNext()) {
- ComponentDescriptionProp cdp = (ComponentDescriptionProp) it.next();
- List references = cdp.getReferences();
- Iterator it_ = references.iterator();
- while (it_.hasNext()) {
- Reference reference = (Reference) it_.next();
- // Is reference dynamic and bound to this service? - must unbind
- if (reference.dynamicUnbindReference(serviceReference)) {
- unbindJobs.put(reference, serviceReference);
- }
- }
- }
- return unbindJobs.isEmpty() ? Collections.EMPTY_MAP : unbindJobs;
- }
-
- /**
- * Doubly-linked node used to traverse the dependency tree in order to
- * find cycles.
- *
- * @version $Revision: 1.1 $
- */
- static private class ReferenceCDP {
- public Reference ref;
- public ComponentDescriptionProp producer;
-
- protected ReferenceCDP(Reference ref, ComponentDescriptionProp producer) {
- this.ref = ref;
- this.producer = producer;
- }
- }
-
- /**
- * Check through the enabled list for cycles. Cycles can only exist if every
- * service is provided by a Service Component (not legacy OSGi). If the cycle
- * has no optional dependencies, log an error and disable a Component
- * Configuration in the cycle. If cycle can be "broken" by an optional
- * dependency, make a note (stored in the
- * {@link ComponentDescriptionProp#delayActivateCDPNames} List).
- *
- * @throws CircularityException if cycle exists with no optional
- * dependencies
- */
- private void resolveCycles() {
-
- try {
- // find the CDPs that resolve using other CDPs and record their
- // dependencies
- Hashtable dependencies = new Hashtable();
- Iterator it = enabledCDPs.iterator();
- while (it.hasNext()) {
- ComponentDescriptionProp enabledCDP = (ComponentDescriptionProp) it.next();
- List dependencyList = new ArrayList();
- Iterator refIt = enabledCDP.getReferences().iterator();
- while (refIt.hasNext()) {
- Reference reference = (Reference) refIt.next();
-
- // see if it resolves to one of the other enabled CDPs
- ComponentDescriptionProp providerCDP = reference.findProviderCDP(enabledCDPs);
- if (providerCDP != null) {
- dependencyList.add(new ReferenceCDP(reference, providerCDP));
- }
- } // end while(more references)
-
- if (!dependencyList.isEmpty()) {
- // CDP resolves using some other CDPs, could be a cycle
- dependencies.put(enabledCDP, dependencyList);
- } else {
- dependencies.put(enabledCDP, Collections.EMPTY_LIST);
- }
- } // end while (more enabled CDPs)
-
- //traverse dependency tree and look for cycles
- Set visited = new HashSet();
- it = dependencies.keySet().iterator();
- while (it.hasNext()) {
- ComponentDescriptionProp cdp = (ComponentDescriptionProp) it.next();
- if (!visited.contains(cdp)) {
- List currentStack = new ArrayList();
- traverseDependencies(cdp, visited, dependencies, currentStack);
- }
- }
- } catch (CircularityException e) {
- // log the error
- Log.log(LogService.LOG_ERROR, "[SCR] Circularity Exception.", e);
-
- // disable offending CDP
- enabledCDPs.remove(e.getCircularDependency());
-
- // try again
- resolveCycles();
- }
- }
-
- /**
- * Recursively do a depth-first traversal of a dependency tree, looking for
- * cycles.
- * <p>
- * If a cycle is found, calls
- * {@link Resolver#handleDependencyCycle(ReferenceCDP, List)}.
- * </p>
- *
- * @param cdp current node in dependency tree
- * @param visited Set of {@link ComponentDescriptionProp} that are visited
- * nodes
- * @param dependencies Dependency tree - a Hashtable of
- * ({@link ComponentDescriptionProp}):(List of {@link ReferenceCDP}s)
- * @param currentStack List of {@link ReferenceCDP}s - the history of our
- * traversal so far (the path back to the root of the tree)
- * @throws CircularityException if an cycle with no optional dependencies is
- * found.
- */
- private void traverseDependencies(ComponentDescriptionProp cdp, Set visited, Hashtable dependencies, List currentStack) throws CircularityException {
-
- // the component has already been visited and it's dependencies checked
- // for cycles
- if (visited.contains(cdp)) {
- return;
- }
-
- List refCDPs = (List) dependencies.get(cdp);
- Iterator it = refCDPs.iterator();
- // first, add the CDP's dependencies
- while (it.hasNext()) {
-
- ReferenceCDP refCDP = (ReferenceCDP) it.next();
-
- if (currentStack.contains(refCDP)) {
- // may throw circularity exception
- handleDependencyCycle(refCDP, currentStack);
- return;
- }
- currentStack.add(refCDP);
-
- traverseDependencies(refCDP.producer, visited, dependencies, currentStack);
-
- currentStack.remove(refCDP);
- }
- // finally write the cdp
- visited.add(cdp);
-
- }
-
- /**
- * A cycle was detected. CDP is referenced by the last element in
- * currentStack. Throws CircularityException if the cycle does not contain
- * an optional dependency, else choses a point at which to
- * "break" the cycle (the break point must be immediately after an
- * optional dependency) and adds a "cycle note".
- *
- * @see ComponentDescriptionProp#delayActivateCDPNames
- */
- private void handleDependencyCycle(ReferenceCDP refCDP, List currentStack) throws CircularityException {
- ListIterator cycleIterator = currentStack.listIterator(currentStack.indexOf(refCDP));
-
- // find an optional dependency
- ReferenceCDP optionalRefCDP = null;
- while (cycleIterator.hasNext()) {
- ReferenceCDP cycleRefCDP = (ReferenceCDP) cycleIterator.next();
- if (!cycleRefCDP.ref.getReferenceDescription().isRequired()) {
- optionalRefCDP = cycleRefCDP;
- break;
- }
- }
-
- if (optionalRefCDP == null) {
- // no optional dependency
- throw new CircularityException(refCDP.ref.getComponentDescriptionProp());
- }
-
- // add note not to initiate activation of next dependency
- optionalRefCDP.ref.getComponentDescriptionProp().setDelayActivateCDPName(optionalRefCDP.producer.getComponentDescription().getName());
- }
-
- /**
- * Method to return the next available component id.
- *
- * @return next component id.
- */
- private long getNextComponentId() {
- synchronized (this) {
- return componentid++;
- }
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/service/ComponentContextImpl.java b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/service/ComponentContextImpl.java
deleted file mode 100644
index 9299104ba..000000000
--- a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/service/ComponentContextImpl.java
+++ /dev/null
@@ -1,365 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.ds.service;
-
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.*;
-import org.eclipse.equinox.ds.Activator;
-import org.eclipse.equinox.ds.model.ComponentDescription;
-import org.eclipse.equinox.ds.model.ComponentDescriptionProp;
-import org.eclipse.equinox.ds.resolver.Reference;
-import org.osgi.framework.*;
-import org.osgi.service.component.*;
-
-/**
- * A ComponentContext object is used by a Service Component to interact with it's
- * execution context including locating services by reference name.
- *
- * <p>
- * A component's implementation class may optionally implement an activate
- * method:
- *
- * <pre>
- * protected void activate(ComponentContext context);
- * </pre>
- *
- * If a component implements this method, this method will be called when the
- * component is activated to provide the component's ComponentContext object.
- *
- * <p>
- * A component's implementation class may optionally implement a deactivate
- * method:
- *
- * <pre>
- * protected void deactivate(ComponentContext context);
- * </pre>
- *
- * If a component implements this method, this method will be called when the
- * component is deactivated.
- *
- * <p>
- * The activate and deactivate methods will be called using reflection and must
- * be at least protected accessible. These methods do not need to be public
- * methods so that they do not appear as public methods on the component's
- * provided service object. The methods will be located by looking through the
- * component's implementation class hierarchy for the first declaration of the
- * method. If the method is declared protected or public, the method will
- * called.
- *
- * @version $Revision: 1.2 $
- */
-public class ComponentContextImpl implements ComponentContext {
-
- /** The BundleContext of the Bundle that contains the Service Component
- * this ComponentContextImpl is associated with */
- BundleContext bundleContext;
-
- /**
- * Component Configuraiton instance
- */
- private ComponentInstanceImpl componentInstance;
-
- /**
- * Component Configuration
- */
- private ComponentDescriptionProp cdp;
-
- Activator main;
-
- /**
- * If the {@link ComponentContextImpl#componentInstance} was created for a
- * {@link org.osgi.framework.ServiceFactory#getService(org.osgi.framework.Bundle, org.osgi.framework.ServiceRegistration) ServiceFactory.getService(...)}
- * call, this is the bundle that is "using" this Component instance.
- * Else null.
- */
- private Bundle usingBundle;
-
- /**
- * Construct a ComponentContext object
- *
- * @param main
- * @param usingBundle See {@link ComponentContextImpl#usingBundle}
- * @param componentInstance
- */
- public ComponentContextImpl(Activator main, Bundle usingBundle, ComponentInstanceImpl componentInstance) {
- this.cdp = componentInstance.getComponentDescriptionProp();
- this.componentInstance = componentInstance;
- this.bundleContext = cdp.getComponentDescription().getBundleContext();
- this.usingBundle = usingBundle;
- this.main = main;
- }
-
- /**
- * Returns the component properties for this ComponentContext.
- *
- * @return The properties for this ComponentContext. The properties are read
- * only and cannot be modified.
- */
- public Dictionary getProperties() {
- return (Dictionary) cdp.getProperties().clone();
- }
-
- /**
- * Returns the service object for the specified service reference name.
- *
- * @param name The name of a service reference as specified in a
- * <code>reference</code> element in this component's description.
- * @return A service object for the referenced service or <code>null</code>
- * if the reference cardinality is <code>0..1</code> or
- * <code>0..n</code> and no matching service is available.
- * @throws ComponentException If the Service Component Runtime catches an
- * exception while getting the target service.
- */
- public Object locateService(String name) throws ComponentException {
-
- try {
- // find the Reference Description with the specified name
- Iterator references = cdp.getReferences().iterator();
- Reference thisReference = null;
- while (references.hasNext()) {
- Reference reference = (Reference) references.next();
- if (reference.getReferenceDescription().getName().equals(name)) {
- thisReference = reference;
- break;
- }
- }
-
- if (thisReference != null) {
- ServiceReference serviceReference = null;
- // check to see if this reference is already bound
- if (!thisReference.getServiceReferences().isEmpty()) {
- // if possible, return reference we are already bound to
- serviceReference = (ServiceReference) thisReference.getServiceReferences().iterator().next();
- } else {
- ServiceReference[] serviceReferences = bundleContext.getServiceReferences(thisReference.getReferenceDescription().getInterfacename(), thisReference.getTarget());
- if (serviceReferences != null && serviceReferences.length > 0) {
-
- // sort by service ranking and service id
- Arrays.sort(serviceReferences);
-
- serviceReference = serviceReferences[0];
- }
-
- }
- if (serviceReference != null) {
- Object serviceObject = main.resolver.instanceProcess.buildDispose.getService(thisReference, serviceReference);
- thisReference.addServiceReference(serviceReference, serviceObject);
- return serviceObject;
- }
- }
-
- return null;
-
- } catch (Exception e) {
- throw new ComponentException(e);
- }
-
- }
-
- /**
- * Returns the service object for the specified reference name and
- * <code>ServiceReference</code>.
- *
- * @param name The name of a reference as specified in a
- * <code>reference</code> element in this component's description.
- * @param serviceReference The <code>ServiceReference</code> to a specific bound
- * service. This must be a <code>ServiceReference</code> provided
- * to the component via the bind or unbind method for the specified
- * reference name.
- * @return A service object for the referenced service or <code>null</code>
- * if the specified <code>ServiceReference</code> is not a bound
- * service for the specified reference name.
- * @throws ComponentException If the Service Component Runtime catches an
- * exception while getting the service.
- */
- public Object locateService(String name, ServiceReference serviceReference) throws ComponentException {
- try {
- // find the Reference Description with the specified name
- Iterator references = cdp.getReferences().iterator();
- Reference thisReference = null;
- while (references.hasNext()) {
- Reference reference = (Reference) references.next();
- if (reference.getReferenceDescription().getName().equals(name)) {
- thisReference = reference;
- break;
- }
- }
-
- if (thisReference != null) {
- Object serviceObject = main.resolver.instanceProcess.buildDispose.getService(thisReference, serviceReference);
- thisReference.addServiceReference(serviceReference, serviceObject);
- return serviceObject;
- }
-
- return null;
-
- } catch (ComponentException e) {
- throw e;
- }
- }
-
- /**
- * Returns the service objects for the specified service reference name.
- *
- * @param name The name of a service reference as specified in a
- * <code>reference</code> element in this component's description.
- * @return An array of service objects for the referenced service or
- * <code>null</code> if the reference cardinality is
- * <code>0..1</code> or <code>0..n</code> and no matching
- * service is available.
- * @throws ComponentException If the Service Component Runtime catches an
- * exception while activating a target service.
- */
- public Object[] locateServices(String name) throws ComponentException {
- try {
- // find the Reference Description with the specified name
- Iterator references = cdp.getReferences().iterator();
- Reference thisReference = null;
- while (references.hasNext()) {
- Reference reference = (Reference) references.next();
- if (reference.getReferenceDescription().getName().equals(name)) {
- thisReference = reference;
- break;
- }
- }
-
- if (thisReference != null) {
- ServiceReference[] serviceReferences = bundleContext.getServiceReferences(thisReference.getReferenceDescription().getInterfacename(), thisReference.getTarget());
-
- if (serviceReferences != null) {
- // sort by service ranking and service id
- Arrays.sort(serviceReferences);
-
- List serviceObjects = new ArrayList(serviceReferences.length);
- for (int counter = 0; counter < serviceReferences.length; counter++) {
- Object serviceObject = main.resolver.instanceProcess.buildDispose.getService(thisReference, serviceReferences[counter]);
- if (serviceObject != null) {
- serviceObjects.add(serviceObject);
- thisReference.addServiceReference(serviceReferences[counter], serviceObject);
- }
- } // end for serviceReferences
- if (!serviceObjects.isEmpty()) {
- return serviceObjects.toArray();
- }
- }
- }
- return null;
-
- } catch (InvalidSyntaxException e) {
- throw new ComponentException(e.getMessage());
- }
- }
-
- /**
- * Returns the BundleContext of the bundle which contains this component.
- *
- * @return The BundleContext of the bundle containing this component.
- */
- public BundleContext getBundleContext() {
- return bundleContext;
- }
-
- /**
- * If the component is registered as a service using the
- * <code>servicefactory=&quot;true&quot;</code> attribute, then this
- * method returns the bundle using the service provided by this component.
- * <p>
- * This method will return <code>null</code> if the component is:
- * <ul>
- * <li>Not a service, then no bundle can be using it as a service.
- * <li>Is a service but did not specify the
- * <code>servicefactory=&quot;true&quot;</code> attribute, then all
- * bundles will use this component.
- * <li>Was created because it specified the immediate=true attribute.
- * </ul>
- *
- * @return The bundle using this component as a service or <code>null</code>.
- */
-
- public Bundle getUsingBundle() {
- ComponentDescription cd = cdp.getComponentDescription();
- if ((cd.getService() == null) || (!cd.getService().isServicefactory())) {
- return null;
- }
- return usingBundle;
- }
-
- /**
- * Returns this Component Configuration instance.
- *
- * @return The ComponentInstance object for this ComponentDescriptionProp.
- */
- public ComponentInstance getComponentInstance() {
- return componentInstance;
- }
-
- /**
- * Enables the specified component name. The specified component name must
- * be in the same bundle as this component.
- *
- * @param name The name of a component or <code>null</code> to indicate
- * all components in the bundle.
- */
- public void enableComponent(String name) {
- final String componentName = name;
-
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- main.enableComponent(componentName, bundleContext.getBundle());
- return null;
- }
- });
-
- }
-
- /**
- * Disables the specified component name. The specified component name must
- * be in the same bundle as this component.
- *
- * @param name The name of a component.
- */
- public void disableComponent(String name) {
-
- final String componentName = name;
-
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- main.disableComponent(componentName, bundleContext.getBundle());
- return null; // nothing to return
- }
- });
- }
-
- /**
- * If this Service Component specified the
- * <code>service</code> element, then this method returns the service
- * reference of the service provided by this Component Configuration.
- * <p>
- * This method will return <code>null</code> if this Component Configuration
- * is not registered as a service.
- *
- * @return The <code>ServiceReference</code> object for this component or
- * <code>null</code> if this component is not registered as a
- * service.
- */
- public ServiceReference getServiceReference() {
- ServiceReference serviceReference = null;
- if (cdp.getComponentDescription().getService() != null) {
- ServiceRegistration serviceRegistration = cdp.getServiceRegistration();
- if (serviceRegistration != null) {
- serviceReference = serviceRegistration.getReference();
- }
- }
- return serviceReference;
- }
-
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/service/ComponentFactoryImpl.java b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/service/ComponentFactoryImpl.java
deleted file mode 100644
index 198ee7ec3..000000000
--- a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/service/ComponentFactoryImpl.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.ds.service;
-
-import java.util.*;
-import org.eclipse.equinox.ds.Activator;
-import org.eclipse.equinox.ds.model.ComponentDescriptionProp;
-import org.osgi.service.component.*;
-
-/**
- * When a Service Component is declared with the <code>factory</code> attribute
- * on its <code>component</code> element, the Service Component Runtime will
- * register a ComponentFactory service to allow new component configurations
- * to be created and activated.
- *
- * @version $Revision: 1.2 $
- */
-public class ComponentFactoryImpl implements ComponentFactory {
-
- private ComponentDescriptionProp cdp;
- private Activator main;
-
- /**
- * ComponentFactoryImpl
- *
- * @param context the SC bundle context
- * @param componentDescriptionProp the ComponentDescription Object with
- * Properties
- * @param buildDispose
- */
- public ComponentFactoryImpl(ComponentDescriptionProp cdp, Activator main) {
- this.cdp = cdp;
- this.main = main;
- }
-
- /**
- * Create and activate a new component configuration. Additional properties
- * may be provided for the component configuration.
- *
- * @param newProperties Additional properties for the component configuration.
- * @return A ComponentInstance object encapsulating an instance of the
- * component configuration. The returned Component Configuration
- * instance has been activated and, if the Service Component
- * specifies a <code>service</code> element, the Component
- * Configuration has been registered as a service.
- * @throws ComponentException If the Service Component Runtime is unable to
- * activate the Component Configuration instance.
- */
- public ComponentInstance newInstance(Dictionary newProperties) {
-
- // merge properties
- Hashtable properties = (Hashtable) cdp.getProperties().clone();
- Enumeration propsEnum = newProperties.keys();
- while (propsEnum.hasMoreElements()) {
- Object key = propsEnum.nextElement();
- properties.put(key, newProperties.get(key));
- }
-
- // create a new cdp (adds to resolver enabledCDPs list)
- ComponentDescriptionProp newCDP = main.resolver.mapFactoryInstance(cdp.getComponentDescription(), properties);
-
- // try to resolve new cdp - adds to resolver's satisfied list
- if (!main.resolver.justResolve(newCDP)) {
- main.resolver.enabledCDPs.remove(newCDP); // was added by
- // mapFactoryInstance
- throw new ComponentException("Could not resolve instance of " + cdp + " with properties " + properties);
- }
-
- // if new cdp resolves, send it to instance process (will register
- // service
- // if it has one)
- main.resolver.instanceProcess.registerComponentConfigs(Collections.singletonList(newCDP));
-
- // get instance of new cdp to return
-
- if (newCDP.getComponentDescription().isImmediate()) {
- // if cdp is immediate then instanceProcess created one
- return (ComponentInstance) newCDP.getInstances().get(0);
- }
-
- return main.resolver.instanceProcess.buildDispose.buildComponentConfigInstance(null, newCDP);
- }
-}
diff --git a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/service/ComponentInstanceImpl.java b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/service/ComponentInstanceImpl.java
deleted file mode 100644
index 17213aa4e..000000000
--- a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/service/ComponentInstanceImpl.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.ds.service;
-
-import java.util.Collections;
-import org.eclipse.equinox.ds.Activator;
-import org.eclipse.equinox.ds.model.ComponentDescriptionProp;
-import org.osgi.service.component.ComponentContext;
-import org.osgi.service.component.ComponentInstance;
-
-/**
- * A ComponentInstance encapsulates an instance of a component.
- * ComponentInstances are created whenever an instance of a component is
- * created.
- *
- * @version $Revision: 1.2 $
- */
-public class ComponentInstanceImpl implements ComponentInstance {
-
- private Object instance;
- private Activator main;
- private ComponentDescriptionProp cdp;
- private ComponentContext componentContext;
-
- /**
- * ComponentInstanceImpl
- *
- * @param Object instance
- *
- */
- public ComponentInstanceImpl(Activator main, ComponentDescriptionProp cdp, Object instance) {
- this.main = main;
- this.instance = instance;
- this.cdp = cdp;
-
- }
-
- public void setComponentContext(ComponentContext context) {
- this.componentContext = context;
- }
-
- public ComponentContext getComponentContext() {
- return componentContext;
- }
-
- /**
- * Dispose of this component instance. The instance will be deactivated. If
- * the instance has already been deactivated, this method does nothing.
- */
- public void dispose() {
- // deactivate
- if (!cdp.isComponentFactory() && cdp.getComponentDescription().getFactory() != null) {
- // this is a factory instance, so dispose of CDP
- cdp.getComponentDescription().removeComponentDescriptionProp(cdp);
- main.resolver.disposeComponentConfigs(Collections.singletonList(cdp));
- cdp = null;
- } else {
- main.resolver.instanceProcess.buildDispose.disposeComponentInstance(this);
- cdp.removeInstance(this);
- }
- instance = null;
- }
-
- /**
- * Returns the component instance. The instance has been activated.
- *
- * @return The component instance or <code>null</code> if the instance has
- * been deactivated.
- */
- public Object getInstance() {
- return instance;
- }
-
- public ComponentDescriptionProp getComponentDescriptionProp() {
- return cdp;
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/tracker/BundleTracker.java b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/tracker/BundleTracker.java
deleted file mode 100644
index dd85ce795..000000000
--- a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/tracker/BundleTracker.java
+++ /dev/null
@@ -1,376 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.ds.tracker;
-
-import java.util.*;
-import org.osgi.framework.*;
-
-/**
- *
- * TODO Add Javadoc comment for this type.
- *
- * @version $Revision: 1.2 $
- */
-public class BundleTracker implements BundleTrackerCustomizer {
- /* set this to true to compile in debug messages */
- private static final boolean DEBUG = false;
-
- /**
- * Bundle context this <tt>BundleTracker</tt> object is tracking against.
- */
- private final BundleContext context;
-
- /**
- * <tt>BundleTrackerCustomizer</tt> object for this tracker.
- */
- final BundleTrackerCustomizer customizer;
-
- /**
- * Tracked bundles: <tt>Bundle</tt> object -> customized Object and
- * <tt>BundleListener</tt> object
- */
- private Tracked tracked;
-
- /**
- * Modification count. This field is initialized to zero by open, set to -1
- * by close and incremented by modified. This field is volatile since it is
- * accessed by multiple threads.
- */
- private volatile int trackingCount = -1;
-
- final int mask;
-
- public BundleTracker(BundleContext context, int stateMask, BundleTrackerCustomizer customizer) {
- this.context = context;
- this.mask = stateMask;
- this.customizer = (customizer == null) ? this : customizer;
- }
-
- public synchronized void open() {
- if (tracked != null) {
- return;
- }
- if (DEBUG) {
- System.out.println("BundleTracker.open"); //$NON-NLS-1$
- }
- tracked = new Tracked();
- trackingCount = 0;
- Bundle[] bundles;
- synchronized (tracked) {
- context.addBundleListener(tracked);
- bundles = context.getBundles();
- }
- /* Call tracked outside of synchronized region */
- if (bundles != null) {
- int length = bundles.length;
- for (int i = 0; i < length; i++) {
- Bundle bundle = bundles[i];
- int state = bundle.getState();
- if ((state & mask) != 0) {
- tracked.track(bundle);
- }
- }
- }
- }
-
- public synchronized void close() {
- if (tracked == null) {
- return;
- }
- if (DEBUG) {
- System.out.println("BundleTracker.close"); //$NON-NLS-1$
- }
- tracked.close();
- Bundle[] bundles = getBundles();
- Tracked outgoing = tracked;
- tracked = null;
- try {
- context.removeBundleListener(outgoing);
- } catch (IllegalStateException e) {
- /* In case the context was stopped. */
- }
- if (bundles != null) {
- for (int i = 0; i < bundles.length; i++) {
- outgoing.untrack(bundles[i]);
- }
- }
- trackingCount = -1;
- }
-
- /**
- * @param bundle
- * @return bundle
- * @see org.eclipse.equinox.ds.tracker.BundleTrackerCustomizer#addingBundle(org.osgi.framework.Bundle)
- */
- public Object addingBundle(Bundle bundle) {
- return bundle;
- }
-
- /**
- * @param bundle
- * @param object
- * @see org.eclipse.equinox.ds.tracker.BundleTrackerCustomizer#modifiedBundle(org.osgi.framework.Bundle,
- * java.lang.Object)
- */
- public void modifiedBundle(Bundle bundle, Object object) {
- }
-
- /**
- * @param bundle
- * @param object
- * @see org.eclipse.equinox.ds.tracker.BundleTrackerCustomizer#removedBundle(org.osgi.framework.Bundle,
- * java.lang.Object)
- */
- public void removedBundle(Bundle bundle, Object object) {
- }
-
- /**
- * Called by the Tracked object whenever the set of tracked bundles is
- * modified. Increments the tracking count.
- */
- void modified() {
- trackingCount++; /* increment modification count */
- if (DEBUG) {
- System.out.println("BundleTracker.modified"); //$NON-NLS-1$
- }
- }
-
- /**
- * Return an array of <tt>Bundle</tt> objects for all bundles being
- * tracked by this <tt>BundleTracker</tt> object.
- *
- * @return Array of <tt>Bundle</tt> objects or <tt>null</tt> if no
- * bundles are being tracked.
- */
- private Bundle[] getBundles() {
- Tracked s_tracked = this.tracked; /*
- * use local var since we are not
- * synchronized
- */
- if (s_tracked == null) /* if BundleTracker is not open */
- {
- return null;
- }
- synchronized (s_tracked) {
- int length = s_tracked.size();
- if (length == 0) {
- return null;
- }
- Bundle[] bundles = new Bundle[length];
- Enumeration keys = s_tracked.keys();
- for (int i = 0; i < length; i++) {
- bundles[i] = (Bundle) keys.nextElement();
- }
- return bundles;
- }
- }
-
- /**
- * Inner class to track bundles. If a <tt>BundleTracker</tt> object is
- * reused (closed then reopened), then a new Tracked object is used. This
- * class is a hashtable mapping <tt>Bundle</tt> object -> customized
- * Object. This class is the <tt>BundleListener</tt> object for the
- * tracker. This class is used to synchronize access to the tracked bundles.
- * This is not a public class. It is only for use by the implementation of
- * the <tt>BundleTracker</tt> class.
- *
- */
- class Tracked extends Hashtable implements SynchronousBundleListener {
- /**
- * Eclipse-generated <code>serialVersionUID</code>
- */
- private static final long serialVersionUID = -4232285292477873203L;
-
- /**
- * List of Bundles in the process of being added.
- */
- private List adding;
- /**
- * true if the tracked object is closed. This field is volatile because
- * it is set by one thread and read by another.
- */
- private volatile boolean closed;
-
- /**
- * Tracked constructor.
- */
- protected Tracked() {
- super();
- closed = false;
- adding = new ArrayList(6);
- }
-
- /**
- * Called by the owning <tt>BundleTracker</tt> object when it is
- * closed.
- */
- protected void close() {
- closed = true;
- }
-
- /**
- * <tt>SynchronousBundleListener</tt> method for the
- * <tt>BundleTracker</tt> class. This method must NOT be synchronized
- * to avoid deadlock potential.
- *
- * @param event <tt>BundleEvent</tt> object from the framework.
- */
- public void bundleChanged(BundleEvent event) {
- /*
- * Check if we had a delayed call (which could happen when we
- * close).
- */
- if (closed) {
- return;
- }
- Bundle bundle = event.getBundle();
- int state = bundle.getState();
- if ((state & mask) != 0) {
- track(bundle);
- /*
- * If the customizer throws an unchecked exception, it is safe
- * to let it propagate
- */
- } else {
- untrack(bundle);
- /*
- * If the customizer throws an unchecked exception, it is safe
- * to let it propagate
- */
- }
- }
-
- /**
- * Begin to track the referenced bundle.
- *
- * @param bundle Bundle to be tracked.
- */
- protected void track(Bundle bundle) {
- Object object;
- synchronized (this) {
- object = this.get(bundle);
- }
- if (object != null) /* we are already tracking the bundle */
- {
- if (DEBUG) {
- System.out.println("BundleTracker.Tracked.track[modified]: " + bundle); //$NON-NLS-1$
- }
- /* Call customizer outside of synchronized region */
- customizer.modifiedBundle(bundle, object);
- /*
- * If the customizer throws an unchecked exception, it is safe
- * to let it propagate
- */
-
- return;
- }
- synchronized (this) {
- if (adding.contains(bundle)) /*
- * if this bundle is already in
- * the process of being added.
- */
- {
- if (DEBUG) {
- System.out.println("BundleTracker.Tracked.track[already adding]: " + bundle); //$NON-NLS-1$
- }
- return;
- }
- adding.add(bundle); /* mark this bundle is being added */
- }
- if (DEBUG) {
- System.out.println("BundleTracker.Tracked.track[adding]: " + bundle); //$NON-NLS-1$
- }
- boolean becameUntracked = false;
- /* Call customizer outside of synchronized region */
- try {
- object = customizer.addingBundle(bundle);
- /*
- * If the customizer throws an unchecked exception, it will
- * propagate after the finally
- */
- } finally {
- synchronized (this) {
- if (adding.remove(bundle)) /*
- * if the bundle was not
- * untracked during the
- * customizer callback
- */
- {
- if (object != null) {
- this.put(bundle, object);
- modified(); /* increment modification count */
- notifyAll();
- }
- } else {
- becameUntracked = true;
- }
- }
- }
- /*
- * The bundle became untracked during the customizer callback.
- */
- if (becameUntracked) {
- if (DEBUG) {
- System.out.println("BundleTracker.Tracked.track[removed]: " + bundle); //$NON-NLS-1$
- }
- /* Call customizer outside of synchronized region */
- customizer.removedBundle(bundle, object);
- /*
- * If the customizer throws an unchecked exception, it is safe
- * to let it propagate
- */
- }
- }
-
- /**
- * Discontinue tracking the bundle.
- *
- * @param bundle Bundle to be untracked.
- */
- protected void untrack(Bundle bundle) {
- Object object;
- synchronized (this) {
- if (adding.remove(bundle)) /*
- * if the bundle is in the process
- * of being added
- */
- {
- if (DEBUG) {
- System.out.println("BundleTracker.Tracked.untrack[being added]: " + bundle); //$NON-NLS-1$
- }
- return; /*
- * in case the bundle is untracked while in the
- * process of adding
- */
- }
- object = this.remove(bundle); /*
- * must remove from tracker
- * before calling customizer
- * callback
- */
- if (object == null) /* are we actually tracking the bundle */
- {
- return;
- }
- modified(); /* increment modification count */
- }
- if (DEBUG) {
- System.out.println("BundleTracker.Tracked.untrack[removed]: " + bundle); //$NON-NLS-1$
- }
- /* Call customizer outside of synchronized region */
- customizer.removedBundle(bundle, object);
- /*
- * If the customizer throws an unchecked exception, it is safe to
- * let it propagate
- */
- }
- }
-}
diff --git a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/tracker/BundleTrackerCustomizer.java b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/tracker/BundleTrackerCustomizer.java
deleted file mode 100644
index b78f25e57..000000000
--- a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/tracker/BundleTrackerCustomizer.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.ds.tracker;
-
-import org.osgi.framework.Bundle;
-
-/**
- * The <tt>BundleTrackerCustomizer</tt> interface allows a
- * <tt>BundleTracker</tt> object to customize the bundle objects that are
- * tracked. The <tt>BundleTrackerCustomizer</tt> object is called when a
- * bundle is being added to the <tt>BundleTracker</tt> object. The
- * <tt>BundleTrackerCustomizer</tt> can then return an object for the tracked
- * bundle. The <tt>BundleTrackerCustomizer</tt> object is also called when a
- * tracked bundle has been removed from the <tt>BundleTracker</tt> object.
- *
- * <p>
- * The methods in this interface may be called as the result of a
- * <tt>BundleEvent</tt> being received by a <tt>BundleTracker</tt> object.
- * Since <tt>BundleEvent</tt> s are synchronously received by the
- * <tt>BundleTracker</tt>, it is highly recommended that implementations of
- * these methods do not alter bundle states while being synchronized on any
- * object.
- *
- * @version $Revision: 1.2 $
- */
-public interface BundleTrackerCustomizer {
- /**
- * A bundle is being added to the <tt>BundleTracker</tt> object.
- *
- * <p>
- * This method is called before a bundle which matched the search parameters
- * of the <tt>BundleTracker</tt> object is added to it. This method should
- * return the object to be tracked for this <tt>Bundle</tt> object. The
- * returned object is stored in the <tt>BundleTracker</tt> object and is
- * available from the <tt>getObject</tt> and <tt>getObjects</tt>
- * methods.
- *
- * @param bundle Bundle being added to the <tt>BundleTracker</tt> object.
- * @return The object to be tracked for the <tt>Bundle</tt> object or
- * <tt>null</tt> if the <tt>Bundle</tt> object should not be
- * tracked.
- */
- public abstract Object addingBundle(Bundle bundle);
-
- /**
- * A bundle tracked by the <tt>BundleTracker</tt> object has been
- * modified.
- *
- * <p>
- * This method is called when a bundle being tracked by the
- * <tt>BundleTracker</tt> object has had its state modified.
- *
- * @param bundle Bundle whose state has been modified.
- * @param object The object for the modified bundle.
- */
- public abstract void modifiedBundle(Bundle bundle, Object object);
-
- /**
- * A bundle tracked by the <tt>BundleTracker</tt> object has been removed.
- *
- * <p>
- * This method is called after a bundle is no longer being tracked by the
- * <tt>BundleTracker</tt> object.
- *
- * @param bundle Bundle that has been removed.
- * @param object The object for the removed bundle.
- */
- public abstract void removedBundle(Bundle bundle, Object object);
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/workqueue/WorkDispatcher.java b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/workqueue/WorkDispatcher.java
deleted file mode 100644
index b22b5a843..000000000
--- a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/workqueue/WorkDispatcher.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.equinox.ds.workqueue;
-
-/**
- * The WorkDispatcher interface contains the method that is called by the
- * WorkQueue to dispatch work.
- */
-
-public interface WorkDispatcher {
- /**
- * This method is called once for each work item. This method can then
- * complete processing work on the work queue thread.
- *
- * <p>
- * The WorkQueue will ignore any Throwable thrown by this method in order to
- * continue dispatch of the next work item.
- *
- * @param workAction Work action value passed from the work enqueuer.
- * @param workObject Work object passed from the work enqueuer.
- */
- public void dispatchWork(int workAction, Object workObject);
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/workqueue/WorkQueue.java b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/workqueue/WorkQueue.java
deleted file mode 100644
index 3cfbc3738..000000000
--- a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/ds/workqueue/WorkQueue.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-
-package org.eclipse.equinox.ds.workqueue;
-
-import org.eclipse.equinox.ds.Log;
-
-/**
- * This class is used for asynchronously dispatching work items.
- */
-
-public class WorkQueue extends Thread {
- private static final boolean DEBUG = false;
-
- /**
- * Queued is a nested class. This class represents the items which are
- * placed on the asynch dispatch queue. This class is private.
- */
- static private class Queued {
- /** dispatcher of this item */
- private final WorkDispatcher dispatcher;
- /** action for this item */
- private final int action;
- /** object for this item */
- private final Object object;
- /** next item in work queue */
- Queued next;
-
- /**
- * Constructor for work queue item
- *
- * @param d Dispatcher for this item
- * @param a Action for this item
- * @param o Object for this item
- */
- Queued(WorkDispatcher d, int a, Object o) {
- dispatcher = d;
- action = a;
- object = o;
- next = null;
- }
-
- void dispatch() {
- try {
- /*
- * Call the WorkDispatcher to dispatch the work.
- */
- dispatcher.dispatchWork(action, object);
- } catch (Throwable t) {
- t.printStackTrace();
- Log.log(1, "[SCR] Error dispatching work ", t);
- }
- }
- }
-
- /** item at the head of the work queue */
- private Queued head;
- /** item at the tail of the work queue */
- private Queued tail;
- /** if true the thread should complete it's work and terminate */
- private volatile boolean stopping;
-
- /**
- * Constructor for the work queue thread.
- *
- * @param threadName Name of the WorkQueue
- */
- public WorkQueue(String threadName) {
- super(threadName);
- stopping = false;
- head = null;
- tail = null;
- }
-
- /**
- * Finish all work and stop thread.
- */
- public void closeAndJoin() {
- stopping = true;
- interrupt();
- try {
- join(); // wait for work to finish
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * This method pulls items from the work queue and dispatches them.
- */
- public void run() {
- try {
- while (true) {
- Queued item = dequeueWork();
- if (item == null) {
- return;
- }
-
- item.dispatch();
- }
- } catch (RuntimeException e) {
- if (DEBUG) {
- e.printStackTrace(System.err);
- }
- throw e;
- } catch (Error e) {
- if (DEBUG) {
- e.printStackTrace(System.err);
- }
- throw e;
- }
- }
-
- /**
- * This methods takes the input parameters and creates a Queued object and
- * queues it. The thread is notified.
- *
- * @param d Dispatcher for this item
- * @param a Action for this item
- * @param o Object for this item
- */
- public synchronized void enqueueWork(WorkDispatcher d, int a, Object o) {
- if (!isAlive()) { /* If the thread is not alive, throw an exception */
- throw new IllegalStateException("work thread is not alive");
- }
-
- Queued item = new Queued(d, a, o);
-
- if (head == null) /* if the queue was empty */
- {
- head = item;
- tail = item;
- } else /* else add to end of queue */
- {
- tail.next = item;
- tail = item;
- }
-
- notify();
- }
-
- /**
- * This method is called by the thread to remove items from the queue so
- * that they can be dispatched to their listeners. If the queue is empty,
- * the thread waits.
- *
- * @return The Queued removed from the top of the queue or null if the
- * thread has been requested to stop.
- */
- private synchronized Queued dequeueWork() {
- while ((!stopping) && (head == null)) {
- try {
- wait();
- } catch (InterruptedException e) {
- }
- }
-
- if (stopping && head == null) { /* if we are stopping */
- return null;
- }
-
- Queued item = head;
- head = item.next;
- if (head == null) {
- tail = null;
- }
-
- return item;
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.event/.classpath b/bundles/org.eclipse.equinox.event/.classpath
deleted file mode 100644
index 751c8f2e5..000000000
--- a/bundles/org.eclipse.equinox.event/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/bundles/org.eclipse.equinox.event/.cvsignore b/bundles/org.eclipse.equinox.event/.cvsignore
deleted file mode 100644
index ba077a403..000000000
--- a/bundles/org.eclipse.equinox.event/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
diff --git a/bundles/org.eclipse.equinox.event/.project b/bundles/org.eclipse.equinox.event/.project
deleted file mode 100644
index 4401f7b95..000000000
--- a/bundles/org.eclipse.equinox.event/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.equinox.event</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/bundles/org.eclipse.equinox.event/.settings/org.eclipse.jdt.core.prefs b/bundles/org.eclipse.equinox.event/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 95d56a49f..000000000
--- a/bundles/org.eclipse.equinox.event/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,49 +0,0 @@
-#Fri Dec 16 09:20:11 CST 2005
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
-org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
-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=warning
-org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
-org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
-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=warning
-org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
-org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
-org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
-org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
-org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
-org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
-org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore
-org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
-org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
-org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning
-org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
-org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
-org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
-org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.unusedImport=error
-org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
-org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
-org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
-org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
diff --git a/bundles/org.eclipse.equinox.event/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.event/META-INF/MANIFEST.MF
deleted file mode 100644
index 14ef10eb2..000000000
--- a/bundles/org.eclipse.equinox.event/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,19 +0,0 @@
-Bundle-ManifestVersion: 2
-Bundle-Name: %bundleName
-Bundle-Version: 1.0.0.qualifier
-Bundle-SymbolicName: org.eclipse.equinox.event
-Bundle-Activator: org.eclipse.equinox.event.Activator
-Bundle-Copyright: %bundleCopyright
-Import-Package: org.eclipse.osgi.framework.eventmgr,
- org.osgi.framework,
- org.osgi.service.cm,
- org.osgi.service.event,
- org.osgi.service.log,
- org.osgi.service.upnp,
- org.osgi.service.useradmin,
- org.osgi.service.wireadmin,
- org.osgi.util.tracker
-Export-Package: org.eclipse.equinox.event; x-internal:=true,
- org.eclipse.equinox.event; x-internal:=true
-Bundle-Vendor: %bundleVendor
-Export-Service: org.osgi.service.event.EventAdmin
diff --git a/bundles/org.eclipse.equinox.event/about.html b/bundles/org.eclipse.equinox.event/about.html
deleted file mode 100644
index b2f1e6bad..000000000
--- a/bundles/org.eclipse.equinox.event/about.html
+++ /dev/null
@@ -1,22 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
-<!-- saved from url=(0043)http://www.eclipse.org/legal/epl/about.html -->
-<HTML><HEAD><TITLE>About</TITLE>
-<META http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-<META content="MSHTML 6.00.2800.1498" name=GENERATOR></HEAD>
-<BODY lang=EN-US>
-<H2>About This Content</H2>
-<P>February 24, 2005</P>
-<H3>License</H3>
-<P>The Eclipse Foundation makes available all content in this plug-in
-("Content"). Unless otherwise indicated below, the Content is provided to you
-under the terms and conditions of the Eclipse Public License Version 1.0
-("EPL"). A copy of the EPL is available at <A
-href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</A>.
-For purposes of the EPL, "Program" will mean the Content.</P>
-<P>If you did not receive this Content directly from the Eclipse Foundation, the
-Content is being redistributed by another party ("Redistributor") and different
-terms and conditions may apply to your use of any object code in the Content.
-Check the Redistributor's license that was provided with the Content. If no such
-license exists, contact the Redistributor. Unless otherwise indicated below, the
-terms and conditions of the EPL still apply to any source code in the
-Content.</P></BODY></HTML>
diff --git a/bundles/org.eclipse.equinox.event/build.properties b/bundles/org.eclipse.equinox.event/build.properties
deleted file mode 100644
index 873261924..000000000
--- a/bundles/org.eclipse.equinox.event/build.properties
+++ /dev/null
@@ -1,17 +0,0 @@
-###############################################################################
-# Copyright (c) 2005 IBM Corporation.
-# 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:
-# IBM Corporation - initial API and implementation
-###############################################################################
-bin.includes = META-INF/,\
- plugin*.properties,\
- about.html,\
- .
-src.includes = about.html
-source.. = src/
-output.. = bin/
diff --git a/bundles/org.eclipse.equinox.event/plugin.properties b/bundles/org.eclipse.equinox.event/plugin.properties
deleted file mode 100644
index 2c33066a5..000000000
--- a/bundles/org.eclipse.equinox.event/plugin.properties
+++ /dev/null
@@ -1,13 +0,0 @@
-###############################################################################
-# Copyright (c) 2005 IBM Corporation.
-# 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:
-# IBM Corporation - initial API and implementation
-###############################################################################
-bundleVendor = Eclipse.org
-bundleName = Event Admin
-bundleCopyright = Copyright (c) IBM Corp. 2005
diff --git a/bundles/org.eclipse.equinox.event/src/org/eclipse/equinox/event/Activator.java b/bundles/org.eclipse.equinox.event/src/org/eclipse/equinox/event/Activator.java
deleted file mode 100644
index cb1e6ee20..000000000
--- a/bundles/org.eclipse.equinox.event/src/org/eclipse/equinox/event/Activator.java
+++ /dev/null
@@ -1,30 +0,0 @@
-
-package org.eclipse.equinox.event;
-
-import org.eclipsei.equinox.event.mapper.EventRedeliverer;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
-
-public class Activator implements BundleActivator {
- private EventRedeliverer _eventRedeliverer= null;
- private ServiceRegistration _eventAdminService = null;
- public void start(BundleContext bundleContext) {
-
- _eventAdminService = bundleContext.registerService("org.osgi.service.event.EventAdmin", //$NON-NLS-1$
- new EventAdminImpl(bundleContext),null);
- _eventRedeliverer = new EventRedeliverer(bundleContext);
- _eventRedeliverer.open();
-
- }
-
- public void stop(BundleContext bundleContext) {
-
- _eventRedeliverer.close();
- _eventRedeliverer=null;
- _eventAdminService.unregister();
- _eventAdminService=null;
-
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.event/src/org/eclipse/equinox/event/EventAdminImpl.java b/bundles/org.eclipse.equinox.event/src/org/eclipse/equinox/event/EventAdminImpl.java
deleted file mode 100644
index 2b7d01154..000000000
--- a/bundles/org.eclipse.equinox.event/src/org/eclipse/equinox/event/EventAdminImpl.java
+++ /dev/null
@@ -1,367 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.event;
-
-import org.eclipse.osgi.framework.eventmgr.*;
-import org.osgi.framework.*;
-import org.osgi.service.event.*;
-
-/**
- * Implementation of org.osgi.service.event.EventAdmin. EventAdminImpl uses
- * LogProxy and org.eclipse.osgi.framework.eventmgr.EventManager. It is assumeed
- * org.eclipse.osgi.framework.eventmgr package is exported by some other bundle.
- */
-public class EventAdminImpl implements EventAdmin {
- /**
- * Class EventDispatcher is used to dispatch events to EventHandlers.
- * Dispatch events only when the receiver bundle is ACTIVE, and the receiver
- * service is registered.
- */
- private class EventAdminDispatcher implements EventDispatcher {
- /**
- *
- * Dispatches Event to EventHandlers
- *
- * @param eventListener
- * @param listenerObject
- * @param eventAction
- * @param eventObject
- * @see org.eclipse.osgi.framework.eventmgr.EventDispatcher#dispatchEvent(java.lang.Object,
- * java.lang.Object, int, java.lang.Object)
- */
- public void dispatchEvent(Object eventListener, Object listenerObject,
- int eventAction, Object eventObject) {
- ServiceReference ref = null;
- ref = (ServiceReference) eventListener;
- Bundle bundle = ref.getBundle();
- if ((bundle == null) || (bundle.getState() != Bundle.ACTIVE)) {
- // the receiver service or bundle being not active, no need
- // to dispatch
- return;
- }
- Object serviceObject = bc.getService(ref);
- if ((serviceObject == null)
- || (!(serviceObject instanceof EventHandler))) {
- // the service being unregistered or invalid, no need to
- // dispatch
- return;
- }
- try {
- ((EventHandler) serviceObject).handleEvent((Event) eventObject);
- }
- catch (Throwable t) {
- // log/handle any Throwable thrown by the listener
- printError("Exception thrown while dispatching an Event to an EventHandler);");
- printError(" Event = " + eventObject);
- printError(" EventHandler = " + serviceObject, t);
- }
- }
- }
-
- private BundleContext bc;
- private EventManager eventManager;
- private static final char TOPIC_SEPARATOR = '/';
-
- /**
- * Constructer for EventAdminImpl.
- *
- * @param bc BundleContext
- */
- protected EventAdminImpl(BundleContext bc) {
- super();
- this.bc = bc;
- eventManager = new EventManager(
- "EventAdmin Async Event Dispatcher Thread");
- }
-
- /**
- * This method should be called when stopping EventAdmin service
- */
- void stop() {
- if (eventManager != null) {
- eventManager.close();
- eventManager = null;
- }
- bc = null;
- }
-
- /**
- * @param event
- * @see org.osgi.service.event.EventAdmin#postEvent(org.osgi.service.event.Event)
- */
- public void postEvent(Event event) {
- dispatchEvent(event, true);
- }
-
- /**
- * @param event
- * @see org.osgi.service.event.EventAdmin#sendEvent(org.osgi.service.event.Event)
- */
- public void sendEvent(Event event) {
- dispatchEvent(event, false);
- }
-
- /**
- * Internal main method for sendEvent() and postEvent(). Dispatching an
- * event to EventHandler. All exceptions are logged except when dealing with
- * LogEntry.
- *
- * @param event to be delivered
- * @param isAsync must be set to true for syncronous event delivery, false
- * for asyncronous delivery.
- */
- protected void dispatchEvent(Event event, boolean isAsync) {
- try {
- if (eventManager == null) {
- // EventAdmin is stopped
- return;
- }
- if (event == null) {
- printError("Null event is passed to EventAdmin. Ignored.");
- return;
- }
- if (!isCallerPermittedTopicPermission(event.getTopic())) {
- printError("Caller bundle doesn't have TopicPermission for topic="
- + event.getTopic());
- return;
- }
- ServiceReference[] refsForEventHandler = getAllEventHandlers();
- if (refsForEventHandler == null) {
- //No EventHandler exists. Do nothing.
- return;
- }
- EventListeners listeners = retrieveMatchedAndPermittedListeners(
- event, refsForEventHandler);
- if (listeners == null) {
- //No permitted EventHandler exists. Do nothing.
- return;
- }
- // Create the listener queue for this event delivery
- ListenerQueue listenerQueue = new ListenerQueue(eventManager);
- // Add the listeners to the queue and associate them with the event
- // dispatcher
- listenerQueue.queueListeners(listeners, new EventAdminDispatcher());
- // Deliver the event to the listeners.
- if (isAsync) {
- listenerQueue.dispatchEventAsynchronous(0, event);
- }
- else {
- listenerQueue.dispatchEventSynchronous(0, event);
- }
- // Remove the listener from the listener list
- listeners.removeAllListeners();
- }
- catch (Throwable t) {
- printError("Exception thrown while dispatching an event, event = "
- + event, t);
- }
- }
-
- /**
- * Filtering EventHandlers, represented by the param references, to listners
- * that have the same topic as the event.getTopic(), and whose Filter
- * property match the event when the property "Filter" is set. This method
- * also filters out listners that do not have appropriate TopicPermission.
- * Results are wrapped and put into EventListeners.
- *
- * @param event This object is used to filter EventHandlers
- * @param references EventHandlers to be filtered
- * @return EventListeners which contains filtered EventHandlers.
- */
- protected EventListeners retrieveMatchedAndPermittedListeners(Event event,
- ServiceReference[] references) {
- EventListeners listeners = null;
- for (int i = 0; i < references.length; i++) {
- ServiceReference ref = references[i];
- if (isEventMatchingListener(event, ref)
- && isHandlerGrantedTopicPermission(ref, event.getTopic())) {
- if (listeners == null)
- listeners = new EventListeners();
- listeners.addListener(ref, null);
- }
- }
- return listeners;
- }
-
- /**
- * Checks if the EventHandler represented by the parameter ref has right
- * SUBSCRIBE TopicPermission.
- *
- * @param ref This object represents ServiceReference which implement
- * EventHandler
- * @param topic This string represents TopicPermission.
- * @return
- */
- protected boolean isHandlerGrantedTopicPermission(ServiceReference ref,
- String topic) {
- Bundle bundle = ref.getBundle();
- return bundle.hasPermission(new TopicPermission(topic,
- TopicPermission.SUBSCRIBE));
- }
-
- /**
- * Checks if the caller bundle has right PUBLISH TopicPermision.
- *
- * @param topic
- * @return true if it has the right permission, false otherwise.
- */
- protected boolean isCallerPermittedTopicPermission(String topic) {
- SecurityManager sm = System.getSecurityManager();
- if (topic == null)
- return false;
- if (sm != null) {
- TopicPermission topicPermission = new TopicPermission(topic,
- TopicPermission.PUBLISH);
- try {
- sm.checkPermission(topicPermission);
- }
- catch (SecurityException e) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Checks if a topic filter string matches the target topic string.
- *
- * @param topicProperty A topic filter like "company/product/*"
- * @param topic Target topic to be checked against like
- * "company/product/topicA"
- * @return true if topicProperty matches topic, false if otherwise.
- */
- protected boolean topicPropertyIncludes(String topicProperty, String topic) {
- if (topicProperty.startsWith("*")) {
- return true;
- }
- if (topicProperty.equals(topic)) {
- return true;
- }
- int index = topicProperty.indexOf(TOPIC_SEPARATOR);
- int index2 = topic.indexOf(TOPIC_SEPARATOR);
- if (index == -1)
- return false;
- if (index2 == -1)
- return false;
- if (index == 0) {
- printError("topicProperty '" + topicProperty + "'starts with '"
- + TOPIC_SEPARATOR + "'. Ignored.");
- return false;
- }
- if (index2 == 0) {
- printError("topic '" + topic + "'starts with '" + TOPIC_SEPARATOR
- + "'. Ignored.");
- return false;
- }
- if (index == topicProperty.length() - 1) {
- printError("topicProperty '" + topicProperty + "'ends with '"
- + TOPIC_SEPARATOR + "'. Ignored.");
- return false;
- }
- if (index2 == topic.length() - 1) {
- printError("topic '" + topic + "'ends with '" + TOPIC_SEPARATOR
- + "'. Ignored.");
- return false;
- }
- String str = topicProperty.substring(0, index);
- String str2 = topic.substring(0, index2);
- if (str.equals(str2)) { // if first names of topic category match
- String str3 = topicProperty.substring(index + 1);
- String str4 = topic.substring(index2 + 1);
- return topicPropertyIncludes(str3, str4); // recursive call to test
- // the rest of the names
- }
- else {
- return false;
- }
- }
-
- /**
- * Checks if a EventHandler's SUBSCRIBE topics contains the target event's
- * topic. Also checks if the listener's EVENT_FILTER matches the event if
- * the filter property of the listener is set.
- *
- * @param event The event to be checked against
- * @param ref This ServiceReference represents EventHandler to be checked
- * @return true if the listener matches the event
- */
- protected boolean isEventMatchingListener(Event event, ServiceReference ref) {
- String eventTopic = event.getTopic();
- Object o = ref.getProperty(EventConstants.EVENT_TOPIC);
- if (o == null) {
- // means no topics, no need to investigate further
- return false;
- }
- if (!(o instanceof String[])) {
- // EVENT_TOPIC property must be String[], ignored.
- return false;
- }
- String listenerTopics[] = (String[]) o;
- boolean found = false;
- for (int i = 0; i < listenerTopics.length; i++) {
- if (topicPropertyIncludes(listenerTopics[i], eventTopic)) {
- found = true;
- break;
- }
- }
- if (!found) {
- return false;
- }
- Object o2 = ref.getProperty(EventConstants.EVENT_FILTER);
- if ((o2 == null) || (!(o2 instanceof String))) {
- // means no need to investigate further
- return true;
- }
- String filterString = (String) o2;
- try {
- Filter filter = bc.createFilter(filterString);
- return (event.matches(filter));
- }
- catch (InvalidSyntaxException e) {
- printError("exception thrown in BundleContext.createfilter(\""
- + filterString + "\". Ignored.", e);
- return false;
- }
- }
-
- /**
- * Returns all the EventHandler's ServiceReferences that are currently
- * registered.
- *
- * @return all the EventHandler's ServiceReferences that are currently
- * registered.
- */
- protected ServiceReference[] getAllEventHandlers() {
- ServiceReference[] references = null;
- try {
- // find all the eventHandlers
- references = bc.getServiceReferences(EventHandler.class.getName(),
- null);
- }
- catch (InvalidSyntaxException e) {
- // exception never be thrown, since filter is null in
- // getServiceReferences() call
- }
- return references;
- }
-
- private void printError(String msg, Throwable t) {
- System.out.println("EventAdmin: " + msg);
- if (t != null) {
- System.out.println("EventAdmin: exception = " + t);
- t.printStackTrace(System.out);
- }
- }
-
- private void printError(String msg) {
- printError(msg, null);
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/BundleEventAdapter.java b/bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/BundleEventAdapter.java
deleted file mode 100644
index 8bd49e5de..000000000
--- a/bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/BundleEventAdapter.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipsei.equinox.event.mapper;
-
-import java.util.Hashtable;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleEvent;
-import org.osgi.service.event.Event;
-import org.osgi.service.event.EventAdmin;
-
-/**
- * @version $Revision: 1.4 $
- */
-public class BundleEventAdapter extends EventAdapter {
- // constants for Event topic substring
- public static final String HEADER = "org/osgi/framework/BundleEvent";
- public static final String INSTALLED = "INSTALLED";
- public static final String STOPPED = "STOPPED";
- public static final String STARTED = "STARTED";
- public static final String UPDATED = "UPDATED";
- public static final String UNINSTALLED = "UNINSTALLED";
- public static final String RESOLVED = "RESOLVED";
- public static final String UNRESOLVED = "UNRESOLVED";
- private BundleEvent event;
-
- public BundleEventAdapter(BundleEvent event, EventAdmin eventAdmin) {
- super(eventAdmin);
- this.event = event;
- }
-
- /**
- * @return
- * @see org.eclipse.equinox.event.mapper.EventAdapter#convert()
- */
- public Event convert() {
- String typename = null;
- switch (event.getType()) {
- case BundleEvent.INSTALLED :
- typename = INSTALLED;
- break;
- case BundleEvent.STOPPED :
- typename = STOPPED;
- break;
- case BundleEvent.STARTED :
- typename = STARTED;
- break;
- case BundleEvent.UPDATED :
- typename = UPDATED;
- break;
- case BundleEvent.UNINSTALLED :
- typename = UNINSTALLED;
- break;
- case BundleEvent.RESOLVED :
- typename = RESOLVED;
- break;
- case BundleEvent.UNRESOLVED :
- typename = UNRESOLVED;
- break;
- default :
- // unknown events must be send as their decimal value
- typename = ""+event.getType();
- }
- String topic = HEADER + Constants.TOPIC_SEPARATOR + typename;
- Hashtable properties = new Hashtable();
- Bundle bundle = event.getBundle();
- if (bundle == null) {
- throw new RuntimeException("BundleEvent.getBundle() returns null");
- }
- else {
- putBundleProperties(properties, bundle);
- }
- properties.put(Constants.EVENT, event);
- Event converted = new Event(topic, properties);
- return converted;
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/ConfigurationEventAdapter.java b/bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/ConfigurationEventAdapter.java
deleted file mode 100644
index 1a9fb6a0b..000000000
--- a/bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/ConfigurationEventAdapter.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipsei.equinox.event.mapper;
-
-import java.util.Hashtable;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.cm.ConfigurationEvent;
-import org.osgi.service.event.Event;
-import org.osgi.service.event.EventAdmin;
-
-/**
- * @version $Revision: 1.4 $
- */
-public class ConfigurationEventAdapter extends EventAdapter {
- // constants for Event topic substring
- public static final String HEADER = "org/osgi/service/cm/ConfigurationEvent";
- public static final String CM_UPDATED = "CM_UPDATED";
- public static final String CM_DELETED = "CM_DELETED";
- // constants for Event properties
- public static final String CM_FACTORY_PID = "cm.factoryPid";
- public static final String CM_PID = "cm.pid";
- private ConfigurationEvent event;
-
- public ConfigurationEventAdapter(ConfigurationEvent event,
- EventAdmin eventAdmin) {
- super(eventAdmin);
- this.event = event;
- }
-
- /**
- * @return
- * @see org.eclipse.equinox.event.mapper.EventAdapter#convert()
- */
- public Event convert() {
- String typename = null;
- switch (event.getType()) {
- case ConfigurationEvent.CM_UPDATED :
- typename = CM_UPDATED;
- break;
- case ConfigurationEvent.CM_DELETED :
- typename = CM_DELETED;
- break;
- default :
- return null;
- }
- String topic = HEADER + Constants.TOPIC_SEPARATOR + typename;
- Hashtable properties = new Hashtable();
- ServiceReference ref = event.getReference();
- if (ref == null) {
- throw new RuntimeException(
- "ServiceEvent.getServiceReference() is null");
- }
- properties.put(CM_PID, event.getPid());
- if (event.getFactoryPid() != null) {
- properties.put(CM_FACTORY_PID, event.getFactoryPid());
- }
- putServiceReferenceProperties(properties, ref);
- // assert objectClass includes
- // "org.osgi.service.cm.ConfigurationAdmin"
- Event converted = new Event(topic, properties);
- return converted;
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/Constants.java b/bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/Constants.java
deleted file mode 100644
index 521107422..000000000
--- a/bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/Constants.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipsei.equinox.event.mapper;
-
-/**
- * @version $Revision: 1.4 $
- */
-public interface Constants {
- // constants for Event common properties; event specific properties are
- // defined in the corresponding event adapter.
- public static final String BUNDLE = "bundle";
- public static final String BUNDLE_ID = "bundle.id";
- public static final String BUNDLE_SYMBOLICNAME = "bundle.symbolicName";
- public static final String EVENT = "event";
- public static final String EXCEPTION = "exception";
- public static final String EXCEPTION_CLASS = "exception.class";
- public static final String EXCEPTION_MESSAGE = "exception.message";
- public static final String MESSAGE = "message";
- public static final String SERVICE = "service";
- public static final String SERVICE_ID = "service.id";
- public static final String SERVICE_OBJECTCLASS = "service.objectClass";
- public static final String SERVICE_PID = "service.pid";
- public static final String TIMESTAMP = "timestamp";
- public static final char TOPIC_SEPARATOR = '/';
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/EventAdapter.java b/bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/EventAdapter.java
deleted file mode 100644
index 4add7a214..000000000
--- a/bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/EventAdapter.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipsei.equinox.event.mapper;
-
-import java.util.Hashtable;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.event.Event;
-import org.osgi.service.event.EventAdmin;
-
-/**
- * @version $Revision: 1.4 $
- */
-public abstract class EventAdapter {
- final EventAdmin eventAdmin;
-
- /**
- * @param event
- * @param eventAdmin
- */
- public EventAdapter(EventAdmin eventAdmin) {
- this.eventAdmin = eventAdmin;
- }
-
- /**
- * @return
- */
- public abstract Event convert();
-
- public void redeliver() {
- Event converted = convert();
- if (converted != null) {
- redeliverInternal(converted);
- }
- }
-
- /**
- * subclasses should override this method if it wants to use sendEvent()
- * instead.
- */
- protected void redeliverInternal(Event converted) {
- eventAdmin.postEvent(converted);
- }
-
- public void putBundleProperties(Hashtable properties, Bundle bundle) {
- // assertion bundle != null
- properties.put(Constants.BUNDLE_ID, new Long(bundle.getBundleId()));
- String symbolicName = bundle.getSymbolicName();
- if (symbolicName != null) {
- properties.put(Constants.BUNDLE_SYMBOLICNAME, symbolicName);
- }
- properties.put(Constants.BUNDLE, bundle);
- }
-
- public void putExceptionProperties(Hashtable properties, Throwable t) {
- // assertion t != null
- properties.put(Constants.EXCEPTION, t);
- properties.put(Constants.EXCEPTION_CLASS, t.getClass().getName());
- String message = t.getMessage();
- if (message != null) {
- properties.put(Constants.EXCEPTION_MESSAGE, t.getMessage());
- }
- }
-
- public void putServiceReferenceProperties(Hashtable properties,
- ServiceReference ref) {
- // assertion ref != null
- properties.put(Constants.SERVICE, ref);
- properties.put(Constants.SERVICE_ID, ref
- .getProperty(org.osgi.framework.Constants.SERVICE_ID));
- Object o = ref.getProperty(org.osgi.framework.Constants.SERVICE_PID);
- if ((o != null) && (o instanceof String)) {
- properties.put(Constants.SERVICE_PID, (String) o);
- }
- Object o2 = ref.getProperty(org.osgi.framework.Constants.OBJECTCLASS);
- if ((o2 != null) && (o2 instanceof String[])) {
- properties.put(Constants.SERVICE_OBJECTCLASS, (String[]) o2);
- }
- }
-
- /*
- * Utility function for converting classes into strings
- */
- public String[] classes2strings(Class classes[]) {
- if ((classes == null) || (classes.length == 0))
- return null;
- String[] strings = new String[classes.length];
- for (int i = 0; i < classes.length; i++) {
- strings[i] = classes[i].getName();
- }
- return strings;
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/EventRedeliverer.java b/bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/EventRedeliverer.java
deleted file mode 100644
index 4615d9fc1..000000000
--- a/bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/EventRedeliverer.java
+++ /dev/null
@@ -1,307 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipsei.equinox.event.mapper;
-
-import java.util.Dictionary;
-import java.util.Hashtable;
-import org.osgi.framework.*;
-import org.osgi.service.cm.ConfigurationEvent;
-import org.osgi.service.cm.ConfigurationListener;
-import org.osgi.service.event.EventAdmin;
-import org.osgi.service.log.LogEntry;
-import org.osgi.service.log.LogListener;
-import org.osgi.service.log.LogReaderService;
-import org.osgi.service.upnp.UPnPDevice;
-import org.osgi.service.upnp.UPnPEventListener;
-import org.osgi.service.upnp.UPnPService;
-import org.osgi.service.useradmin.UserAdminEvent;
-import org.osgi.service.useradmin.UserAdminListener;
-import org.osgi.service.wireadmin.WireAdminEvent;
-import org.osgi.service.wireadmin.WireAdminListener;
-import org.osgi.service.wireadmin.WireConstants;
-import org.osgi.util.tracker.ServiceTracker;
-
-/**
- * Main class for redeliver special events like FrameworkEvents via EventAdmin.
- *
- *
- * @version $Revision: 1.4 $
- */
-public class EventRedeliverer implements FrameworkListener, BundleListener,
- ServiceListener, LogListener, LogReaderServiceListener,
- ConfigurationListener, WireAdminListener, UPnPEventListener,
- UserAdminListener {
- private ServiceTracker eventAdminTracker;
- private LogReaderServiceTracker logTracker;
- private LogReaderService reader;
- private final static boolean DEBUG = false;
- private BundleContext bc;
- private ServiceRegistration configurationListenerReg;
- private ServiceRegistration wireAdminListenerReg;
- private ServiceRegistration upnpEventListenerReg;
- private ServiceRegistration userAdminListenerReg;
-
- public EventRedeliverer(BundleContext bc) {
- this.bc = bc;
- }
-
- public void close() {
- if (logTracker != null) {
- logTracker.close();
- logTracker = null;
- }
- if (eventAdminTracker != null) {
- eventAdminTracker.close();
- eventAdminTracker = null;
- }
- if (reader != null) {
- reader.removeLogListener(this);
- }
- reader = null;
- bc.removeFrameworkListener(this);
- bc.removeBundleListener(this);
- bc.removeServiceListener(this);
- if (configurationListenerReg != null) {
- configurationListenerReg.unregister();
- configurationListenerReg = null;
- }
- if (wireAdminListenerReg != null) {
- wireAdminListenerReg.unregister();
- wireAdminListenerReg = null;
- }
- if (upnpEventListenerReg != null) {
- upnpEventListenerReg.unregister();
- upnpEventListenerReg = null;
- }
- if (userAdminListenerReg != null) {
- userAdminListenerReg.unregister();
- userAdminListenerReg = null;
- }
- }
-
- /**
- * prepare any service trackers and register event listeners which are
- * necessary to obtain events to be mapped
- */
- public void open() {
- // open ServiceTracker for EventAdmin
- eventAdminTracker = new ServiceTracker(bc, EventAdmin.class.getName(),
- null);
- eventAdminTracker.open();
- // open ServiceTracker for LogReaderService
- logTracker = new LogReaderServiceTracker(bc, this);
- logTracker.open();
- // add legacy event listener for framework level event
- bc.addFrameworkListener(this);
- bc.addBundleListener(this);
- bc.addServiceListener(this);
- // register configurationListener
- configurationListenerReg = bc.registerService(
- ConfigurationListener.class.getName(), this, null);
- // register WireAdminListener
- Hashtable ht = new Hashtable();
- // create an event mask to receive all the types of WireAdminEvent
- Integer mask = new Integer(WireAdminEvent.WIRE_CONNECTED
- | WireAdminEvent.WIRE_CREATED | WireAdminEvent.WIRE_DELETED
- | WireAdminEvent.WIRE_DISCONNECTED | WireAdminEvent.WIRE_TRACE
- | WireAdminEvent.WIRE_UPDATED
- | WireAdminEvent.CONSUMER_EXCEPTION
- | WireAdminEvent.PRODUCER_EXCEPTION);
- ht.put(WireConstants.WIREADMIN_EVENTS, mask);
- wireAdminListenerReg = bc.registerService(WireAdminListener.class
- .getName(), this, ht);
- // register UPnPEventListener
- // create a Filter object to receive all the UPnP events
- Hashtable ht2 = new Hashtable();
- Filter filter = null;
- try {
- filter = bc.createFilter("(|(|(" + UPnPDevice.TYPE + "=*)("
- + UPnPDevice.ID + "=*))(|(" + UPnPService.TYPE + "=*)("
- + UPnPService.ID + "=*)))");
- }
- catch (InvalidSyntaxException e) {
- System.out
- .println("Exception thrown while trying to create Filter. "
- + e);
- e.printStackTrace(System.out);
- }
- if (filter != null) {
- ht2.put(UPnPEventListener.UPNP_FILTER, filter);
- upnpEventListenerReg = bc.registerService(UPnPEventListener.class
- .getName(), this, ht2);
- }
- // register usrAdminListener
- userAdminListenerReg = bc.registerService(UserAdminListener.class
- .getName(), this, null);
- }
-
- private EventAdmin getEventAdmin() {
- if (eventAdminTracker == null)
- return null;
- return (EventAdmin) eventAdminTracker.getService();
- }
-
- /**
- * @param event
- * @see org.osgi.framework.FrameworkListener#frameworkEvent(org.osgi.framework.FrameworkEvent)
- */
- public void frameworkEvent(FrameworkEvent event) {
- EventAdmin eventAdmin = getEventAdmin();
- if (eventAdmin != null) {
- (new FrameworkEventAdapter(event, eventAdmin)).redeliver();
- }
- else {
- printNoEventAdminError();
- }
- }
-
- private void printNoEventAdminError() {
- if (DEBUG) {
- System.out.println(this.getClass().getName()
- + ": Cannot find the EventAdmin.");
- }
- }
-
- /**
- * @param event
- * @see org.osgi.framework.BundleListener#bundleChanged(org.osgi.framework.BundleEvent)
- */
- public void bundleChanged(BundleEvent event) {
- EventAdmin eventAdmin = getEventAdmin();
- if (eventAdmin != null) {
- (new BundleEventAdapter(event, eventAdmin)).redeliver();
- }
- else {
- printNoEventAdminError();
- }
- }
-
- /**
- * @param event
- * @see org.osgi.framework.ServiceListener#serviceChanged(org.osgi.framework.ServiceEvent)
- */
- public void serviceChanged(ServiceEvent event) {
- EventAdmin eventAdmin = getEventAdmin();
- if (eventAdmin != null) {
- (new ServiceEventAdapter(event, eventAdmin)).redeliver();
- }
- else {
- printNoEventAdminError();
- }
- }
-
- /**
- * @param entry
- * @see org.osgi.service.log.LogListener#logged(org.osgi.service.log.LogEntry)
- */
- public void logged(LogEntry entry) {
- EventAdmin eventAdmin = getEventAdmin();
- if (eventAdmin != null) {
- (new LogEntryAdapter(entry, eventAdmin)).redeliver();
- }
- else {
- printNoEventAdminError();
- }
- }
-
- /**
- * @param reference
- * @param service
- * @see org.eclipse.equinox.event.mapper.LogReaderServiceListener#logReaderServiceAdding(org.osgi.framework.ServiceReference,
- * org.osgi.service.log.LogReaderService)
- */
- public void logReaderServiceAdding(ServiceReference reference,
- LogReaderService service) {
- if (reader != null) {
- return;
- }
- reader = service;
- reader.addLogListener(this);
- }
-
- /**
- * @param reference
- * @param service
- * @see org.eclipse.equinox.event.mapper.LogReaderServiceListener#logReaderServiceRemoved(org.osgi.framework.ServiceReference,
- * org.osgi.service.log.LogReaderService)
- */
- public void logReaderServiceRemoved(ServiceReference reference,
- LogReaderService service) {
- if ((reader != null) && reader.equals(service)) {
- reader.removeLogListener(this);
- reader = null;
- }
- // ungetService() will be called after returning to
- // LogReaderServiceTracker's removedService() method.
- }
-
- /**
- * @param event
- * @see org.osgi.service.cm.ConfigurationListener#configurationEvent(org.osgi.service.cm.ConfigurationEvent)
- */
- public void configurationEvent(ConfigurationEvent event) {
- EventAdmin eventAdmin = getEventAdmin();
- if (eventAdmin != null) {
- (new ConfigurationEventAdapter(event, eventAdmin)).redeliver();
- }
- else {
- printNoEventAdminError();
- }
- }
-
- /**
- * @param event
- * @see org.osgi.service.wireadmin.WireAdminListener#wireAdminEvent(org.osgi.service.wireadmin.WireAdminEvent)
- */
- public void wireAdminEvent(WireAdminEvent event) {
- EventAdmin eventAdmin = getEventAdmin();
- if (eventAdmin != null) {
- (new WireAdminEventAdapter(event, eventAdmin)).redeliver();
- }
- else {
- printNoEventAdminError();
- }
- }
-
- /**
- * @param deviceId
- * @param serviceId
- * @param events
- * @see org.osgi.service.upnp.UPnPEventListener#notifyUPnPEvent(java.lang.String,
- * java.lang.String, java.util.Dictionary)
- */
- public void notifyUPnPEvent(String deviceId, String serviceId,
- Dictionary events) {
- EventAdmin eventAdmin = getEventAdmin();
- if (eventAdmin != null) {
- (new UPnPEventAdapter(deviceId, serviceId, events, eventAdmin))
- .redeliver();
- }
- else {
- printNoEventAdminError();
- }
- }
-
- /**
- * @param event
- * @see org.osgi.service.useradmin.UserAdminListener#roleChanged(org.osgi.service.useradmin.UserAdminEvent)
- */
- public void roleChanged(UserAdminEvent event) {
- EventAdmin eventAdmin = getEventAdmin();
- if (eventAdmin != null) {
- (new UserAdminEventAdapter(event, eventAdmin)).redeliver();
- }
- else {
- printNoEventAdminError();
- }
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/FrameworkEventAdapter.java b/bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/FrameworkEventAdapter.java
deleted file mode 100644
index 071e66fa3..000000000
--- a/bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/FrameworkEventAdapter.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipsei.equinox.event.mapper;
-
-import java.util.Hashtable;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.FrameworkEvent;
-import org.osgi.service.event.Event;
-import org.osgi.service.event.EventAdmin;
-
-/**
- * @version $Revision: 1.4 $
- */
-public class FrameworkEventAdapter extends EventAdapter {
- // constants for Event topic substring
- public static final String HEADER = "org/osgi/framework/FrameworkEvent";
- public static final String STARTLEVEL_CHANGED = "STARTLEVEL_CHANGED";
- public static final String STARTED = "STARTED";
- public static final String PACKAGES_REFRESHED = "PACKAGES_REFRESHED";
- public static final String ERROR = "ERROR";
- protected FrameworkEvent event;
-
- public FrameworkEventAdapter(FrameworkEvent event, EventAdmin eventAdmin) {
- super(eventAdmin);
- this.event = event;
- }
-
- /**
- * @return
- * @see org.eclipse.equinox.event.mapper.EventAdapter#convert()
- */
- public Event convert() {
- String typename = null;
- switch (event.getType()) {
- case FrameworkEvent.ERROR :
- typename = ERROR;
- break;
- case FrameworkEvent.PACKAGES_REFRESHED :
- typename = PACKAGES_REFRESHED;
- break;
- case FrameworkEvent.STARTED :
- typename = STARTED;
- break;
- case FrameworkEvent.STARTLEVEL_CHANGED :
- typename = STARTLEVEL_CHANGED;
- break;
- default :
- return null;
- }
- String topic = HEADER + Constants.TOPIC_SEPARATOR + typename;
- Hashtable properties = new Hashtable();
- Bundle bundle = event.getBundle();
- if (bundle != null) {
- putBundleProperties(properties, bundle);
- }
- Throwable t = event.getThrowable();
- if (t != null) {
- putExceptionProperties(properties, t);
- }
- properties.put(Constants.EVENT, event);
- Event converted = new Event(topic, properties);
- return converted;
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/LogEntryAdapter.java b/bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/LogEntryAdapter.java
deleted file mode 100644
index 232514b17..000000000
--- a/bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/LogEntryAdapter.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipsei.equinox.event.mapper;
-
-import java.util.Hashtable;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.event.Event;
-import org.osgi.service.event.EventAdmin;
-import org.osgi.service.log.LogEntry;
-import org.osgi.service.log.LogService;
-
-/**
- * @version $Revision: 1.4 $
- */
-public class LogEntryAdapter extends EventAdapter {
- // constants for Event topic substring
- public static final String TOPIC = "org/osgi/service/log/LogEntry";
- // constants for Event properties
- public static final String TIMESTAMP = "timestamp";
- public static final String MESSAGE = "message";
- public static final String LOG_LEVEL = "log.level";
- public static final String LOG_ENTRY = "log.entry";
- private LogEntry entry;
-
- public LogEntryAdapter(LogEntry entry, EventAdmin eventAdmin) {
- super(eventAdmin);
- this.entry = entry;
- }
-
- /**
- * @return
- * @see org.eclipse.equinox.event.mapper.EventAdapter#convert()
- */
- public Event convert() {
- String topic = TOPIC;
- int level = entry.getLevel();
- switch (level) {
- case LogService.LOG_ERROR:
- case LogService.LOG_WARNING:
- case LogService.LOG_INFO:
- case LogService.LOG_DEBUG:
- break;
- default:
- // other log levels are represented by their decimal value
- topic += Constants.TOPIC_SEPARATOR + level;
- }
- Hashtable properties = new Hashtable();
- Bundle bundle = entry.getBundle();
- if (bundle == null) {
- throw new RuntimeException("LogEntry.getBundle() returns null");
- }
- putBundleProperties(properties, bundle);
- Throwable t = entry.getException();
- if (t != null) {
- putExceptionProperties(properties, t);
- }
- ServiceReference ref = entry.getServiceReference();
- if (ref != null) {
- putServiceReferenceProperties(properties, ref);
- }
- properties.put(LOG_ENTRY, entry);
- properties.put(LOG_LEVEL, new Integer(entry.getLevel()));
- if (entry.getMessage() != null)
- properties.put(MESSAGE, entry.getMessage());
- properties.put(TIMESTAMP, new Long(entry.getTime()));
- Event converted = new Event(topic, properties);
- return converted;
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/LogReaderServiceListener.java b/bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/LogReaderServiceListener.java
deleted file mode 100644
index 147d8c761..000000000
--- a/bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/LogReaderServiceListener.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipsei.equinox.event.mapper;
-
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.log.LogReaderService;
-
-/**
- * @version $Revision: 1.4 $
- */
-public interface LogReaderServiceListener {
- public void logReaderServiceAdding(ServiceReference reference,
- LogReaderService service);
-
- public void logReaderServiceRemoved(ServiceReference reference,
- LogReaderService service);
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/LogReaderServiceTracker.java b/bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/LogReaderServiceTracker.java
deleted file mode 100644
index b55fa3982..000000000
--- a/bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/LogReaderServiceTracker.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipsei.equinox.event.mapper;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.log.LogReaderService;
-import org.osgi.util.tracker.ServiceTracker;
-
-/**
- * @version $Revision: 1.4 $
- */
-public class LogReaderServiceTracker extends ServiceTracker {
- private final LogReaderServiceListener listener;
- private ServiceReference reference;
-
- public LogReaderServiceTracker(BundleContext context,
- LogReaderServiceListener listener) {
- super(context, LogReaderService.class.getName(), null);
- this.listener = listener;
- }
-
- public Object addingService(ServiceReference reference) {
- Object object = super.addingService(reference);
- if ((object != null) && (this.reference == null)
- && (object instanceof LogReaderService)) {
- this.reference = reference;
- listener.logReaderServiceAdding(reference,
- (LogReaderService) object);
- }
- return object;
- }
-
- public void removedService(ServiceReference reference, Object service) {
- if ((service != null) && (this.reference.equals(reference))
- && (service instanceof LogReaderService)) {
- listener.logReaderServiceRemoved(reference,
- (LogReaderService) service);
- this.reference = null;
- }
- super.removedService(reference, service);
- //this method calls ungetService()
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/ServiceEventAdapter.java b/bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/ServiceEventAdapter.java
deleted file mode 100644
index b55025ef0..000000000
--- a/bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/ServiceEventAdapter.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipsei.equinox.event.mapper;
-
-import java.util.Hashtable;
-import org.osgi.framework.ServiceEvent;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.event.Event;
-import org.osgi.service.event.EventAdmin;
-
-/**
- * @version $Revision: 1.4 $
- */
-public class ServiceEventAdapter extends EventAdapter {
- // constants for Event topic substring
- public static final String HEADER = "org/osgi/framework/ServiceEvent";
- public static final String UNREGISTERING = "UNREGISTERING";
- public static final String MODIFIED = "MODIFIED";
- public static final String REGISTERED = "REGISTERED";
- private ServiceEvent event;
-
- public ServiceEventAdapter(ServiceEvent event, EventAdmin eventAdmin) {
- super(eventAdmin);
- this.event = event;
- }
-
- // override super's method to force syncronous event delivery
- protected void redeliverInternal(Event converted) {
- eventAdmin.sendEvent(converted);
- }
-
- /**
- * @return
- * @see org.eclipse.equinox.event.mapper.EventAdapter#convert()
- */
- public Event convert() {
- String typename = null;
- switch (event.getType()) {
- case ServiceEvent.REGISTERED :
- typename = REGISTERED;
- break;
- case ServiceEvent.MODIFIED :
- typename = MODIFIED;
- break;
- case ServiceEvent.UNREGISTERING :
- typename = UNREGISTERING;
- break;
- default :
- return null;
- }
- String topic = HEADER + Constants.TOPIC_SEPARATOR + typename;
- Hashtable properties = new Hashtable();
- ServiceReference ref = event.getServiceReference();
- if (ref != null) {
- putServiceReferenceProperties(properties, ref);
- }
- properties.put(Constants.EVENT, event);
- Event converted = new Event(topic, properties);
- return converted;
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/UPnPEventAdapter.java b/bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/UPnPEventAdapter.java
deleted file mode 100644
index d93e6f38b..000000000
--- a/bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/UPnPEventAdapter.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipsei.equinox.event.mapper;
-
-import java.util.Dictionary;
-import java.util.Hashtable;
-import org.osgi.service.event.Event;
-import org.osgi.service.event.EventAdmin;
-
-/**
- * @version $Revision: 1.4 $
- */
-public class UPnPEventAdapter extends EventAdapter {
- // constants for Event topic substring
- public static final String TOPIC = "org/osgi/service/upnp/UPnPEvent";
- // constants for Event properties
- public static final String UPNP_DEVICEID = "upnp.deviceId";
- public static final String UPNP_SERVICEID = "upnp.serviceId";
- public static final String UPNP_EVENTS = "upnp.events";
- private String deviceId;
- private String serviceId;
- private Dictionary events;
-
- public UPnPEventAdapter(String deviceId, String serviceId,
- Dictionary events, EventAdmin eventAdmin) {
- super(eventAdmin);
- this.deviceId = deviceId;
- this.serviceId = serviceId;
- this.events = events;
- }
-
- /**
- * @return
- * @see org.eclipse.equinox.event.mapper.EventAdapter#convert()
- */
- public Event convert() {
- Hashtable properties = new Hashtable();
- if (deviceId != null) {
- properties.put(UPNP_DEVICEID, deviceId);
- }
- if (serviceId != null) {
- properties.put(UPNP_SERVICEID, serviceId);
- }
- if (events != null) {
- properties.put(UPNP_EVENTS, events);
- }
- Event converted = new Event(TOPIC, properties);
- return converted;
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/UserAdminEventAdapter.java b/bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/UserAdminEventAdapter.java
deleted file mode 100644
index 796b07502..000000000
--- a/bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/UserAdminEventAdapter.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipsei.equinox.event.mapper;
-
-import java.util.Hashtable;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.event.Event;
-import org.osgi.service.event.EventAdmin;
-import org.osgi.service.useradmin.Role;
-import org.osgi.service.useradmin.UserAdminEvent;
-
-/**
- * @version $Revision: 1.4 $
- */
-public class UserAdminEventAdapter extends EventAdapter {
- // constants for Event topic substring
- public static final String TOPIC = "org/osgi/service/useradmin/UserAdminEvent";
- public static final String ROLE_CREATED = "ROLE_CREATED";
- public static final String ROLE_CHANGED = "ROLE_CHANGED";
- public static final String ROLE_REMOVED = "ROLE_REMOVED";
- // constants for Event properties
- public static final String ROLE = "role";
- public static final String ROLE_NAME = "role.name";
- public static final String ROLE_TYPE = "role.type";
- private UserAdminEvent event;
-
- public UserAdminEventAdapter(UserAdminEvent event, EventAdmin eventAdmin) {
- super(eventAdmin);
- this.event = event;
- }
-
- /**
- * @return
- * @see org.eclipse.equinox.event.mapper.EventAdapter#convert()
- */
- public Event convert() {
- String typename = null;
- switch (event.getType()) {
- case UserAdminEvent.ROLE_CREATED :
- typename = ROLE_CREATED;
- break;
- case UserAdminEvent.ROLE_CHANGED :
- typename = ROLE_CHANGED;
- break;
- case UserAdminEvent.ROLE_REMOVED :
- typename = ROLE_REMOVED;
- break;
- default :
- return null;
- }
- String topic = TOPIC + Constants.TOPIC_SEPARATOR + typename;
- Hashtable properties = new Hashtable();
- ServiceReference ref = event.getServiceReference();
- if (ref == null) {
- throw new RuntimeException(
- "UserAdminEvent's getServiceReference() returns null.");
- }
- putServiceReferenceProperties(properties, ref);
- Role role = event.getRole();
- if (role == null) {
- throw new RuntimeException(
- "UserAdminEvent's getRole() returns null.");
- }
- if (role != null) {
- properties.put(ROLE, role);
- properties.put(ROLE_NAME, role.getName());
- properties.put(ROLE_TYPE, new Integer(role.getType()));
- }
- properties.put(Constants.EVENT, event);
- Event converted = new Event(topic, properties);
- return converted;
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/WireAdminEventAdapter.java b/bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/WireAdminEventAdapter.java
deleted file mode 100644
index 7b425f161..000000000
--- a/bundles/org.eclipse.equinox.event/src/org/eclipsei/equinox/event/mapper/WireAdminEventAdapter.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipsei.equinox.event.mapper;
-
-import java.util.Hashtable;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.event.Event;
-import org.osgi.service.event.EventAdmin;
-import org.osgi.service.wireadmin.Wire;
-import org.osgi.service.wireadmin.WireAdminEvent;
-
-/**
- * @version $Revision: 1.4 $
- */
-public class WireAdminEventAdapter extends EventAdapter {
- // constants for Event topic substring
- public static final String TOPIC = "org/osgi/service/wireadmin/WireAdminEvent";
- public static final String WIRE_CREATED = "WIRE_CREATED";
- public static final String WIRE_CONNECTED_T = "WIRE_CONNECTED";
- public static final String WIRE_UPDATED = "WIRE_UPDATED";
- public static final String WIRE_TRACE = "WIRE_TRACE";
- public static final String WIRE_DISCONNECTED = "WIRE_DISCONNECTED";
- public static final String WIRE_DELETED = "WIRE_DELETED";
- public static final String PRODUCER_EXCEPTION = "PRODUCER_EXCEPTION";
- public static final String CONSUMER_EXCEPTION = "CONSUMER_EXCEPTION";
- // constants for Event properties
- public static final String WIRE = "wire";
- public static final String WIRE_FLAVORS = "wire.flavors";
- public static final String WIRE_SCOPE = "wire.scope";
- public static final String WIRE_CONNECTED_P = "wire.connected";
- public static final String WIRE_VALID = "wire.valid";
- private WireAdminEvent event;
-
- public WireAdminEventAdapter(WireAdminEvent event, EventAdmin admin) {
- super(admin);
- this.event = event;
- }
-
- /**
- * @return
- * @see org.eclipse.equinox.event.mapper.EventAdapter#convert()
- */
- public Event convert() {
- String typename = null;
- switch (event.getType()) {
- case WireAdminEvent.WIRE_CONNECTED :
- typename = WIRE_CONNECTED_T;
- break;
- case WireAdminEvent.WIRE_CREATED :
- typename = WIRE_CREATED;
- break;
- case WireAdminEvent.WIRE_UPDATED :
- typename = WIRE_UPDATED;
- break;
- case WireAdminEvent.WIRE_DELETED :
- typename = WIRE_DELETED;
- break;
- case WireAdminEvent.WIRE_DISCONNECTED :
- typename = WIRE_DISCONNECTED;
- break;
- case WireAdminEvent.WIRE_TRACE :
- typename = WIRE_TRACE;
- break;
- case WireAdminEvent.PRODUCER_EXCEPTION :
- typename = PRODUCER_EXCEPTION;
- break;
- case WireAdminEvent.CONSUMER_EXCEPTION :
- typename = CONSUMER_EXCEPTION;
- break;
- default :
- return null;
- }
- String topic = TOPIC + Constants.TOPIC_SEPARATOR + typename;
- Hashtable properties = new Hashtable();
- Throwable t = event.getThrowable();
- if (t != null) {
- putExceptionProperties(properties, t);
- }
- ServiceReference ref = event.getServiceReference();
- if (ref == null) {
- throw new RuntimeException("WireAdminEvent's getServiceReference() returns null.");
- }
- putServiceReferenceProperties(properties, ref);
- Wire wire = event.getWire();
- if (wire != null) {
- properties.put(WIRE, wire);
- if (wire.getFlavors() != null) {
- properties.put(WIRE_FLAVORS, classes2strings(wire.getFlavors()));
- }
- if (wire.getScope() != null) {
- properties.put(WIRE_SCOPE, wire.getScope());
- }
- properties.put(WIRE_CONNECTED_P, new Boolean(wire.isConnected()));
- properties.put(WIRE_VALID, new Boolean(wire.isValid()));
- }
- properties.put(Constants.EVENT, event);
- Event converted = new Event(topic, properties);
- return converted;
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.http/.classpath b/bundles/org.eclipse.equinox.http/.classpath
deleted file mode 100644
index 065ac06e1..000000000
--- a/bundles/org.eclipse.equinox.http/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/bundles/org.eclipse.equinox.http/.cvsignore b/bundles/org.eclipse.equinox.http/.cvsignore
deleted file mode 100644
index ba077a403..000000000
--- a/bundles/org.eclipse.equinox.http/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
diff --git a/bundles/org.eclipse.equinox.http/.project b/bundles/org.eclipse.equinox.http/.project
deleted file mode 100644
index 61067d2f9..000000000
--- a/bundles/org.eclipse.equinox.http/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.equinox.http</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/bundles/org.eclipse.equinox.http/.settings/org.eclipse.jdt.core.prefs b/bundles/org.eclipse.equinox.http/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index bfb7248b2..000000000
--- a/bundles/org.eclipse.equinox.http/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,49 +0,0 @@
-#Fri Dec 16 09:20:21 CST 2005
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
-org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
-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=warning
-org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
-org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
-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=warning
-org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
-org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
-org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
-org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
-org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
-org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
-org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore
-org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
-org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
-org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning
-org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
-org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
-org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
-org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.unusedImport=error
-org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
-org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
-org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
-org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
diff --git a/bundles/org.eclipse.equinox.http/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.http/META-INF/MANIFEST.MF
deleted file mode 100644
index 574c6dfce..000000000
--- a/bundles/org.eclipse.equinox.http/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,22 +0,0 @@
-Bundle-ManifestVersion: 2
-Bundle-Vendor: %bundleVendor
-Bundle-Version: 1.0.0.qualifier
-Bundle-Activator: org.eclipse.equinox.http.Activator
-Bundle-Copyright: %bundleCopyright
-Bundle-SymbolicName: org.eclipse.equinox.http
-Bundle-Name: %bundleName
-Import-Package: javax.servlet,
- javax.servlet.http,
- org.osgi.framework;version="1.0",
- org.osgi.service.cm;version="1.0",
- org.osgi.service.http;version="1.1",
- org.osgi.service.log;version="1.0",
- org.osgi.util.tracker;version="1.1",
- org.eclipse.osgi.util
-Export-Package: org.eclipse.equinox.http;x-internal:=true,
- org.eclipse.equinox.http.servlet;x-internal:=true,
- org.eclipse.equinox.socket;x-internal:=true,
- org.eclipse.equinox.socket.https;x-internal:=true
-Import-Service: org.osgi.service.log.LogService
-Export-Service: org.osgi.service.http.HttpService
-Bundle-Localization: plugin
diff --git a/bundles/org.eclipse.equinox.http/OSGI-INF/l10n/bundle_en.properties b/bundles/org.eclipse.equinox.http/OSGI-INF/l10n/bundle_en.properties
deleted file mode 100644
index c363862d4..000000000
--- a/bundles/org.eclipse.equinox.http/OSGI-INF/l10n/bundle_en.properties
+++ /dev/null
@@ -1,33 +0,0 @@
-###############################################################################
-# Copyright (c) 1999, 2005 IBM Corporation.
-# 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:
-# IBM Corporation - initial API and implementation
-###############################################################################
-# NLS_MESSAGEFORMAT_ALL
-MIN_THREADS=Minimum Threads
-MIN_THREADS_DESC=The minimum number of threads allotted to the Http Service
-MAX_THREADS=Maximum Threads
-MAX_THREADS_DESC=The maximum number of threads allotted to the Http Service
-THREAD_PRIORITY=Thread Priority
-THREAD_PRIORITY_DESC=The priority of the Http Service Threads
-ADDRESS=Host Address
-ADDRESS_DESC=The Host Address to listen on
-PORT_NUMBER=Port Number
-PORT_NUMBER_DESC=The port number
-PORT_SCHEME=Port Scheme
-PORT_SCHEME_DESC=The protocol
-HTTP=http
-HTTPS=https
-THREAD_TIMEOUT=Keep-Alive thread timeout
-THREAD_TIMEOUT_DESC=The number of seconds to wait for another request before reclaiming the thread
-SERVICE_RANKING=Service Ranking
-SERVICE_RANKING_DESC=The service ranking framework property
-HTTP_GEN_SETTINGS=Http Service General Settings
-HTTP_GEN_SETTINGS_DESC=The general settings for the Http Service
-HTTP_SETTINGS=Http Service Settings
-HTTP_SETTINGS_DESC=The configurable settings for each registered Http Service
diff --git a/bundles/org.eclipse.equinox.http/OSGI-INF/metatype/METADATA.XML b/bundles/org.eclipse.equinox.http/OSGI-INF/metatype/METADATA.XML
deleted file mode 100644
index 3b64d2ea3..000000000
--- a/bundles/org.eclipse.equinox.http/OSGI-INF/metatype/METADATA.XML
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<metatype:MetaData xmlns:metatype="http://www.osgi.org/xmlns/metatype/v1.0.0">
- <OCD id="org.eclipse.equinox.http.Http" name="%HTTP_GEN_SETTINGS" description="%HTTP_GEN_SETTINGS_DESC">
- <AD id="http.minThreads" type="Integer" default="4" name="%MIN_THREADS" description="%MIN_THREADS_DESC" cardinality="0" min="0" max="63" />
- <AD id="http.maxThreads" type="Integer" default="20" name="%MAX_THREADS" description="%MAX_THREADS_DESC" cardinality="0" min="0" max="63" />
- <AD id="http.threadPriority" type="Integer" default="5" name="%THREAD_PRIORITY" description="%THREAD_PRIORITY_DESC" cardinality="0" min="1" max="10" />
- </OCD>
- <OCD id="org.eclipse.equinox.http.HttpFactory" name="%HTTP_SETTINGS" description="%HTTP_SETTINGS_DESC">
- <AD id="http.address" type="String" default="ALL" name="%ADDRESS" description="%ADDRESS_DESC" cardinality="0" />
- <AD id="http.port" type="Integer" default="80" name="%PORT_NUMBER" description="%PORT_NUMBER_DESC" cardinality="0" min="0" max="65535"/>
- <AD id="http.timeout" type="Integer" default="30" name="%THREAD_TIMEOUT" description="%THREAD_TIMEOUT_DESC" cardinality="0" min="0" max="600" />
- <AD id="service.ranking" type="Integer" default="0" name="%SERVICE_RANKING" description="%SERVICE_RANKING_DESC" cardinality="0"/>
- </OCD>
- <Designate pid="org.eclipse.equinox.http.Http">
- <Object ocdref="org.eclipse.equinox.http.Http"/>
- </Designate>
- <Designate pid="org.eclipse.equinox.http.HttpFactory" factoryPid="org.eclipse.equinox.http.HttpFactory">
- <Object ocdref="org.eclipse.equinox.http.HttpFactory"/>
- </Designate>
-</metatype:MetaData>
diff --git a/bundles/org.eclipse.equinox.http/about.html b/bundles/org.eclipse.equinox.http/about.html
deleted file mode 100644
index b2f1e6bad..000000000
--- a/bundles/org.eclipse.equinox.http/about.html
+++ /dev/null
@@ -1,22 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
-<!-- saved from url=(0043)http://www.eclipse.org/legal/epl/about.html -->
-<HTML><HEAD><TITLE>About</TITLE>
-<META http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-<META content="MSHTML 6.00.2800.1498" name=GENERATOR></HEAD>
-<BODY lang=EN-US>
-<H2>About This Content</H2>
-<P>February 24, 2005</P>
-<H3>License</H3>
-<P>The Eclipse Foundation makes available all content in this plug-in
-("Content"). Unless otherwise indicated below, the Content is provided to you
-under the terms and conditions of the Eclipse Public License Version 1.0
-("EPL"). A copy of the EPL is available at <A
-href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</A>.
-For purposes of the EPL, "Program" will mean the Content.</P>
-<P>If you did not receive this Content directly from the Eclipse Foundation, the
-Content is being redistributed by another party ("Redistributor") and different
-terms and conditions may apply to your use of any object code in the Content.
-Check the Redistributor's license that was provided with the Content. If no such
-license exists, contact the Redistributor. Unless otherwise indicated below, the
-terms and conditions of the EPL still apply to any source code in the
-Content.</P></BODY></HTML>
diff --git a/bundles/org.eclipse.equinox.http/build.properties b/bundles/org.eclipse.equinox.http/build.properties
deleted file mode 100644
index 873261924..000000000
--- a/bundles/org.eclipse.equinox.http/build.properties
+++ /dev/null
@@ -1,17 +0,0 @@
-###############################################################################
-# Copyright (c) 2005 IBM Corporation.
-# 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:
-# IBM Corporation - initial API and implementation
-###############################################################################
-bin.includes = META-INF/,\
- plugin*.properties,\
- about.html,\
- .
-src.includes = about.html
-source.. = src/
-output.. = bin/
diff --git a/bundles/org.eclipse.equinox.http/plugin.properties b/bundles/org.eclipse.equinox.http/plugin.properties
deleted file mode 100644
index ad0e815c1..000000000
--- a/bundles/org.eclipse.equinox.http/plugin.properties
+++ /dev/null
@@ -1,13 +0,0 @@
-###############################################################################
-# Copyright (c) 2005 IBM Corporation.
-# 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:
-# IBM Corporation - initial API and implementation
-###############################################################################
-bundleVendor = Eclipse.org
-bundleName = HTTP Service
-bundleCopyright = Copyright (c) IBM Corp. 1999, 2005
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/Activator.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/Activator.java
deleted file mode 100644
index 013288d5e..000000000
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/Activator.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1999, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.http;
-
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-
-/**
- */
-
-public class Activator implements BundleActivator {
- /*
- * ----------------------------------------------------------------------
- * BundleActivator Interface implementation
- * ----------------------------------------------------------------------
- */
-
- private Http http = null;
-
- /**
- * Required by BundleActivator Interface.
- */
- public void start(BundleContext context) throws Exception {
- http = new Http(context);
- http.start();
- }
-
- /**
- * Required by BundleActivator Interface.
- */
- public void stop(BundleContext context) throws Exception {
- http.stop();
- http.close();
- http = null;
- }
-}
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/DefaultHttpContext.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/DefaultHttpContext.java
deleted file mode 100644
index e63e4f137..000000000
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/DefaultHttpContext.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1999, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.http;
-
-import java.io.IOException;
-import java.net.URL;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import org.osgi.framework.Bundle;
-import org.osgi.service.http.HttpContext;
-
-public class DefaultHttpContext implements HttpContext {
-
- protected Bundle bundle;
- protected HttpSecurityTracker securityTracker;
-
- public DefaultHttpContext(Bundle bundle, HttpSecurityTracker securityTracker) {
- this.bundle = bundle;
- this.securityTracker = securityTracker;
- }
-
- /* Implementation defined behavior */
- public boolean handleSecurity(HttpServletRequest request, HttpServletResponse response) throws IOException {
- return securityTracker.handleSecurity(request, response);
- }
-
- /* Behavior defined by OSGi spec */
- public URL getResource(String name) {
- return (new SecureAction()).getBundleResource(bundle, name);
- }
-
- /* Behavior defined by OSGi spec */
- public String getMimeType(String name) {
- return null;
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/ExternalMessages.properties b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/ExternalMessages.properties
deleted file mode 100644
index 31f47d9f7..000000000
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/ExternalMessages.properties
+++ /dev/null
@@ -1,59 +0,0 @@
-###############################################################################
-# Copyright (c) 2005 IBM Corporation.
-# 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:
-# IBM Corporation - initial API and implementation
-###############################################################################
-# NLS_MESSAGEFORMAT_ALL
-
-HTTP_ALIAS_ALREADY_REGISTERED_EXCEPTION=Alias {0} is already registered
-HTTP_SERVLET_ALREADY_REGISTERED_EXCEPTION=This servlet object has already been registered under a different alias
-HTTP_SERVLET_NULL_EXCEPTION=This servlet object is null.
-HTTP_SERVLET_EXCEPTION=Servlet Exception
-HTTP_ALIAS_UNREGISTER_EXCEPTION=Alias could not be unregistered
-HTTP_ALIAS_INVALID_EXCEPTION=Invalid alias {0} alias must start with a '/' but not end with a '/'
-HTTP_RESOURCE_NAME_INVALID_EXCEPTION=Invalid resource name {0} name must not end with a '/'
-HTTP_SERVET_INIT_EXCEPTION=Servlet init exception
-HTTP_DEFAULT_MIME_TABLE_ERROR=An error occured processing the default MIME table
-HTTP_STATUS_CODES_TABLE_ERROR=An error occured processing the status codes table
-HTTP_STATUS_CODE_NOT_FOUND=Unsupported
-HTTP_ACCEPT_SOCKET_EXCEPTION=Error while waiting on port {0}
-HTTP_PORT_IN_USE_EXCEPTION=Port {0} is use
-HTTP_INVALID_VALUE_RANGE_EXCEPTION=Value must be between {0} and {1}
-HTTP_CONNECTION_EXCEPTION=Error handling connection
-HTTP_INVALID_SCHEME_EXCEPTION=The scheme {0} is not supported
-HTTP_NO_HEADER_LINE_READ_EXCEPTION=No header line was read
-HTTP_QUERYDATA_PARSE_EXCEPTION=Exception parsing query data
-HTTP_INVALID_HEADER_LINE_EXCEPTION=Invalid header line: {0}
-HTTP_HEADER_LINE_TOO_LONG_EXCEPTION=Header line was larger than buffer size: {0}
-HTTP_UNEXPECTED_IOEXCEPTION=An unexpected IOException occurred
-HTTP_UNEXPECTED_RUNTIMEEXCEPTION=An unexpected RuntimeException occurred
-HTTP_ONLY_SUPPORTS_2_1=HttpService only supports servlet 2.1 specification.
-HTTP_HOST_UNKNOWN=The host address "{0}" is unknown. Defaulting to all IP addresses.
-OSGi_Http_Service_IBM_Implementation_16=OSGi Http Service - IBM Implementation
-IBM_Http_Service_37=IBM Http Service
-Jan_1=Jan
-Feb_2=Feb
-Mar_3=Mar
-Apr_4=Apr
-May_5=May
-Jun_6=Jun
-Jul_7=Jul
-Aug_8=Aug
-Sep_9=Sep
-Oct_10=Oct
-Nov_11=Nov
-Dec_12=Dec
-Sun_13=Sun
-Mon_14=Mon
-Tue_15=Tue
-Wed_16=Wed
-Thu_17=Thu
-Fri_18=Fri
-Sat_19=Sat
-HTTP_DEFAULT_PORT_FORMAT_EXCEPTION={0} value is not an integer
-HTTP_THREAD_POOL_CREATE_NUMBER_ERROR=Failed to create thread number {0} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/Http.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/Http.java
deleted file mode 100644
index 0d74aa0e9..000000000
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/Http.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1999, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.http;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.util.Hashtable;
-import java.util.Vector;
-import org.eclipse.equinox.http.servlet.HttpSessionImpl;
-import org.eclipse.equinox.socket.ServerSocketInterface;
-import org.eclipse.equinox.socket.https.HttpsServerSocket;
-import org.eclipse.osgi.util.NLS;
-import org.osgi.framework.BundleContext;
-import org.osgi.service.log.LogService;
-
-public class Http {
- public static final boolean DEBUG = false;
- BundleContext context;
- private LogTracker log = null;
-
- protected HttpConfiguration configuration;
-
- /** Mapping of Session ID (String) => HttpSessionImpl */
- protected Hashtable sessions;
-
- protected Vector servlets;
- protected StaticDataReader dataReader;
-
- HttpSecurityTracker securityTracker;
-
- protected Http(BundleContext context) throws Exception {
- this.context = context;
-
- initialize();
- }
-
- /**
- * Initializes fields.
- * <p>
- * Added for subclassing purposes
- */
- protected void initialize() throws Exception {
- log = new LogTracker(context, System.out);
-
- securityTracker = new HttpSecurityTracker(context);
-
- servlets = new Vector(15);
-
- //initialize sessions Hashtable
- sessions = new Hashtable(15);
-
- //get a MIMETypes object to compute MIMETypes
- dataReader = new StaticDataReader(this);
- }
-
- protected void start() throws Exception {
- if (Http.DEBUG) {
- logDebug("Starting Http Service bundle"); //$NON-NLS-1$
- }
-
- try {
- configuration = new HttpConfiguration(this);
- } catch (IOException e) {
- logError("Http Service failed to start -- HALTING", e); //$NON-NLS-1$
- stop();
- throw e;
- }
-
- if (Http.DEBUG) {
- logInfo("Http Service started"); //$NON-NLS-1$
- }
- }
-
- protected void stop() {
- if (Http.DEBUG) {
- logDebug("Stopping Http Service bundle"); //$NON-NLS-1$
- }
-
- if (configuration != null) {
- configuration.close();
- configuration = null;
- }
-
- if (Http.DEBUG) {
- logDebug("Http Service stopped"); //$NON-NLS-1$
- }
- }
-
- protected void close() {
-
- if (securityTracker != null) {
- securityTracker.close();
- securityTracker = null;
- }
-
- if (log != null) {
- log.close();
- log = null;
- }
- }
-
- /**
- * @param session javax.servlet.http.HttpSession
- */
- public void addSession(HttpSessionImpl session) {
- sessions.put(session.getId(), session);
- }
-
- public void removeSession(HttpSessionImpl session) {
- sessions.remove(session.getId());
- }
-
- /**
- * Returns a valid session from the cache.
- *
- * @param id ID of requested session.
- * @return Valid session object.
- */
- public HttpSessionImpl getSession(String id) {
- HttpSessionImpl session = (HttpSessionImpl) sessions.get(id);
-
- if ((session != null) && (session.isValid(true))) {
- return (session); /* session is valid */
- }
- /* session is null or invalid and has removed itself from the cache */
-
- return (null);
- }
-
- /**
- * @return MIMETypes
- */
- public String getMimeType(String name) {
- return (dataReader.computeMimeType(name));
- }
-
- /**
- * @return java.lang.String
- * @param statusCode java.lang.String
- */
- public String getStatusPhrase(int statusCode) {
- return (dataReader.computeStatusPhrase(statusCode));
- }
-
- public void logDebug(String message) {
- if (Http.DEBUG) {
- System.out.println(message);
-
- log.log(LogService.LOG_DEBUG, message);
- }
- }
-
- public void logDebug(String message, Throwable t) {
- if (Http.DEBUG) {
- System.out.println(message);
- t.printStackTrace(System.out);
-
- log.log(LogService.LOG_DEBUG, message, t);
- }
- }
-
- public void logError(String message, Throwable t) {
- if (Http.DEBUG) {
- System.out.println(message);
- t.printStackTrace(System.out);
- }
-
- log.log(LogService.LOG_ERROR, message, t);
- }
-
- public void logInfo(String message) {
- if (Http.DEBUG) {
- System.out.println(message);
- }
-
- log.log(LogService.LOG_INFO, message);
- }
-
- public void logWarning(String message, Throwable t) {
- if (Http.DEBUG) {
- System.out.println(message);
- t.printStackTrace(System.out);
- }
-
- log.log(LogService.LOG_WARNING, message, t);
- }
-
- protected ServerSocketInterface createSSLServerSocket(int port, int backlog, InetAddress address) throws IOException {
- HttpsServerSocket socket;
- try {
- socket = new HttpsServerSocket(context, port, backlog, address);
- } catch (UnsupportedOperationException ex) {
- throw new IOException(NLS.bind(HttpMsg.HTTP_INVALID_SCHEME_EXCEPTION, "https")); //$NON-NLS-1$
- }
- return (socket);
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpConfiguration.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpConfiguration.java
deleted file mode 100644
index b65baa00f..000000000
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpConfiguration.java
+++ /dev/null
@@ -1,581 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1999, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.http;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.security.*;
-import java.util.*;
-import org.eclipse.equinox.socket.ServerSocketInterface;
-import org.eclipse.osgi.util.NLS;
-import org.osgi.framework.*;
-import org.osgi.service.cm.*;
-
-/**
- * This class is the main configuration class for Http Service. It creates the
- * thread pool and the listeners and responds to configuration changes.
- */
-
-public class HttpConfiguration implements ManagedService, ManagedServiceFactory {
-
- /** default HttpListener object for 'http' protocol
- * This object is set if ConfigurationAdmin has NOT configured any
- * HttpListeners and we are not waiting to be configured.
- */
- private HttpListener defaultHttpListener;
- /** default HttpListener object for 'https' protocol
- * This object is set if ConfigurationAdmin has NOT configured any
- * HttpListeners and we are not waiting to be configured.
- */
- private HttpListener defaultHttpsListener;
- /** Hashtable of HttpListener object configured by the ConfigurationAdmin
- * Configuration PID (String) => HttpListener object
- */
- Hashtable configuredListeners;
-
- protected Http http;
-
- protected HttpThreadPool pool;
-
- protected final static String enviroKeyHttpPort = "org.osgi.service.http.port"; //$NON-NLS-1$
- protected final static String enviroKeyHttpsPort = "org.osgi.service.http.port.secure"; //$NON-NLS-1$
- protected final static String enviroKeyHttpAddress = "org.eclipse.equinox.http.address"; //$NON-NLS-1$
-
- protected final static String HTTPSERVICEPID = "org.eclipse.equinox.http.Http"; //$NON-NLS-1$
- protected ServiceRegistration managedService;
- protected final static String HTTPSERVICEFACTORYPID = "org.eclipse.equinox.http.HttpFactory"; //$NON-NLS-1$
- protected ServiceRegistration managedServiceFactory;
-
- protected final static String keyHttpMinThreads = "http.minThreads"; //$NON-NLS-1$
- protected final static String keyHttpMaxThreads = "http.maxThreads"; //$NON-NLS-1$
- protected final static String keyHttpThreadPriority = "http.threadPriority"; //$NON-NLS-1$
- protected final static String keyHttpAddress = "http.address"; //$NON-NLS-1$
- protected final static String keyHttpPort = "http.port"; //$NON-NLS-1$
- protected final static String keyHttpScheme = "http.scheme"; //$NON-NLS-1$
- protected final static String keyHttpTimeout = "http.timeout"; //$NON-NLS-1$
-
- protected static final int DEFAULT_MINTHREADS = 4;
- protected static final int DEFAULT_MAXTHREADS = 20;
- protected static final int DEFAULT_THREADPRIOTRITY = Thread.NORM_PRIORITY;
- protected static String DEFAULT_HTTP_ADDRESS = "ALL"; //$NON-NLS-1$
- protected static int DEFAULT_HTTP_PORT = 80;
- protected static int DEFAULT_HTTPS_PORT = 443;
- protected static final int DEFAULT_TIMEOUT = 30;
-
- /** Current minimum number of threads in the thread pool */
- private int minThreads = DEFAULT_MINTHREADS;
- /** Current maximum number of threads in the thread pool */
- private int maxThreads = DEFAULT_MAXTHREADS;
- /** Current priority of the the threads in the thread pool */
- private int threadPriority = DEFAULT_THREADPRIOTRITY;
-
- private boolean active;
-
- /**
- * Constructor - create the Http Configuration object and start it.
- */
- protected HttpConfiguration(Http http) throws IOException {
- this.http = http;
- active = true;
-
- initialize();
- }
-
- /**
- * Initializes fields.
- * <p>
- */
- protected void initialize() {
- setDefaultPorts();
- /* Create configured listeners before thread pool
- * in case we exceed the number of threads */
- configuredListeners = new Hashtable(7);
- synchronized (configuredListeners) {
- createDefaultListeners();
- }
-
- pool = new HttpThreadPool(http, minThreads, maxThreads, threadPriority);
-
- registerManagedService();
- registerManagedServiceFactory();
- }
-
- protected void registerManagedService() {
- /* Register a Managed Service to handle updates to the general configuration values */
- Hashtable properties = new Hashtable(7);
-
- properties.put(Constants.SERVICE_VENDOR, "IBM"); //$NON-NLS-1$
- properties.put(Constants.SERVICE_DESCRIPTION, HttpMsg.OSGi_Http_Service_IBM_Implementation_16);
- properties.put(Constants.SERVICE_PID, HTTPSERVICEPID);
-
- managedService = http.context.registerService(ManagedService.class.getName(), this, properties);
- }
-
- protected void registerManagedServiceFactory() {
- /* Register a Managed Service Factory to handle updates to the unique configuration values */
- Hashtable properties = new Hashtable(7);
-
- properties.put(Constants.SERVICE_VENDOR, "IBM"); //$NON-NLS-1$
- properties.put(Constants.SERVICE_DESCRIPTION, HttpMsg.OSGi_Http_Service_IBM_Implementation_16);
- properties.put(Constants.SERVICE_PID, HTTPSERVICEFACTORYPID);
-
- managedServiceFactory = http.context.registerService(ManagedServiceFactory.class.getName(), this, properties);
- }
-
- /**
- * Create default Http Listeners if requested.
- * <p>
- */
- protected void createDefaultListeners() {
- if (DEFAULT_HTTP_PORT != -1) {
- try {
- defaultHttpListener = new HttpListener(http, this, createProperties(DEFAULT_HTTP_ADDRESS, DEFAULT_HTTP_PORT, "http", 30));//$NON-NLS-1$
- } catch (IOException e) {
- http.logError(HttpMsg.HTTP_UNEXPECTED_IOEXCEPTION, e);
- http.logError(HttpMsg.HTTP_UNEXPECTED_RUNTIMEEXCEPTION, e);
- }
- }
-
- }
-
- /**
- * Close default Http Listeners if present.
- * <p>
- */
- protected void closeDefaultListeners() {
- if (defaultHttpListener != null) {
- defaultHttpListener.close();
- defaultHttpListener = null;
- }
-
- if (defaultHttpsListener != null) {
- defaultHttpsListener.close();
- defaultHttpsListener = null;
- }
- }
-
- /**
- * Create default Http Listeners if requested.
- * <p>
- */
- protected void setDefaultPorts() {
- BundleContext context = http.context;
-
- String property = context.getProperty(enviroKeyHttpPort);
- if (property != null) {
- try {
- DEFAULT_HTTP_PORT = Integer.parseInt(property);
- } catch (NumberFormatException e) {
- http.logWarning(NLS.bind(HttpMsg.HTTP_DEFAULT_PORT_FORMAT_EXCEPTION, enviroKeyHttpPort), e);
- }
- }
-
- property = context.getProperty(enviroKeyHttpsPort);
- if (property != null) {
- try {
- DEFAULT_HTTPS_PORT = Integer.parseInt(property);
- } catch (NumberFormatException e) {
- http.logWarning(NLS.bind(HttpMsg.HTTP_DEFAULT_PORT_FORMAT_EXCEPTION, enviroKeyHttpsPort), e);
- }
- }
-
- DEFAULT_HTTP_ADDRESS = context.getProperty(enviroKeyHttpAddress);
- if (DEFAULT_HTTP_ADDRESS == null) {
- DEFAULT_HTTP_ADDRESS = "ALL"; //$NON-NLS-1$
- }
- }
-
- protected Dictionary createProperties(String address, int port, String scheme, int socketTimeout) {
- Hashtable properties = new Hashtable(31);
-
- properties.put(Constants.SERVICE_VENDOR, "IBM"); //$NON-NLS-1$
- properties.put(Constants.SERVICE_DESCRIPTION, HttpMsg.OSGi_Http_Service_IBM_Implementation_16);
- properties.put(Constants.SERVICE_PID, "org.eclipse.equinox.http.HttpService-" + scheme); //$NON-NLS-1$
- properties.put(keyHttpAddress, address);
- properties.put(keyHttpPort, new Integer(port));
- properties.put(keyHttpScheme, scheme);
- properties.put(keyHttpTimeout, new Integer(socketTimeout));
-
- return (properties);
- }
-
- protected ServerSocketInterface createServerSocket(String address, int port, String scheme) throws IOException {
- InetAddress netAddress = null;
- if (address != null) {
- try {
- netAddress = InetAddress.getByName(address);
- } catch (UnknownHostException uhe) {
- http.logWarning(NLS.bind(HttpMsg.HTTP_HOST_UNKNOWN, address), uhe);
- }
- }
- if ("http".equalsIgnoreCase(scheme)) //$NON-NLS-1$
- {
- try {
- ServerSocketInterface ssi = new HttpServerSocket(port, 50, netAddress);
- ssi.setAddress(address);
- return ssi;
- } catch (IOException e) {
- http.logError(NLS.bind(HttpMsg.HTTP_PORT_IN_USE_EXCEPTION, new Integer(port)), e);
-
- throw e;
- }
- }
-
- if ("https".equalsIgnoreCase(scheme)) //$NON-NLS-1$
- {
- try {
- ServerSocketInterface ssi = http.createSSLServerSocket(port, 50, netAddress);
- ssi.setAddress(address);
- return ssi;
- } catch (IOException e) {
- http.logError(NLS.bind(HttpMsg.HTTP_PORT_IN_USE_EXCEPTION, new Integer(port)), e);
-
- throw e;
- }
- }
-
- throw new IOException(NLS.bind(HttpMsg.HTTP_INVALID_SCHEME_EXCEPTION, scheme));
- }
-
- void close() {
- active = false;
-
- managedService.unregister();
-
- managedServiceFactory.unregister();
-
- if (defaultHttpListener != null) {
- defaultHttpListener.close();
- defaultHttpListener = null;
- }
-
- if (defaultHttpsListener != null) {
- defaultHttpsListener.close();
- defaultHttpsListener = null;
- }
-
- Enumeration listeners = configuredListeners.elements();
- while (listeners.hasMoreElements()) {
- HttpListener listener = (HttpListener) listeners.nextElement();
-
- listener.close();
- }
-
- pool.close();
- pool = null;
- }
-
- /**
- * Return a descriptive name of this ManagedServiceFactory.
- *
- * @return the name for the factory, which might be localized
- */
- public String getName() {
- return HttpMsg.IBM_Http_Service_37;
- }
-
- /**
- * Create a new instance, or update the configuration of an
- * existing instance.
- *
- * If the PID of the <tt>Configuration</tt> object is new for the Managed Service Factory,
- * then create a new factory instance, using the configuration
- * <tt>properties</tt> provided. Else, update the service instance with the
- * provided <tt>properties</tt>.
- *
- * <p>If the factory instance is registered with the Framework, then
- * the configuration <tt>properties</tt> should be copied to its registry
- * properties. This is not mandatory and
- * security sensitive properties should obviously not be copied.
- *
- * <p>If this method throws any <tt>Exception</tt>, the
- * Configuration Admin service must catch it and should log it.
- *
- * <p>When the implementation of updated detects any kind of
- * error in the configuration properties, it should create a
- * new {@Link ConfigurationException}which describes the problem.
- *
- * <p>The Configuration Admin service must call this method on a thread
- * other than the thread which necessitated the callback. This implies that
- * implementors of the <tt>ManagedServiceFactory</tt> class can be assured that the
- * callback will not take place during registration when they
- * execute the registration in a synchronized method.
- *
- * @param pid the PID for this configuration
- * @param properties the configuration properties
- * @throws ConfigurationException when the configuration properties are invalid
- */
- public void updated(final String pid, final Dictionary properties) throws ConfigurationException {
- if (active) {
- String address = DEFAULT_HTTP_ADDRESS;
- int port = DEFAULT_HTTP_PORT;
- String scheme = "http"; //$NON-NLS-1$
- int timeout = DEFAULT_TIMEOUT;
-
- /* Get configuration values and validate */
- String key = keyHttpPort;
- Object portProperty = properties.get(key);
- if (portProperty != null) /* if null we will just use the default */
- {
- if (!(portProperty instanceof Integer)) {
- throw new ConfigurationException(key, "not an Integer"); //$NON-NLS-1$
- }
-
- port = ((Integer) portProperty).intValue();
-
- if ((port < 0) || (port > 65535)) {
- throw new ConfigurationException(key, "must be in the range 0-65535"); //$NON-NLS-1$
- }
- }
-
- key = keyHttpScheme;
- Object schemeProperty = properties.get(key);
- if (schemeProperty != null) /* if null we will just use the default */
- {
- if (!(schemeProperty instanceof String)) {
- throw new ConfigurationException(key, "not an String"); //$NON-NLS-1$
- }
-
- scheme = (String) schemeProperty;
-
- if (!(scheme.equals("http") || scheme.equals("https"))) //$NON-NLS-1$ //$NON-NLS-2$
- {
- throw new ConfigurationException(key, "must be either http or https"); //$NON-NLS-1$
- }
- }
-
- key = keyHttpAddress;
- Object addressProperty = properties.get(key);
- if (addressProperty != null) /* if null we will just use the default */
- {
- if (!(addressProperty instanceof String)) {
- throw new ConfigurationException(key, "not an String"); //$NON-NLS-1$
- }
-
- address = (String) addressProperty;
- }
-
- key = keyHttpTimeout;
- Object timeoutProperty = properties.get(key);
- if (timeoutProperty != null) /* if null we will just use the default */
- {
- if (!(timeoutProperty instanceof Integer)) {
- throw new ConfigurationException(key, "not an Integer"); //$NON-NLS-1$
- }
-
- timeout = ((Integer) timeoutProperty).intValue();
-
- if ((timeout < 0) || (timeout > 600)) {
- throw new ConfigurationException(key, "must be in the range 0-600"); //$NON-NLS-1$
- }
- }
-
- if (schemeProperty == null) {
- if (port == DEFAULT_HTTPS_PORT) {
- scheme = "https"; //$NON-NLS-1$
- }
- } else {
- if (portProperty == null) {
- if (scheme.equals("https")) //$NON-NLS-1$
- {
- port = DEFAULT_HTTPS_PORT;
- }
- }
- }
-
- if (addressProperty == null) {
- properties.put(keyHttpAddress, address);
- }
- if (schemeProperty == null) {
- properties.put(keyHttpScheme, scheme);
- }
- if (portProperty == null) {
- properties.put(keyHttpPort, new Integer(port));
- }
- if (timeoutProperty == null) {
- properties.put(keyHttpTimeout, new Integer(timeout));
- }
-
- properties.remove("service.bundleLocation"); /* Don't want to publish this! *///$NON-NLS-1$
- properties.put(Constants.SERVICE_VENDOR, "IBM"); //$NON-NLS-1$
- properties.put(Constants.SERVICE_DESCRIPTION, HttpMsg.OSGi_Http_Service_IBM_Implementation_16);
-
- /* Configuration values have been validated */
- synchronized (configuredListeners) {
- try {
- AccessController.doPrivileged(new PrivilegedExceptionAction() {
- public Object run() throws ConfigurationException {
- if (configuredListeners.size() == 0) {
- closeDefaultListeners();
- }
-
- HttpListener listener = (HttpListener) configuredListeners.get(pid);
-
- try {
- if (listener != null) {
- listener.setProperties(properties);
- } else {
- listener = new HttpListener(http, HttpConfiguration.this, properties);
-
- configuredListeners.put(pid, listener);
- }
- } catch (IOException e) {
- http.logError(HttpMsg.HTTP_UNEXPECTED_IOEXCEPTION, e);
-
- if (configuredListeners.size() == 0) {
- createDefaultListeners();
- }
-
- throw new ConfigurationException(null, e.getMessage());
- }
-
- return null;
- }
- });
- } catch (PrivilegedActionException pae) {
- throw (ConfigurationException) pae.getException();
- }
- }
- }
- }
-
- /**
- * Remove a factory instance.
- *
- * Remove the factory instance associated with the PID. If the instance was
- * registered with the service registry, it should be unregistered.
- * <p>If this method throws any <tt>Exception</tt>, the Configuration Admin
- * service must catch it and should log it.
- * <p> The Configuration Admin service must call this method on a thread
- * other than the thread which called <tt>delete()</tt> on the corresponding
- * <tt>Configuration</tt> object.
- *
- * @param pid the PID of the service to be removed
- */
- public void deleted(final String pid) {
- if (active) {
- synchronized (configuredListeners) {
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- HttpListener listener = (HttpListener) configuredListeners.remove(pid);
-
- if (listener != null) {
- listener.close();
- }
-
- if (configuredListeners.size() == 0) {
- createDefaultListeners();
- }
-
- return null;
- }
- });
- }
- }
- }
-
- /**
- * Update the configuration for a Managed Service.
- *
- * <p>When the implementation of <tt>updated(Dictionary)</tt> detects any kind of
- * error in the configuration properties, it should create a
- * new <tt>ConfigurationException</tt> which describes the problem. This
- * can allow a management system to provide useful information to
- * a human administrator.
- *
- * <p>If this method throws any other <tt>Exception</tt>, the
- * Configuration Admin service must catch it and should log it.
- * <p> The Configuration Admin service must call this method on a thread
- * other than the thread which initiated the callback. This
- * implies that implementors of Managed Service can be assured
- * that the callback will not take place during registration
- * when they execute the registration in a synchronized method.
- *
- * @param properties configuration properties, or <tt>null</tt>
- * @throws ConfigurationException when the update fails
- */
- public void updated(Dictionary properties) throws ConfigurationException {
- /* Since updated is called asynchronously, we may have stopped
- * after the decision was made to call.
- */
- if (active) {
- if (properties == null) {
- /* We have no configuration; we will just use our defaults */
- return;
- }
-
- int min = minThreads;
- int max = maxThreads;
- int priority = threadPriority;
-
- /* Get configuration values and validate */
- String key = keyHttpMinThreads;
- Object property = properties.get(key);
- if (property != null) /* if null we will just use the default */
- {
- if (!(property instanceof Integer)) {
- throw new ConfigurationException(key, "not an Integer"); //$NON-NLS-1$
- }
-
- min = ((Integer) property).intValue();
-
- if ((min < 0) || (min > 63)) {
- throw new ConfigurationException(key, "must be in the range 0-63"); //$NON-NLS-1$
- }
- }
-
- key = keyHttpMaxThreads;
- property = properties.get(key);
- if (property != null) /* if null we will just use the default */
- {
- if (!(property instanceof Integer)) {
- throw new ConfigurationException(key, "not an Integer"); //$NON-NLS-1$
- }
-
- max = ((Integer) property).intValue();
-
- if ((max < 0) || (max > 63)) {
- throw new ConfigurationException(key, "must be in the range 0-63"); //$NON-NLS-1$
- }
- }
-
- key = keyHttpThreadPriority;
- property = properties.get(key);
- if (property != null) /* if null we will just use the default */
- {
- if (!(property instanceof Integer)) {
- throw new ConfigurationException(key, "not an Integer"); //$NON-NLS-1$
- }
-
- priority = ((Integer) property).intValue();
-
- if ((priority < Thread.MIN_PRIORITY) || (priority > Thread.MAX_PRIORITY)) {
- throw new ConfigurationException(key, "must be one of the Thread defined priorities"); //$NON-NLS-1$
- }
- }
-
- /* Configuration values have been validated */
- if ((max != maxThreads) || (min != minThreads)) {
- pool.setSize(min, max);
-
- /* Get the values from the pool in case it adjusted them */
- minThreads = pool.getLowerSizeLimit();
- maxThreads = pool.getUpperSizeLimit();
- }
-
- if (priority != threadPriority) {
- pool.setPriority(priority);
- threadPriority = priority;
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpDate.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpDate.java
deleted file mode 100644
index dc9693f6a..000000000
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpDate.java
+++ /dev/null
@@ -1,388 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1999, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.http;
-
-import java.util.*;
-
-/**
- * <b>HTTPDate</b> provides several services with regards to dates and date formatting.
- */
-public class HttpDate {
-
- protected Calendar time;
- private boolean valid = true;
-
- private static final String[] MONTH_NAMES = {HttpMsg.Jan_1, HttpMsg.Feb_2, HttpMsg.Mar_3, HttpMsg.Apr_4, HttpMsg.May_5, HttpMsg.Jun_6, HttpMsg.Jul_7, HttpMsg.Aug_8, HttpMsg.Sep_9, HttpMsg.Oct_10, HttpMsg.Nov_11, HttpMsg.Dec_12};
- private static final String[] WEEK_DAYS = {HttpMsg.Sun_13, HttpMsg.Mon_14, HttpMsg.Tue_15, HttpMsg.Wed_16, HttpMsg.Thu_17, HttpMsg.Fri_18, HttpMsg.Sat_19};
-
- private static TimeZone gmt = null;
-
- /**
- * Constructs an HTTPDate object representing the current time.
- */
- public HttpDate() { // Now...
- if (gmt == null) {
- gmt = TimeZone.getTimeZone("GMT"); //$NON-NLS-1$
- }
- time = new GregorianCalendar(gmt);
- }
-
- /**
- * Constructs an HTTPDate object from the passed long.
- * @param itime the number of uSeconds since the epoch.
- */
- public HttpDate(long iTime) { // Raw mill seconds
- this();
- time.setTime(new Date(iTime));
- }
-
- /**
- * Constructs an HTTPDate object from an RFC compliant string.
- * @param iString the time in a formatted string.
- */
- public HttpDate(String iString) { // RFC2068 3.3.1 compliant
- this();
- if (iString.indexOf(",") > 0) //$NON-NLS-1$
- {
- if (iString.indexOf("-") > 0) //$NON-NLS-1$
- {
- parseRFC1036(iString);
- } else {
- parseRFC1123(iString);
- }
- } else { //asctime type
- parseASC(iString);
- }
- }
-
- /**
- * Constructs an HTTPDate object from the passed long.
- * @param itime the number of uSeconds since the epoch.
- */
- public HttpDate(Date iTime) { // Raw mill seconds
- this();
- time.setTime(iTime);
- }
-
- /**
- * Returns the Date/Time time as an RFC 1123 formatted String
- */
- public static String format(long time) {
- return (new HttpDate(time).toString());
- }
-
- protected void formatDoubleDigit(StringBuffer buff, int val) {
- if (val < 10) {
- buff.append('0');
- }
-
- buff.append(val);
- }
-
- /**
- * Returns the time represented as a long. This represents the number
- * of uSeconds since the epoch.
- * @return the time represented as a long.
- */
- public long getAsLong() {
- return (time.getTime().getTime());
- }
-
- /**
- * Returns the time represented as a string.
- * @return the time represented as a string.
- */
- public String getAsString() {
- return (toString());
- }
-
- /**
- * Returns the day of the month of the internal time, starting at 1
- * @return the day of the month.
- */
- public int getDay() {
- return (time.get(Calendar.DATE));
- }
-
- /**
- * Returns the day of the week of the internal time.
- * The number is in the range of 0 to 6 where 0 represents Sunday.
- * @return the day of the week.
- */
- public int getDayOfWeek() {
- return (time.get(Calendar.DAY_OF_WEEK) - 1);
- }
-
- /**
- * Returns the hour of the day of the internal time. 24 Hour time
- * @return the hour.
- */
- public int getHour() {
- return (time.get(Calendar.HOUR_OF_DAY));
- }
-
- /**
- * Returns the minute of the hour of the internal time.
- * @return the minute.
- */
- public int getMin() {
- return (time.get(Calendar.MINUTE));
- }
-
- /**
- * Returns the month of the year of the internal time.
- * The number is in the range of 0 to 11 where 0 represents January.
- * @return the month of the year.
- */
- public int getMonth() {
- return (time.get(Calendar.MONTH));
- }
-
- /**
- * Returns the second of the minute of the internal time.
- * @return the second.
- */
- public int getSec() {
- return (time.get(Calendar.SECOND));
- }
-
- /**
- * Returns the year of the internal time.
- * @return the year.
- */
- public int getYear() {
- return (time.get(Calendar.YEAR));
- }
-
- /**
- * Checks wether or not the Date this object represents is valid.
- * It would be Invalid if the string used to construct the object was a NON
- * RFC 1123, 1036 or ASC Time conforming Date String.
- * @return true if this object represents a REAL date.
- */
- public boolean isValid() {
- return (valid);
- }
-
- protected int locateMonth(String monthString) throws NumberFormatException {
- for (int i = 0; i < 12; i++) {
- if (MONTH_NAMES[i].equals(monthString)) {
- return (i);
- }
- }
- throw new NumberFormatException("Invalid month: " + monthString); //$NON-NLS-1$
- }
-
- /**
- * Returns the current Date/Time as an RFC ASC Time formatted String
- */
- public static String now() {
- return (new HttpDate().toString());
- }
-
- protected void parseASC(String str) {
- //ASCTIMEFMT = "EEE MMM dD HH:MM:SS YYYY"
- // 012345678901234567890123
-
- int day, month, year, hour, min, sec;
-
- parsedate: try {
- /* ignore day */
-
- if (str.charAt(3) != ' ') {
- break parsedate;
- }
-
- month = locateMonth(str.substring(4, 7));
-
- if (str.charAt(7) != ' ') {
- break parsedate;
- }
-
- if (str.charAt(8) == ' ') {
- day = Integer.parseInt(str.substring(9, 10));
- } else {
- day = Integer.parseInt(str.substring(8, 10));
- }
-
- if (str.charAt(10) != ' ') {
- break parsedate;
- }
-
- hour = Integer.parseInt(str.substring(11, 13));
-
- if (str.charAt(13) != ':') {
- break parsedate;
- }
-
- min = Integer.parseInt(str.substring(14, 16));
-
- if (str.charAt(16) != ':') {
- break parsedate;
- }
-
- sec = Integer.parseInt(str.substring(17, 19));
-
- if (str.charAt(19) != ' ') {
- break parsedate;
- }
-
- year = Integer.parseInt(str.substring(20));
-
- time.set(year, month, day, hour, min, sec);
- return;
- } catch (NumberFormatException e) {
- valid = false;
- }
- }
-
- protected void parseRFC1036(String str) {
- //RFC1036DATEFMT = "EEEE, DD-MMM-YY HH:MM:SS ZZZ"
- // 0123456789012345678901
-
- int day, month, year, hour, min, sec;
- parsedate: try {
- /* skip past day */
-
- int i = str.indexOf(", "); //$NON-NLS-1$
-
- if (i == -1) {
- break parsedate;
- }
-
- str = str.substring(i + 2);
-
- day = Integer.parseInt(str.substring(0, 2));
-
- if (str.charAt(2) != '-') {
- break parsedate;
- }
-
- month = locateMonth(str.substring(3, 6));
-
- if (str.charAt(6) != '-') {
- break parsedate;
- }
-
- year = Integer.parseInt(str.substring(7, 9));
- year += (year < 70) ? 2000 : 1900; /* y2k window */
-
- if (str.charAt(9) != ' ') {
- break parsedate;
- }
-
- hour = Integer.parseInt(str.substring(10, 12));
-
- if (str.charAt(12) != ':') {
- break parsedate;
- }
-
- min = Integer.parseInt(str.substring(13, 15));
-
- if (str.charAt(15) != ':') {
- break parsedate;
- }
-
- sec = Integer.parseInt(str.substring(16, 18));
-
- if (str.charAt(18) != ' ') {
- break parsedate;
- }
-
- time.set(year, month, day, hour, min, sec);
- } catch (NumberFormatException e) {
- valid = false;
- }
- }
-
- protected void parseRFC1123(String str) {
- //RFC1123DATEFMT = "EEE, DD MMM YYYY HH:MM:SS ZZZ"
- // 01234567890123456789012345678
-
- int day, month, year, hour, min, sec;
-
- parsedate: try {
- /* ignore day */
-
- if ((str.charAt(3) != ',') || (str.charAt(4) != ' ')) {
- break parsedate;
- }
-
- day = Integer.parseInt(str.substring(5, 7));
-
- if (str.charAt(7) != ' ') {
- break parsedate;
- }
-
- month = locateMonth(str.substring(8, 11));
-
- if (str.charAt(11) != ' ') {
- break parsedate;
- }
-
- year = Integer.parseInt(str.substring(12, 16));
-
- if (str.charAt(16) != ' ') {
- break parsedate;
- }
-
- hour = Integer.parseInt(str.substring(17, 19));
-
- if (str.charAt(19) != ':') {
- break parsedate;
- }
-
- min = Integer.parseInt(str.substring(20, 22));
-
- if (str.charAt(22) != ':') {
- break parsedate;
- }
-
- sec = Integer.parseInt(str.substring(23, 25));
-
- if (str.charAt(25) != ' ') {
- break parsedate;
- }
-
- time.set(year, month, day, hour, min, sec);
- } catch (NumberFormatException e) {
- valid = false;
- }
-
-
- }
-
- /**
- * Returns the time represented as an RFC1123 string.
- * @return the time represented as a string.
- */
- public String toString() {
- StringBuffer buff = new StringBuffer(30);
- buff.append(WEEK_DAYS[getDayOfWeek()]);
- buff.append(", "); //$NON-NLS-1$
- formatDoubleDigit(buff, getDay());
- buff.append(' ');
- buff.append(MONTH_NAMES[getMonth()]);
- buff.append(' ');
- buff.append(getYear());
- buff.append(' ');
-
- formatDoubleDigit(buff, getHour());
- buff.append(':');
- formatDoubleDigit(buff, getMin());
- buff.append(':');
- formatDoubleDigit(buff, getSec());
- buff.append(' ');
- buff.append(time.getTimeZone().getID());
-
- return (buff.toString());
- }
-}
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpListener.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpListener.java
deleted file mode 100644
index c96f672bf..000000000
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpListener.java
+++ /dev/null
@@ -1,16 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1999, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.http; import java.io.IOException; import java.net.InetAddress; import java.net.Socket; import java.util.*; import javax.servlet.Servlet; import javax.servlet.ServletException; import javax.servlet.http.HttpServletResponse;
-
-import org.eclipse.equinox.http.servlet.*; import org.eclipse.equinox.socket.ServerSocketInterface; import org.eclipse.equinox.socket.SocketInterface; import org.eclipse.osgi.util.NLS; import org.osgi.framework.*; import org.osgi.service.http.HttpContext; import org.osgi.service.http.NamespaceException; public class HttpListener extends Thread implements ServiceFactory { protected Http http; /** ServerSocket upon which this listener operates */ protected volatile ServerSocketInterface serverSocket; /** Controlling HttpConfiguration object */ protected HttpConfiguration configuration; /** if true this thread must terminate */ protected volatile boolean running; protected ServiceRegistration service; private String httpsvcClass = "org.osgi.service.http.HttpService"; //$NON-NLS-1$ protected Hashtable registrations; /** Mapping of HttpContext => ServletContextImpl */ protected Hashtable servletContexts; protected int socketTimeout; protected Object lock = new Object(); /** * Constructor. * */ protected HttpListener(Http http, HttpConfiguration configuration, Dictionary properties) throws IOException { this.http = http; this.configuration = configuration; registrations = new Hashtable(51); //initialize servletContext Hashtable servletContexts = new Hashtable(15); setProperties(properties); start(); } /** * Returns true if this thread has been closed. * @return boolean */ public boolean isClosed() { return (!running); } /** * Close this thread. */ public void close() { running = false; try { setProperties(null); } catch (IOException e) { /* this will not occur when calling with null */ } servletContexts = null; } /* * ---------------------------------------------------------------------- * ServiceFactory Interface implementation * ---------------------------------------------------------------------- */ public Object getService(Bundle bundle, ServiceRegistration reg) { return (new HttpService(this, bundle)); } public void ungetService(Bundle bundle, ServiceRegistration reg, Object httpService) { ((HttpService) httpService).destroy(); } public synchronized void setProperties(Dictionary properties) throws IOException { ServerSocketInterface oldServerSocket = serverSocket; if (properties != null) { String address = (String) properties.get(HttpConfiguration.keyHttpAddress); int port = ((Integer) (properties.get(HttpConfiguration.keyHttpPort))).intValue(); String scheme = (String) properties.get(HttpConfiguration.keyHttpScheme); socketTimeout = ((Integer) (properties.get(HttpConfiguration.keyHttpTimeout))).intValue() * 1000; if ("ALL".equalsIgnoreCase(address)) { //$NON-NLS-1$ address = null; } if ((serverSocket == null) || (port != serverSocket.getLocalPort()) || !scheme.equals(serverSocket.getScheme())) { serverSocket = configuration.createServerSocket(address, port, scheme); closeServerSocket(oldServerSocket); } else if ((serverSocket.getAddress() != null && !serverSocket.getAddress().equals(address)) || (serverSocket.getAddress() == null && address != null)) { serverSocket = null; closeServerSocket(oldServerSocket); serverSocket = configuration.createServerSocket(address, port, scheme); synchronized (lock) { lock.notify(); } } if (service == null) { service = http.context.registerService(httpsvcClass, this, properties); } else { service.setProperties(properties); } } else { serverSocket = null; closeServerSocket(oldServerSocket); service.unregister(); service = null; } } protected Object getProperty(String key) { return service.getReference().getProperty(key); } private void closeServerSocket(ServerSocketInterface oldServerSocket) { if (oldServerSocket != null) { try { try { Socket phonyClient = new Socket(InetAddress.getByName(oldServerSocket.getAddress()), oldServerSocket.getLocalPort()); phonyClient.close(); } catch (IOException e) { http.logWarning(HttpMsg.HTTP_UNEXPECTED_IOEXCEPTION, e); } } finally { try { oldServerSocket.close(); } catch (IOException e) { http.logWarning(HttpMsg.HTTP_UNEXPECTED_IOEXCEPTION, e); } } configuration.pool.recallThreads(); } } public void run() { running = true; while (running) { SocketInterface socket = null; try { if (serverSocket == null) { if (running) { try { synchronized (lock) { lock.wait(5000); } } catch (InterruptedException e) {
- // ignore and check exit condition } if (serverSocket == null) { running = false; continue; } } else { continue; } } ServerSocketInterface tempServerSocket = this.serverSocket; socket = tempServerSocket.acceptSock(); if (tempServerSocket != this.serverSocket) /* socket changed while we were waiting */ { try { socket.close(); } catch (IOException e) {
- // TODO: consider logging } socket = null; } } catch (IOException e) { if (serverSocket != null) { http.logError(NLS.bind(HttpMsg.HTTP_ACCEPT_SOCKET_EXCEPTION, new Integer(serverSocket.getLocalPort())), e); } } if (socket != null) { HttpThread thread = configuration.pool.getThread(); if (thread != null) { thread.handleConnection(this, socket, socketTimeout); } else { try { socket.close(); } catch (Exception e) {
- // TODO: consider logging } } } } } protected void handleConnection(SocketInterface socket) throws IOException, ServletException { /* Create the servlet request and response objects */ HttpServletResponseImpl response = new HttpServletResponseImpl(socket, http); HttpServletRequestImpl request = new HttpServletRequestImpl(socket, http, response); /* After the request and response objects are successfully created, * we enter a try/finally block to ensure that the response is * always closed. */ try { //Get the URI from socket String uri = request.getRequestURI(); //Get Registration object associated with the request Registration registration = getRegistration(uri); while (registration != null) { try { if (registration.getHttpContext().handleSecurity(request, response)) { //Service Request registration.service(request, response); } return; } catch (ResourceUnavailableException e) { uri = reduceURI(uri); if (uri == null) { registration = null; } else { registration = getRegistration(uri); } } } if (registration == null) { if (Http.DEBUG) { http.logDebug("File " + request.getRequestURI() + //$NON-NLS-1$ " not found -- No Registration object"); //$NON-NLS-1$ } response.sendError(HttpServletResponse.SC_NOT_FOUND); } } finally { response.close(); /* close (and flush) the response output */ } } protected ResourceRegistration registerResources(Bundle bundle, String alias, String name, HttpContext httpContext) throws NamespaceException { synchronized (registrations) { if (Http.DEBUG) { http.logDebug("HttpService -- Registering Resource -- Alias = " + //$NON-NLS-1$ alias + " Name = " + name); //$NON-NLS-1$ } checkAlias(alias); //check to see if name is valid int length = name.length(); if (length > 1) { //we need to allow "/" and "" if (name.endsWith("/")) //$NON-NLS-1$ { throw new IllegalArgumentException(NLS.bind(HttpMsg.HTTP_RESOURCE_NAME_INVALID_EXCEPTION, name)); } } checkNamespace(alias); ResourceRegistration registration = new ResourceRegistration(bundle, alias, name, httpContext, http); registrations.put(alias, registration); return (registration); } } private void checkAlias(String alias) { //check to see if the alias is valid if (!alias.equals("/")) //$NON-NLS-1$ { //so one can register at "/" if (!alias.startsWith("/") || alias.endsWith("/")) //$NON-NLS-1$ //$NON-NLS-2$ { throw new IllegalArgumentException(NLS.bind(HttpMsg.HTTP_ALIAS_INVALID_EXCEPTION, alias)); } } } protected ServletRegistration registerServlet(Bundle bundle, String alias, Servlet servlet, Dictionary initparams, HttpContext httpContext) throws ServletException, NamespaceException { synchronized (registrations) { if (Http.DEBUG) { http.logDebug("HttpService -- Registering Servlet -- Alias = " + alias); //$NON-NLS-1$ } checkAlias(alias); checkNamespace(alias); if (servlet == null) { throw new NullPointerException(HttpMsg.HTTP_SERVLET_NULL_EXCEPTION); } if (http.servlets.contains(servlet)) { throw new ServletException(HttpMsg.HTTP_SERVLET_ALREADY_REGISTERED_EXCEPTION); } /* Determine the ServletContext */ ServletContextImpl servletContext = getServletContext(httpContext); //Create registration object ServletRegistration registration = new ServletRegistration(bundle, alias, servlet, httpContext, servletContext); //call servlet's init() method try { servlet.init(new ServletConfigImpl(servletContext, initparams)); } catch (ServletException e) { ungetServletContext(httpContext); throw e; } catch (Throwable t) { ungetServletContext(httpContext); throw new ServletException(HttpMsg.HTTP_SERVET_INIT_EXCEPTION, t); } http.servlets.addElement(servlet); registrations.put(alias, registration); return (registration); } } protected void unregister(Bundle bundle, String alias) throws IllegalArgumentException { synchronized (registrations) { Registration registration = (Registration) registrations.get(alias); if (registration != null) { //this is to prevent other bundles from unregistering a bundle's resource/servlet if (registration.getBundle() != bundle) { registration = null; } } removeRegistration(registration); } } protected HttpContext createDefaultHttpContext(Bundle bundle) { return (new DefaultHttpContext(bundle, http.securityTracker)); } protected ServletContextImpl getServletContext(HttpContext httpContext) { /* Determine the ServletContext */ ServletContextImpl servletContext = (ServletContextImpl) servletContexts.get(httpContext); if (servletContext == null) { servletContext = new ServletContextImpl(http, this, httpContext); servletContexts.put(httpContext, servletContext); } servletContext.incrUseCount(); return (servletContext); } protected void ungetServletContext(HttpContext httpContext) { ServletContextImpl servletContext = (ServletContextImpl) servletContexts.get(httpContext); if (servletContext != null) { int useCount = servletContext.decrUseCount(); if (useCount <= 0) { servletContexts.remove(httpContext); } } } protected void destroyBundle(Bundle bundle) { if (registrations != null) { if (Http.DEBUG) { http.logDebug("Removing bundle " + bundle + //$NON-NLS-1$ " from HttpListener"); //$NON-NLS-1$ } synchronized (registrations) { Enumeration e = registrations.elements(); while (e.hasMoreElements()) { Registration reg = (Registration) e.nextElement(); if (bundle == reg.getBundle()) { removeRegistration(reg); } } } } } private void checkNamespace(String uri) throws NamespaceException { // If alias already exists in master resource table, // throw NamespaceException if (registrations.get(uri) != null) { throw new NamespaceException(NLS.bind(HttpMsg.HTTP_ALIAS_ALREADY_REGISTERED_EXCEPTION, uri)); } } public Registration getRegistration(String uri) { synchronized (registrations) { while (uri != null) { Registration reg = (Registration) registrations.get(uri); if (reg != null) { return (reg); } uri = reduceURI(uri); } return (null); } } /** * Reduce the input URI per the HttpService spec. * * @param uri input URI to be reduced. * @return Reduced URI or null if no further reduction possible. */ private String reduceURI(String uri) { if (uri.equals("/")) //$NON-NLS-1$ { return (null); } int index = uri.lastIndexOf('/'); if (index < 0) { return (null); } if (index == 0) { return ("/"); //$NON-NLS-1$ } return (uri.substring(0, index)); } /** * Must be called while holding the registrations lock * */ private void removeRegistration(Registration registration) { if (registration == null) { throw new IllegalArgumentException(HttpMsg.HTTP_ALIAS_UNREGISTER_EXCEPTION); } registrations.remove(registration.getAlias()); if (registration instanceof ServletRegistration) { Servlet servlet = ((ServletRegistration) registration).getServlet(); http.servlets.removeElement(servlet); } // BUGBUG Must not call servlet.destroy while it is processing requests! // Servlet 2.2 Section 3.3.4 registration.destroy(); if (registration instanceof ServletRegistration) { ungetServletContext(registration.getHttpContext()); } } }
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpMsg.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpMsg.java
deleted file mode 100644
index 96a571666..000000000
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpMsg.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1999, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.equinox.http;
-
-import org.eclipse.osgi.util.NLS;
-
-public class HttpMsg extends NLS {
- private static final String BUNDLE_NAME = "org.eclipse.equinox.http.ExternalMessages"; //$NON-NLS-1$
-
- public static String HTTP_ALIAS_ALREADY_REGISTERED_EXCEPTION;
- public static String HTTP_SERVLET_ALREADY_REGISTERED_EXCEPTION;
- public static String HTTP_SERVLET_NULL_EXCEPTION;
- public static String HTTP_SERVLET_EXCEPTION;
- public static String HTTP_ALIAS_UNREGISTER_EXCEPTION;
- public static String HTTP_ALIAS_INVALID_EXCEPTION;
- public static String HTTP_RESOURCE_NAME_INVALID_EXCEPTION;
- public static String HTTP_SERVET_INIT_EXCEPTION;
- public static String HTTP_DEFAULT_MIME_TABLE_ERROR;
- public static String HTTP_STATUS_CODES_TABLE_ERROR;
- public static String HTTP_STATUS_CODE_NOT_FOUND;
- public static String HTTP_ACCEPT_SOCKET_EXCEPTION;
- public static String HTTP_PORT_IN_USE_EXCEPTION;
- public static String HTTP_INVALID_VALUE_RANGE_EXCEPTION;
- public static String HTTP_CONNECTION_EXCEPTION;
- public static String HTTP_INVALID_SCHEME_EXCEPTION;
- public static String HTTP_NO_HEADER_LINE_READ_EXCEPTION;
- public static String HTTP_QUERYDATA_PARSE_EXCEPTION;
- public static String HTTP_INVALID_HEADER_LINE_EXCEPTION;
- public static String HTTP_HEADER_LINE_TOO_LONG_EXCEPTION;
- public static String HTTP_UNEXPECTED_IOEXCEPTION;
- public static String HTTP_UNEXPECTED_RUNTIMEEXCEPTION;
- public static String HTTP_ONLY_SUPPORTS_2_1;
- public static String HTTP_HOST_UNKNOWN;
- public static String OSGi_Http_Service_IBM_Implementation_16;
- public static String IBM_Http_Service_37;
- public static String Jan_1;
- public static String Feb_2;
- public static String Mar_3;
- public static String Apr_4;
- public static String May_5;
- public static String Jun_6;
- public static String Jul_7;
- public static String Aug_8;
- public static String Sep_9;
- public static String Oct_10;
- public static String Nov_11;
- public static String Dec_12;
- public static String Sun_13;
- public static String Mon_14;
- public static String Tue_15;
- public static String Wed_16;
- public static String Thu_17;
- public static String Fri_18;
- public static String Sat_19;
- public static String HTTP_DEFAULT_PORT_FORMAT_EXCEPTION;
- public static String HTTP_THREAD_POOL_CREATE_NUMBER_ERROR;
-
- static {
- // initialize resource bundles
- NLS.initializeMessages(BUNDLE_NAME, HttpMsg.class);
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpSecurityTracker.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpSecurityTracker.java
deleted file mode 100644
index 5181b76c4..000000000
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpSecurityTracker.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1999, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.http;
-
-import java.io.IOException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.service.http.HttpContext;
-import org.osgi.util.tracker.ServiceTracker;
-
-public class HttpSecurityTracker extends ServiceTracker {
-
- protected HttpSecurityTracker(BundleContext context) throws InvalidSyntaxException {
- super(context, context.createFilter("(&(objectClass=org.osgi.service.http.HttpContext)(org.eclipse.equinox.http.default.handleSecurity=*))"), null); //$NON-NLS-1$
-
- open();
- }
-
- protected boolean handleSecurity(HttpServletRequest request, HttpServletResponse response) throws IOException {
- HttpContext service = (HttpContext) getService();
-
- if (service != null) {
- return (service.handleSecurity(request, response));
- }
-
- return (defaultHandleSecurity(request, response));
- }
-
- protected boolean defaultHandleSecurity(HttpServletRequest request, HttpServletResponse response) throws IOException {
- return (true);
- }
-}
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpServerSocket.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpServerSocket.java
deleted file mode 100644
index d4ab9501a..000000000
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpServerSocket.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1999, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.http;
-
-import java.io.IOException;
-import java.net.Socket;
-import org.eclipse.equinox.socket.ServerSocketInterface;
-import org.eclipse.equinox.socket.SocketInterface;
-
-public class HttpServerSocket extends java.net.ServerSocket implements ServerSocketInterface {
- String address = null;
-
- /**
- * HttpServerSocket constructor comment.
- * @param port int
- * @exception java.io.IOException The exception description.
- */
- public HttpServerSocket(int port) throws java.io.IOException {
- super(port);
- }
-
- /**
- * HttpServerSocket constructor comment.
- * @param port int
- * @param backlog int
- * @exception java.io.IOException The exception description.
- */
- public HttpServerSocket(int port, int backlog) throws java.io.IOException {
- super(port, backlog);
- }
-
- /**
- * HttpServerSocket constructor comment.
- * @param port int
- * @param backlog int
- * @param bindAddr java.net.InetAddress
- * @exception java.io.IOException The exception description.
- */
- public HttpServerSocket(int port, int backlog, java.net.InetAddress bindAddr) throws java.io.IOException {
- super(port, backlog, bindAddr);
- }
-
- /**
- * This method was created in VisualAge.
- */
- public Socket accept() throws IOException {
- return (Socket) acceptSock();
- }
-
- public SocketInterface acceptSock() throws IOException {
- HttpSocket socket = new HttpSocket(getScheme());
- implAccept(socket);
- return (socket);
- }
-
- public String getScheme() {
- return ("http"); //$NON-NLS-1$
- }
-
- public String getAddress() {
- return address;
- }
-
- public void setAddress(String address) {
- this.address = address;
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpService.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpService.java
deleted file mode 100644
index 2bc7c3339..000000000
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpService.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1999, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.http;
-
-import javax.servlet.Servlet;
-import javax.servlet.ServletException;
-import org.osgi.framework.Bundle;
-import org.osgi.service.http.HttpContext;
-import org.osgi.service.http.NamespaceException;
-
-public class HttpService implements org.osgi.service.http.HttpService {
- private HttpListener listener;
- private Bundle bundle;
-
- HttpService(HttpListener listener, Bundle bundle) {
- this.listener = listener;
- this.bundle = bundle;
- }
-
- void destroy() {
- listener.destroyBundle(bundle);
- listener = null;
- bundle = null;
- }
-
- public void registerResources(String alias, String name, HttpContext httpContext) throws NamespaceException {
- HttpListener tempListener = this.listener;
-
- if (tempListener != null) {
- if (httpContext == null) {
- httpContext = createDefaultHttpContext();
- }
-
- tempListener.registerResources(bundle, alias, name, httpContext);
- }
- }
-
- public void registerServlet(String alias, Servlet servlet, java.util.Dictionary initparams, HttpContext httpContext) throws ServletException, NamespaceException, IllegalArgumentException {
- HttpListener tempListener = this.listener;
-
- if (tempListener != null) {
- if (httpContext == null) {
- httpContext = createDefaultHttpContext();
- }
-
- tempListener.registerServlet(bundle, alias, servlet, initparams, httpContext);
- }
- }
-
- public void unregister(String alias) throws IllegalArgumentException {
- HttpListener tempListener = this.listener;
-
- if (tempListener != null) {
- tempListener.unregister(bundle, alias);
- }
- }
-
- public HttpContext createDefaultHttpContext() {
- HttpListener tempListener = this.listener;
-
- if (tempListener != null) {
- return (tempListener.createDefaultHttpContext(bundle));
- }
-
- return (null);
- }
-}
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpSocket.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpSocket.java
deleted file mode 100644
index 8bb8b3291..000000000
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpSocket.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1999, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.http;
-
-import java.io.*;
-import org.eclipse.equinox.socket.SocketInterface;
-
-public class HttpSocket extends java.net.Socket implements SocketInterface {
- private InputStream in = null;
- private boolean closed = false;
- private boolean active = false;
- private String scheme;
-
- public HttpSocket(String sheme) {
- super();
- this.scheme = sheme;
- }
-
- public void close() throws IOException {
- super.close();
- //must set closed to try after calling super.close() otherwise
- //jdk1.4 will not close the socket
- closed = true;
- }
-
- /**
- * Wrap the real socket input stream in a buffered input stream
- *
- * @return a buffered InputStream which wraps the real input stream.
- * @throws IOException
- */
- public InputStream getInputStream() throws IOException {
- if (in == null) {
- synchronized (this) {
- if (in == null) {
- in = new BufferedInputStream(super.getInputStream());
- }
- }
- }
-
- return in;
- }
-
- /**
- * Return the scheme this socket is using.
- *
- * @return Either "http" or "https".
- */
- public String getScheme() {
- return scheme;
- }
-
- /**
- * Test to see if the socket has been closed.
- *
- * @return true if close has been called on this socket.
- */
- public boolean isClosed() {
- return closed;
- }
-
- /**
- * Test to see if the socket is active.
- *
- * @return true if markActive has been called.
- */
- public boolean isActive() {
- return active;
- }
-
- /**
- * Mark the socket active.
- *
- */
- public void markActive() {
- active = true;
- }
-
- /**
- * Mark the socket inactive.
- *
- */
- public void markInactive() {
- active = false;
- }
-}
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpThread.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpThread.java
deleted file mode 100644
index 4df2e92be..000000000
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpThread.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1999, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.http;
-
-import java.io.IOException;
-import java.io.InterruptedIOException;
-import java.net.SocketException;
-import javax.servlet.ServletException;
-import org.eclipse.equinox.socket.SocketInterface;
-
-/**
- * The class provide a thread for processing HTTP requests.
- */
-public class HttpThread extends Thread {
- /** Master HTTP object */
- protected Http http;
-
- /** if true this thread must terminate */
- protected volatile boolean running;
-
- /** Pool to which this thread belongs. */
- protected HttpThreadPool pool;
-
- /** socket that this thread is operating */
- private SocketInterface socket;
-
- /** Listener this thread is working for */
- private HttpListener listener;
-
- /** if true, we support Keep-Alive for the socket */
- private boolean supportKeepAlive;
-
- /**
- * HttpThread constructor.
- */
- public HttpThread(Http http, HttpThreadPool pool, String name) {
- super(pool, name);
-
- this.http = http;
- this.pool = pool;
-
- setDaemon(true); /* mark thread as daemon thread */
- }
-
- /**
- * Returns true if this thread has been closed.
- * @return boolean
- */
- public boolean isClosed() {
- return (!running);
- }
-
- /**
- * Close this thread.
- */
- public synchronized void close() {
- running = false;
-
- if (socket == null) {
- interrupt();
- } else {
- try {
- socket.close();
- } catch (IOException e) {
- // TODO: consider logging
- }
- }
- }
-
- /**
- * recall this thread.
- */
- public synchronized void recall() {
- if (Http.DEBUG) {
- http.logDebug(getName() + ": recall on socket: " + socket); //$NON-NLS-1$
-
- }
-
- if ((socket != null) && !socket.isActive()) {
- try {
- if (Http.DEBUG) {
- http.logDebug(getName() + ": Closing socket: " + socket); //$NON-NLS-1$
- }
-
- socket.close();
- } catch (IOException e) {
- // TODO: consider logging
- }
- }
-
- supportKeepAlive = false;
- }
-
- public synchronized void handleConnection(HttpListener listenerParam, SocketInterface socketParam, int socketTimeout) {
- if (running) {
- this.listener = listenerParam;
- this.socket = socketParam;
-
- if (socketTimeout > 0) {
- try {
- socketParam.setSoTimeout(socketTimeout);
-
- supportKeepAlive = true;
- } catch (SocketException e) {
- supportKeepAlive = false;
- }
- } else {
- supportKeepAlive = false;
- }
-
- notify();
- }
- }
-
- public void run() {
- running = true;
-
- while (running) {
- if (socket == null) {
- /*
- synchronized (this)
- {
- pool.putThread(this);
-
- * Synchronizing on this before putThread
- * causes deadlock when security manager causes
- * Thread.isAlive() calls
- */
-
- pool.putThread(this);
-
- synchronized (this) {
- try {
- wait();
- } catch (InterruptedException e) {
- // ignore and check exit condition
- }
- }
- }
-
- if (running && (socket != null)) {
- boolean keepAlive = false;
-
- try {
- if (Http.DEBUG) {
- http.logDebug(getName() + ": Processing request on socket: " + socket); //$NON-NLS-1$
- }
-
- socket.markInactive();
-
- listener.handleConnection(socket);
-
- keepAlive = supportKeepAlive && !socket.isClosed();
- } catch (InterruptedIOException e) {
- /* A read on the socket did not complete within the timeout period.
- */
- keepAlive = false;
-
- if (Http.DEBUG) {
- http.logDebug(getName() + ": Read Timeout while processing connection on socket: " + socket, e); //$NON-NLS-1$
- }
- } catch (SocketException e) {
- /* Most likely the user agent closed the socket.
- */
- keepAlive = false;
-
- if (Http.DEBUG) {
- http.logDebug(getName() + ": Socket Exception while processing connection on socket: " + socket, e); //$NON-NLS-1$
- }
- }
- // BUGBUG Need to handle UnavailableException
- // Servlet 2.2 Section 3.3.3.2
- // BUGBUG An unhandled exception should result in flushing the response
- // buff and returning status code 500.
- // Servlet 2.3 Section 9.9.2
- catch (ServletException e) {
- /* The Servlet threw a ServletException.
- */
- keepAlive = false;
-
- http.logWarning(HttpMsg.HTTP_SERVLET_EXCEPTION, e);
- } catch (IOException e) {
- /* The Servlet threw an IOException.
- */
- keepAlive = false;
-
- http.logWarning(HttpMsg.HTTP_CONNECTION_EXCEPTION, e);
- } catch (Throwable t) {
- /* Some exception has occurred. Log it and keep
- * the thread working.
- */
- keepAlive = false;
-
- http.logError(HttpMsg.HTTP_CONNECTION_EXCEPTION, t);
- } finally {
- if (!keepAlive) {
- if (!socket.isClosed()) {
- try {
- if (Http.DEBUG) {
- http.logDebug(getName() + ": Closing socket: " + socket); //$NON-NLS-1$
- }
-
- socket.close();
- } catch (IOException e) {
- // TODO: consider logging
- }
- }
-
- socket = null;
- listener = null;
- }
- }
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpThreadPool.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpThreadPool.java
deleted file mode 100644
index bcf730ddd..000000000
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpThreadPool.java
+++ /dev/null
@@ -1,287 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1999, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.http;
-
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.Vector;
-import org.eclipse.osgi.util.NLS;
-
-public class HttpThreadPool extends ThreadGroup {
- /** Master HTTP object */
- protected Http http;
-
- /** container to threads waiting for work */
- private Vector idleThreads;
-
- /** container to threads which are working */
- private Vector activeThreads;
- /** Upper bound on size of thread pool */
- private int upper;
- /** Lower bound on size of thread pool */
- private int lower;
- /** Priority of thread pool */
- private int priority;
- /** number of threads to be terminated when they are returned to the pool */
- private int hitCount;
- /** Thread allocation number */
- int number;
- /** prevent new threads from readjusting */
- private int adjusting = 0;
-
- /**
- * Constructs and populates a new thread pool with the specified thread group
- * identifier and the specified number of threads.
- *
- */
- public HttpThreadPool(Http http, int lower, int upper, int priority) {
- super("Http Service Thread Pool"); //$NON-NLS-1$
- this.http = http;
- idleThreads = new Vector(upper);
- activeThreads = new Vector(upper);
- number = 0;
- setSize(lower, upper);
-
- setPriority(priority);
- }
-
- /**
- * Returns the lower bound on size of thread pool.
- */
- public int getLowerSizeLimit() {
- return (lower);
- }
-
- /**
- * Returns the upper bound on size of thread pool.
- */
- public int getUpperSizeLimit() {
- return (upper);
- }
-
- /**
- * Sets the size of thread pool.
- *
- * @param lower the lower bounds on the size
- * @param upper the upper bounds on the size
- */
- public synchronized void setSize(int lower, int upper) {
- this.lower = lower;
- this.upper = upper;
- adjustThreadCount();
- }
-
- /**
- * Must be called while synchronized.
- *
- */
- protected void adjustThreadCount() {
- if (adjusting > 0) {
- adjusting--;
- return;
- }
- int active = activeThreads.size();
- int idle = idleThreads.size();
- int count = idle + active;
-
- if (Http.DEBUG) {
- http.logDebug("Current thread count: " + idle + " idle, " + active + " active"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- if (idle < 2) {
- count += 5;
- } else {
- if (idle > 10) {
- count -= 5;
- }
- }
-
- if (count > upper) {
- count = upper;
- }
-
- if (count < lower) {
- count = lower;
- }
-
- int delta = count - (idle + active);
- if (Http.DEBUG) {
- http.logDebug("New thread count: " + count + ", delta: " + delta); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- if (delta < 0) /* remove threads */
- {
- delta = -delta; /* invert sign */
- if (delta < idle) {
- for (int i = idle - 1; delta > 0; i--, delta--) {
- HttpThread thread = (HttpThread) idleThreads.elementAt(i);
- idleThreads.removeElementAt(i);
- thread.close();
- }
- } else {
- hitCount += delta - idle;
- for (int i = 0; i < idle; i++) {
- HttpThread thread = (HttpThread) idleThreads.elementAt(i);
- thread.close();
- }
- idleThreads.removeAllElements();
- }
- } else {
- if (delta > 0) /* add threads */
- {
- adjusting = delta; /* new threads will call this method */
- if (delta > hitCount) {
- delta -= hitCount;
- hitCount = 0;
- idleThreads.ensureCapacity(count);
- for (int i = 0; i < delta; i++) {
- number++;
- try {
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- HttpThread thread = new HttpThread(http, HttpThreadPool.this, "HttpThread_" + number); //$NON-NLS-1$
- thread.start(); /* thread will add itself to the pool */
- return null;
- }
- });
- } catch (RuntimeException e) {
- /* No resources to create another thread */
- http.logError(NLS.bind(HttpMsg.HTTP_THREAD_POOL_CREATE_NUMBER_ERROR, new Integer(number)), e);
-
- number--;
-
- /* Readjust the upper bound of the thread pool */
- upper -= delta - i;
-
- break;
- }
- }
- } else {
- hitCount -= delta;
- }
- }
- }
- }
-
- /**
- * Set the priority of the threads in the thread pool.
- *
- * @param priority Thread priority.
- */
- public void setPriority(int priority) {
- if ((Thread.MIN_PRIORITY <= priority) && (priority <= Thread.MAX_PRIORITY)) {
- this.priority = priority;
- } else {
- throw new IllegalArgumentException(NLS.bind(HttpMsg.HTTP_INVALID_VALUE_RANGE_EXCEPTION, new Object[] {new Integer(Thread.MIN_PRIORITY), new Integer(Thread.MAX_PRIORITY)}));
- }
- }
-
- /**
- * Returns a thread to the thread pool and notifies the pool that
- * a thread is available.
- *
- * @param availableThread the thread being added/returned to the pool
- */
- public synchronized void putThread(HttpThread thread) {
- synchronized (thread) {
- if (Http.DEBUG) {
- http.logDebug(thread.getName() + ": becoming idle"); //$NON-NLS-1$
- }
-
- activeThreads.removeElement(thread);
-
- if (hitCount > 0) {
- hitCount--;
- thread.close();
- } else {
- if (!idleThreads.contains(thread)) {
- idleThreads.addElement(thread);
- notify();
- }
- }
- }
-
- adjustThreadCount();
- }
-
- /**
- * Gets the next available thread from the thread pool. If no thread is
- * available, this method blocks until one becomes available or the pool is
- * disposed of.
- *
- * @return the next available thread; if the pool has been (or is disposed
- * of while waiting), null is returned
- */
- public synchronized HttpThread getThread() {
- adjustThreadCount();
-
- while (upper > 0) {
- int count = idleThreads.size();
- if (count > 0) {
- int i = count - 1;
-
- HttpThread thread = (HttpThread) idleThreads.elementAt(i);
- idleThreads.removeElementAt(i);
- if (thread.getPriority() != priority) {
- thread.setPriority(priority);
- }
- activeThreads.addElement(thread);
- //new Exception((size-i)+" Threads are at work!").printStackTrace();
- if (Http.DEBUG) {
- http.logDebug(thread.getName() + ": becoming active"); //$NON-NLS-1$
- }
-
- return (thread);
- }
- try {
- wait();
- } catch (InterruptedException e) {
- // ignore and check exit condition
- }
- }
-
- return (null);
- }
-
- /**
- * Remove all thread from the pool.
- */
- public synchronized void close() {
- recallThreads();
-
- setSize(0, 0);
- /* Notify everyone waiting for a thread */
- notifyAll();
-
- // destroy the threadgroup, will never go away otherwise
- try {
- // Need to set it to a daemon first otherwise it will not be destroyed
- setDaemon(true);
- destroy();
- } catch (Exception e) {
- // TODO: consider logging
- }
- }
-
- /**
- * This method recalls threads that are waiting on a socket for work.
- * This is needed when Keep-Alive is in use and we need to
- * close the socket the thread is waiting on.
- *
- */
- public synchronized void recallThreads() {
- int count = activeThreads.size();
- for (int i = count - 1; i >= 0; i--) {
- HttpThread thread = (HttpThread) activeThreads.elementAt(i);
- thread.recall();
- }
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/LogMessages.properties b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/LogMessages.properties
deleted file mode 100644
index cf6028be3..000000000
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/LogMessages.properties
+++ /dev/null
@@ -1,16 +0,0 @@
-###############################################################################
-# Copyright (c) 2005 IBM Corporation.
-# 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:
-# IBM Corporation - initial API and implementation
-###############################################################################
-# NLS_MESSAGEFORMAT_ALL
-
-Unknown_Log_level=Unknown Log Level
-Info=Log Info
-Warning=Log Warning
-Error=Log Error \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/LogTracker.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/LogTracker.java
deleted file mode 100644
index 112d05605..000000000
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/LogTracker.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.http;
-
-import java.io.PrintStream;
-import java.text.DateFormat;
-import java.util.Calendar;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.log.LogService;
-import org.osgi.util.tracker.ServiceTracker;
-
-/**
- * LogTracker class. This class encapsulates the LogService
- * and handles all issues such as the service coming and going.
- */
-
-public class LogTracker extends ServiceTracker implements LogService {
- /** LogService interface class name */
- protected final static String clazz = "org.osgi.service.log.LogService"; //$NON-NLS-1$
-
- /** PrintStream to use if LogService is unavailable */
- protected PrintStream out;
-
- /** Calendar and DateFormat to user if LogService is unavailable */
- private static Calendar calendar;
- private static DateFormat dateFormat;
- private String timestamp;
-
- /**
- * Create new LogTracker.
- *
- * @param context BundleContext of parent bundle.
- * @param out Default PrintStream to use if LogService is unavailable.
- */
- public LogTracker(BundleContext context, PrintStream out) {
- super(context, clazz, null);
- this.out = out;
- calendar = Calendar.getInstance();
- dateFormat = DateFormat.getDateTimeInstance();
- open();
- }
-
- /*
- * ----------------------------------------------------------------------
- * LogService Interface implementation
- * ----------------------------------------------------------------------
- */
-
- public void log(int level, String message) {
- log(null, level, message, null);
- }
-
- public void log(int level, String message, Throwable exception) {
- log(null, level, message, exception);
- }
-
- public void log(ServiceReference reference, int level, String message) {
- log(reference, level, message, null);
- }
-
- public synchronized void log(ServiceReference reference, int level, String message, Throwable exception) {
- ServiceReference[] references = getServiceReferences();
-
- if (references != null) {
- int size = references.length;
-
- for (int i = 0; i < size; i++) {
- LogService service = (LogService) getService(references[i]);
- if (service != null) {
- try {
- service.log(reference, level, message, exception);
- } catch (Exception e) {
- // TODO: consider printing to System Error
- }
- }
- }
-
- return;
- }
-
- noLogService(level, message, exception, reference);
- }
-
- /**
- * The LogService is not available so we write the message to a PrintStream.
- *
- * @param level Logging level
- * @param message Log message.
- * @param throwable Log exception or null if none.
- * @param reference ServiceReference associated with message or null if none.
- */
- protected void noLogService(int level, String message, Throwable throwable, ServiceReference reference) {
- if (out != null) {
- synchronized (out) {
- // Bug #113286. If no log service present and messages are being
- // printed to stdout, prepend message with a timestamp.
- timestamp = dateFormat.format(calendar.getTime());
- out.print(timestamp + " "); //$NON-NLS-1$
-
- switch (level) {
- case LOG_DEBUG : {
- out.print("Debug: "); //$NON-NLS-1$
-
- break;
- }
- case LOG_INFO : {
- out.print(LogTrackerMsg.Info);
-
- break;
- }
- case LOG_WARNING : {
- out.print(LogTrackerMsg.Warning);
-
- break;
- }
- case LOG_ERROR : {
- out.print(LogTrackerMsg.Error);
-
- break;
- }
- default : {
- out.print("["); //$NON-NLS-1$
- out.print(LogTrackerMsg.Unknown_Log_level);
- out.print("]: "); //$NON-NLS-1$
-
- break;
- }
- }
-
- out.println(message);
-
- if (reference != null) {
- out.println(reference);
- }
-
- if (throwable != null) {
- throwable.printStackTrace(out);
- }
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/LogTrackerMsg.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/LogTrackerMsg.java
deleted file mode 100644
index 35311045b..000000000
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/LogTrackerMsg.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.http;
-
-import org.eclipse.osgi.util.NLS;
-
-public class LogTrackerMsg extends NLS {
- private static final String BUNDLE_NAME = "org.eclipse.equinox.http.LogMessages"; //$NON-NLS-1$
-
- public static String Unknown_Log_level;
- public static String Info;
- public static String Warning;
- public static String Error;
-
- static {
- // initialize resource bundles
- NLS.initializeMessages(BUNDLE_NAME, LogTrackerMsg.class);
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/Registration.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/Registration.java
deleted file mode 100644
index dfbbf3666..000000000
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/Registration.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1999, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.http;
-
-import java.io.IOException;
-import javax.servlet.*;
-import org.eclipse.equinox.http.servlet.HttpServletRequestImpl;
-import org.eclipse.equinox.http.servlet.HttpServletResponseImpl;
-import org.osgi.framework.Bundle;
-import org.osgi.service.http.HttpContext;
-
-public interface Registration {
- public abstract Bundle getBundle();
-
- public abstract HttpContext getHttpContext();
-
- public abstract void destroy();
-
- public abstract String getAlias();
-
- public abstract void service(HttpServletRequestImpl req, HttpServletResponseImpl res) throws ServletException, IOException;
-
- public abstract void service(ServletRequest req, ServletResponse res) throws ServletException, IOException;
-}
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/ResourceRegistration.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/ResourceRegistration.java
deleted file mode 100644
index 73830499d..000000000
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/ResourceRegistration.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1999, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.http;
-
-import java.io.*;
-import java.net.URL;
-import java.net.URLConnection;
-import javax.servlet.ServletException;
-import javax.servlet.ServletOutputStream;
-import javax.servlet.http.*;
-
-import org.eclipse.equinox.http.servlet.HttpServletRequestImpl;
-import org.eclipse.equinox.http.servlet.HttpServletResponseImpl;
-import org.osgi.framework.Bundle;
-import org.osgi.service.http.HttpContext;
-
-/**
- This class contains methods used to send requested resources a client.
- */
-public class ResourceRegistration extends HttpServlet implements Registration {
-
- private static final long serialVersionUID = -8732464938673729607L;
- protected Bundle bundle;
- protected HttpContext httpContext;
- protected String alias;
- protected String path;
- protected Http http;
- protected SecureAction secureAction;
-
- /**
- * The constructor
- */
- protected ResourceRegistration(Bundle bundle, String alias, String path, HttpContext httpContext, Http http) {
- this.bundle = bundle;
- this.alias = alias;
- this.path = path;
- this.httpContext = httpContext;
- this.http = http;
-
- secureAction = new SecureAction();
- }
-
- public Bundle getBundle() {
- return (bundle);
- }
-
- public HttpContext getHttpContext() {
- return (httpContext);
- }
-
- /**
- * This method returns the correct MIME type of a given URI by first checking
- * the HttpContext::getMimeType and, if null, checking the httpservice's MIMETypes table.
- * @return java.lang.String
- * @param URI java.lang.String
- */
- private String computeMimeType(String name, URLConnection conn) {
- String mimeType = httpContext.getMimeType(name);
- if (mimeType != null) {
- return (mimeType);
- }
-
- mimeType = conn.getContentType();
- if (mimeType != null) {
- return (mimeType);
- }
-
- return (http.getMimeType(name));
- }
-
- public void destroy() {
- alias = null;
- path = null;
- }
-
- public String getAlias() {
- return (alias);
- }
-
- /** This method is called by Http::handleConnection. It is called when a request comes in for
- * a resource registered by this registration.
- */
- public void service(HttpServletRequestImpl request, HttpServletResponseImpl response) throws ServletException, IOException {
- /* set additional data for the servlet request */
- request.init(alias, null);
-
- super.service(request, response);
- }
-
- protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
- String filename = getFilename(request.getRequestURI());
-
- URL url = httpContext.getResource(filename);
-
- if (url == null) {
- // We got null back from httpContext.getResource
- // In this case we want to keep looking to see if another alias matches
- throw new ResourceUnavailableException();
- }
-
- URLConnection conn = secureAction.openURL(url);
-
- long modifiedSince = request.getDateHeader("If-Modified-Since"); //$NON-NLS-1$
- if (modifiedSince >= 0) {
- long modified = conn.getLastModified();
- if ((modified > 0) && (modifiedSince >= modified)) {
- response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
- return;
- }
- }
-
- InputStream in;
- try {
- in = conn.getInputStream();
- } catch (IOException ex) {
- response.sendError(HttpServletResponse.SC_NOT_FOUND);
- return;
- }
-
- try {
- int contentlength = conn.getContentLength();
- if (contentlength >= 0) {
- response.setContentLength(contentlength);
- }
-
- String mimeType = computeMimeType(filename, conn);
- response.setContentType(mimeType);
-
- // We want to use a writer if we are sending text
- if (mimeType.startsWith("text/")) //$NON-NLS-1$
- {
- PrintWriter writer = response.getWriter();
-
- writer.flush(); /* write the headers and unbuffer the output */
-
- BufferedReader reader = new BufferedReader(new InputStreamReader(in));
-
- char buffer[] = new char[4096];
- int read;
- while ((read = reader.read(buffer, 0, buffer.length)) != -1) {
- writer.write(buffer, 0, read);
- }
- } else {
- ServletOutputStream out = response.getOutputStream();
-
- out.flush(); /* write the headers and unbuffer the output */
-
- byte buffer[] = new byte[4096];
- int read;
- while ((read = in.read(buffer, 0, buffer.length)) != -1) {
- out.write(buffer, 0, read);
- }
- }
- } finally {
- in.close();
- }
- }
-
- protected void doHead(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
- String filename = getFilename(request.getRequestURI());
-
- URL url = httpContext.getResource(filename);
-
- if (url == null) {
- // We got null back from httpContext.getResource
- // In this case we want to keep looking to see if another alias matches
- throw new ResourceUnavailableException();
- }
- URLConnection conn = secureAction.openURL(url);
- int contentlength = conn.getContentLength();
- if (contentlength >= 0) {
- response.setContentLength(contentlength);
-
- String mimeType = computeMimeType(filename, conn);
- response.setContentType(mimeType);
- } else {
- super.doHead(request, response);
- }
- }
-
- protected String getFilename(String filename) {
- //If the requested URI is equal to the Registeration's alias, send the file
- //corresponding to the alias. Otherwise, we have request for a file in an
- //registered directory (the file was not directly registered itself).
- if (filename.equals(alias)) {
- filename = path;
- } else {
- // The file we re looking for is the registered resource (alias) + the rest of the
- // filename that is not part of the registered resource. For example, if we export
- // /a to /tmp and we have a request for /a/b/foo.txt, then /tmp is our directory
- // (file.toString()) and /b/foo.txt is the rest.
- // The result is that we open the file /tmp/b/foo.txt.
-
- int aliaslen = alias.length();
- int pathlen = path.length();
-
- if (pathlen == 1) /* path == "/" */
- {
- if (aliaslen > 1) /* alias != "/" */
- {
- filename = filename.substring(aliaslen);
- }
- } else /* path != "/" */
- {
- StringBuffer buf = new StringBuffer(aliaslen + pathlen);
- buf.append(path);
-
- if (aliaslen == 1) /* alias == "/" */
- {
- buf.append(filename);
- } else /* alias != "/" */
- {
- buf.append(filename.substring(aliaslen));
- }
-
- filename = buf.toString();
- }
- }
-
- return (filename);
- }
-}
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/ResourceUnavailableException.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/ResourceUnavailableException.java
deleted file mode 100644
index f747b3aa2..000000000
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/ResourceUnavailableException.java
+++ /dev/null
@@ -1,15 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1999, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.http;
-
-public class ResourceUnavailableException extends RuntimeException {
- private static final long serialVersionUID = 4662869318092654517L;
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/SSLTracker.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/SSLTracker.java
deleted file mode 100644
index 264e409f4..000000000
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/SSLTracker.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1999, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.http;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.util.tracker.ServiceTracker;
-
-public class SSLTracker extends ServiceTracker {
- protected static final String sslsvcClass = "com.ibm.osg.service.ssl.SSLService"; //ssl //$NON-NLS-1$
-
- protected SSLTracker(BundleContext context) {
- super(context, sslsvcClass, null);
-
- open();
- }
-
- //BUGBUG need to handle opening and closing of HTTPS port!
- // e.g. httpAcceptor.createSSLListener();
-}
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/SecureAction.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/SecureAction.java
deleted file mode 100644
index 2b884f4f8..000000000
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/SecureAction.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.equinox.http;
-
-import java.io.IOException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.security.*;
-import org.osgi.framework.Bundle;
-
-/**
- * Utility class to execute common privileged code.
- */
-public class SecureAction {
- // make sure we use the correct controlContext;
- private AccessControlContext controlContext;
-
- /**
- * Constructs a new SecureAction object. The constructed SecureAction object
- * uses the caller's AccessControlContext to perform security checks
- */
- public SecureAction() {
- // save the control context to be used.
- this.controlContext = AccessController.getContext();
- }
-
- /**
- * Gets a resource from a bundle.
- * @param bundle the bundle to get the resource from
- * @param name The name of the resource
- * @return The URL of the resource
- */
-
- public URL getBundleResource(final Bundle bundle, final String name) {
- if (System.getSecurityManager() == null)
- return bundle.getResource(name);
- return (URL) AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- return bundle.getResource(name);
- }
- }, controlContext);
- }
-
- public URLConnection openURL(final URL url) throws IOException {
- if (System.getSecurityManager() == null)
- return open(url);
- try {
- return (URLConnection) AccessController.doPrivileged(new PrivilegedExceptionAction() {
- public Object run() throws IOException {
- return open(url);
- }
- }, controlContext);
- } catch(PrivilegedActionException ex) {
- throw (IOException) ex.getException();
- }
- }
-
- URLConnection open(final URL url)throws IOException
- {
- URLConnection connection = url.openConnection();
- connection.connect(); /* establish connection to check permissions */
- return connection;
- }
-
- /**
- * Returns a system property. Same as calling
- * System.getProperty(String,String).
- * @param property the property key.
- * @param def the default value if the property key does not exist.
- * @return the value of the property or the def value if the property
- * does not exist.
- */
- public String getProperty(final String property, final String def) {
- if (System.getSecurityManager() == null)
- return System.getProperty(property, def);
- return (String) AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- return System.getProperty(property, def);
- }
- }, controlContext);
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/ServletRegistration.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/ServletRegistration.java
deleted file mode 100644
index cd99c7504..000000000
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/ServletRegistration.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1999, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.http;
-
-import java.io.IOException;
-import java.security.AccessControlContext;
-import java.security.AccessController;
-import javax.servlet.*;
-import org.eclipse.equinox.http.servlet.*;
-import org.osgi.framework.Bundle;
-import org.osgi.service.http.HttpContext;
-
-public class ServletRegistration implements Registration {
- protected Bundle bundle;
- protected HttpContext httpContext;
- protected String alias;
- protected Servlet servlet;
- protected ServletContextImpl servletContext;
- protected AccessControlContext accessControlContext;
-
- protected ServletRegistration(Bundle bundle, String alias, Servlet servlet, HttpContext httpContext, ServletContextImpl servletContext) {
- this.bundle = bundle;
- this.alias = alias;
- this.servlet = servlet;
- this.httpContext = httpContext;
- this.servletContext = servletContext;
- // The constructor is called on the calling bundle's thread, therefore this
- // should capture the AccessControlContext for the calling bundle.
- accessControlContext = AccessController.getContext();
- }
-
- public Bundle getBundle() {
- return (bundle);
- }
-
- public HttpContext getHttpContext() {
- return (httpContext);
- }
-
- public void destroy() {
- if (servlet != null) {
- servlet.destroy();
- }
-
- this.alias = null;
- this.servlet = null;
- }
-
- public java.lang.String getAlias() {
- return (alias);
- }
-
- /**
- * This is to provide the request dispatcher direct access to the servlet for a
- * RequestDispatcher.include call
- * @return javax.servlet.Servlet
- */
- public Servlet getServlet() {
- return (servlet);
- }
-
- public void service(HttpServletRequestImpl request, HttpServletResponseImpl response) throws ServletException, IOException {
- /* set additional data for the servlet request */
- request.init(alias, servletContext);
-
- service((ServletRequest) request, (ServletResponse) response);
- }
-
- public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException {
- if (servlet instanceof SingleThreadModel) {
- synchronized (this) {
- servlet.service(request, response);
- }
- } else {
- servlet.service(request, response);
- }
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/StaticDataReader.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/StaticDataReader.java
deleted file mode 100644
index 571af8ab7..000000000
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/StaticDataReader.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1999, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.http;
-
-import java.io.*;
-import java.util.Hashtable;
-import java.util.StringTokenizer;
-
-public class StaticDataReader {
- protected Http http;
- protected static final String defaultMimeType = "application/octet-stream"; //$NON-NLS-1$
- protected static final String defaultMimeTable = "mime.types"; //$NON-NLS-1$
- protected static final String defaultStatusCodes = "status.codes"; //$NON-NLS-1$
-
- /** file extentsions (String) => MIME type (String) */
- protected Hashtable mimeTypes;
-
- /** status code (Integer) => status phrase (String) */
- protected Hashtable statusCodes;
-
- /**
- * Construct mime table from a standard mime.types file.
- */
- public StaticDataReader(Http http) {
- this.http = http;
-
- InputStream in = getClass().getResourceAsStream(defaultMimeTable);
- mimeTypes = parseMimeTypes(in);
-
- in = getClass().getResourceAsStream(defaultStatusCodes);
- statusCodes = parseStatusCodes(in);
-
- }
-
- /**
- * Determine the mime type of a file based on the file extension.
- * This method is more convenient to use than getMIMEType because
- * takes a filename as an argument. It is also able to discern that
- * files which are directories, such as
- * http://www.ibm.com/ are assumed to be HTML, rather than appOctet.
- *
- * @param String filename - the name of the file, which must
- * not be null.
- * @returns String - the mime type of the file.
- */
- public String computeMimeType(String filename) {
- int i = filename.lastIndexOf('.');
-
- if (i >= 0) {
- return (getMimeType(filename.substring(i + 1)));
- }
-
- return (getMimeType(filename));
- }
-
- /**
- * This method was created in VisualAge.
- * @return java.lang.String
- * @param statusCode int
- */
- public String computeStatusPhrase(int statusCode) {
- String statusPhrase = (String) statusCodes.get(new Integer(statusCode));
- if (statusPhrase != null) {
- return (statusPhrase);
- }
-
- return (HttpMsg.HTTP_STATUS_CODE_NOT_FOUND);
- }
-
- private String getMimeType(String extension) {
- String type = (String) mimeTypes.get(extension.toLowerCase());
-
- if (type != null) {
- return (type);
- }
-
- return (defaultMimeType);
- }
-
- /**
- * Parses the default MIME type table.
- *
- * @return Default MIME type Hashtable
- */
- private Hashtable parseMimeTypes(InputStream in) {
- Hashtable resultMimeTypes = new Hashtable();
-
- if (in != null) {
- try {
- BufferedReader rdr = new BufferedReader(new InputStreamReader(in, "8859_1")); //$NON-NLS-1$
- while (true) {
- String line = rdr.readLine();
- if (line == null) /* EOF */
- {
- break;
- }
-
- if ((line.length() != 0) && (line.charAt(0) != '#')) { // skip comments and blank lines
- StringTokenizer tokens = new StringTokenizer(line);
- String type = tokens.nextToken();
- while (tokens.hasMoreTokens()) {
- String ext = tokens.nextToken();
- resultMimeTypes.put(ext.toLowerCase(), type);
- }
- }
- }
- } catch (Exception e) {
- http.logError(HttpMsg.HTTP_DEFAULT_MIME_TABLE_ERROR, e);
- } finally {
- try {
- in.close();
- } catch (IOException e) {
- // TODO: consider logging
- }
- }
- }
-
- return (resultMimeTypes);
- }
-
- /**
- * This method was created in VisualAge.
- */
- private Hashtable parseStatusCodes(InputStream in) {
- Hashtable resultStatusCodes = new Hashtable();
-
- if (in != null) {
- try {
- BufferedReader rdr = new BufferedReader(new InputStreamReader(in, "8859_1")); //$NON-NLS-1$
- while (true) {
- String line = rdr.readLine();
- if (line == null) /* EOF */
- {
- break;
- }
-
- if ((line.length() != 0) && (line.charAt(0) != '#')) { // skip comments and blank lines
- int space = line.indexOf(' ');
- Integer status = new Integer(line.substring(0, space));
- String statusPhrase = line.substring(space + 1);
- resultStatusCodes.put(status, statusPhrase);
- }
- }
- } catch (Exception e) {
- http.logError(HttpMsg.HTTP_STATUS_CODES_TABLE_ERROR, e);
- } finally {
- try {
- in.close();
- } catch (IOException e) {
- // TODO: consider logging
- }
- }
- }
-
- return (resultStatusCodes);
- }
-
- /**
- * Read alias data and populate a Hashtable.
- * The inputstream is always closed.
- *
- * @param in InputStream from which to read alias data.
- * @return Hashtable of aliases.
- */
- private static Hashtable parseAliases(InputStream in) {
- Hashtable aliases = new Hashtable(37);
-
- if (in != null) {
- try {
- try {
- BufferedReader br = new BufferedReader(new InputStreamReader(in, "8859_1")); //$NON-NLS-1$
-
- while (true) {
- String line = br.readLine();
-
- if (line == null) /* EOF */
- {
- break; /* done */
- }
-
- Tokenizer tokenizer = new Tokenizer(line);
-
- String master = tokenizer.getString("#"); //$NON-NLS-1$
-
- if (master != null) {
- master = master.toUpperCase();
-
- aliases.put(master, master);
-
- parseloop: while (true) {
- String alias = tokenizer.getString("#"); //$NON-NLS-1$
-
- if (alias == null) {
- break parseloop;
- }
-
- aliases.put(alias.toUpperCase(), master);
- }
- }
- }
- } catch (IOException e) {
- if (Http.DEBUG) {
- e.printStackTrace();
- }
- }
- } finally {
- try {
- in.close();
- } catch (IOException ee) {
- // TODO: consider logging
- }
- }
- }
-
- return (aliases);
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/Tokenizer.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/Tokenizer.java
deleted file mode 100644
index 76dd58958..000000000
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/Tokenizer.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1999, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.http;
-
-public class Tokenizer {
- private char value[];
- private int max;
- private int cursor;
-
- public Tokenizer(String value) {
- this.value = value.toCharArray();
- max = this.value.length;
- cursor = 0;
- }
-
- public char getChar() {
- int cur = cursor;
- if (cur < max) {
- cursor = cur + 1;
- return (value[cur]);
- }
- return ('\0'); /* end of value */
- }
-
- public String getString(String terminals) {
- skipWhiteSpace();
- char[] val = value;
- int cur = cursor;
-
- if (cur < max) {
- if (val[cur] == '\"') /* if a quoted string */
- {
- cur++; /* skip quote */
- char c = '\0';
- int begin = cur;
- for (; cur < max; cur++) {
- c = val[cur];
- if (c == '\"') {
- break;
- }
- }
- int count = cur - begin;
- if (c == '\"') {
- cur++;
- }
- cursor = cur;
- if (count > 0) {
- skipWhiteSpace();
- return (new String(val, begin, count));
- }
- } else /* not a quoted string; same as token */
- {
- int begin = cur;
- for (; cur < max; cur++) {
- char c = val[cur];
- if ((c == ' ') || (c == '\t') || (terminals.indexOf(c) != -1)) {
- break;
- }
- }
- cursor = cur;
- int count = cur - begin;
- if (count > 0) {
- skipWhiteSpace();
- return (new String(val, begin, count));
- }
- }
- }
- return (null);
- }
-
- public String getToken(String terminals) {
- skipWhiteSpace();
- char[] val = value;
- int cur = cursor;
-
- int begin = cur;
- for (; cur < max; cur++) {
- char c = val[cur];
- if ((c == ' ') || (c == '\t') || (terminals.indexOf(c) != -1)) {
- break;
- }
- }
- cursor = cur;
- int count = cur - begin;
- if (count > 0) {
- skipWhiteSpace();
- return (new String(val, begin, count));
- }
- return (null);
- }
-
- private void skipWhiteSpace() {
- char[] val = value;
- int cur = cursor;
-
- for (; cur < max; cur++) {
- char c = val[cur];
- if ((c == ' ') || (c == '\t')) {
- continue;
- }
- break;
- }
- cursor = cur;
- }
-}
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/URI.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/URI.java
deleted file mode 100644
index 20e519b94..000000000
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/URI.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1999, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.http;
-
-import java.io.UnsupportedEncodingException;
-
-public class URI {
- /**
- * Takes an encoded string and decodes it
- * @param input encoded String
- * @param charset The charset to use convert escaped characters
- * @return Decoded String.
- */
- public static String decode(String input, String charset) {
- if (input == null) {
- return null;
- }
-
- return decode(input, 0, input.length(), charset);
- }
-
- /**
- * Takes an encoded string and decodes it
- * @param input encoded String (must not be null)
- * @param begin the beginning index, inclusive.
- * @param end the ending index, exclusive.
- * @param charset The charset to use convert escaped characters
- * @return Decoded String.
- */
- public static String decode(String input, int begin, int end, String charset) {
- if (input == null) {
- return (null);
- }
-
- int index = input.indexOf('%', begin);
- if ((index == -1) || (index >= end)) {
- return input.substring(begin, end).replace('+', ' ');
- }
-
- int size = end - begin;
- StringBuffer result = new StringBuffer(size);
- byte[] bytes = new byte[size];
- int length = 0;
-
- for (int i = begin; i < end; i++) {
- char c = input.charAt(i);
-
- if (c == '%') {
- if (i + 2 >= end) {
- throw new IllegalArgumentException();
- }
-
- i++;
- int digit = Character.digit(input.charAt(i), 16);
- if (digit == -1) {
- throw new IllegalArgumentException();
- }
- int value = (digit << 4);
-
- i++;
- digit = Character.digit(input.charAt(i), 16);
- if (digit == -1) {
- throw new IllegalArgumentException();
- }
- value |= digit;
-
- bytes[length] = (byte) value;
- length++;
- } else {
- if (length > 0) {
- result.append(convert(bytes, 0, length, charset));
-
- length = 0;
- }
-
- if (c == '+') {
- c = ' ';
- }
-
- result.append(c);
- }
- }
-
- if (length > 0) {
- result.append(convert(bytes, 0, length, charset));
-
- length = 0;
- }
-
- return result.toString();
- }
-
- /**
- * Convert bytes to a String using the supplied charset.
- * @param input Array of bytes to convert.
- * @param offset the beginning index, inclusive.
- * @param length number of bytes to convert.
- * @param charset The charset to use convert the bytes.
- * @return String containing converted bytes.
- */
- public static String convert(byte[] input, int offset, int length, String charset) {
- if (charset != null) {
- try {
- return new String(input, offset, length, charset);
- } catch (UnsupportedEncodingException e) {
- /* if the supplied charset is invalid,
- * fall through to use 8859_1.
- */
- }
- }
-
- try {
- return new String(input, offset, length, "8859_1"); //$NON-NLS-1$
- } catch (UnsupportedEncodingException e) {
- /* in the unlikely event 8859_1 is not present */
- return new String(input, offset, length);
- }
- }
-}
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/mime.types b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/mime.types
deleted file mode 100644
index 764b0ae5d..000000000
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/mime.types
+++ /dev/null
@@ -1,44 +0,0 @@
-###############################################################################
-# Copyright (c) 2005 IBM Corporation.
-# 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:
-# IBM Corporation - initial API and implementation
-###############################################################################
-
-# mime.types
-# This file contains the default mapping of file extension to MIME types.
-# This file must be encoded in ISO-8859-1.
-# Extension are processed in a case insensitive manner.
-
-# MIME type Extension
-
-application/octet-stream bin dms lha lzh exe class
-application/x-gtar gtar
-application/x-javascript js
-application/x-tar tar
-application/x-tcl tcl
-application/zip zip jar jxe
-application/pdf pdf
-audio/basic au snd
-audio/midi mid midi kar
-audio/mpeg mpga mp2 mp3
-audio/x-aiff aif aiff aifc
-audio/x-wav wav
-image/gif gif
-image/png png
-image/jpeg jpeg jpg jpe
-image/vnd.map.wbmp wbmp
-model/vrml wrl vrml
-text/html html htm
-text/plain asc txt
-text/richtext rtx
-text/rtf rtf
-text/sgml sgml sgm
-text/xml xml
-text/css css
-text/vnd.map.wml wml
-video/mpeg mpeg mpg mpe
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/HttpServletRequestImpl.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/HttpServletRequestImpl.java
deleted file mode 100644
index 991c774d8..000000000
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/HttpServletRequestImpl.java
+++ /dev/null
@@ -1,1444 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1999, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.http.servlet;
-
-import java.io.*;
-import java.security.Principal;
-import java.util.*;
-import javax.servlet.RequestDispatcher;
-import javax.servlet.ServletInputStream;
-import javax.servlet.http.*;
-
-import org.eclipse.equinox.http.*;
-import org.eclipse.equinox.socket.SocketInterface;
-import org.eclipse.osgi.util.NLS;
-import org.osgi.service.http.HttpContext;
-
-/**
- * Implementation of the HttpServletRequest interface
- *
- * Per Servlet 2.2 Section 3.3.3.3, this object need not be thread-safe.
- */
-
-public class HttpServletRequestImpl implements HttpServletRequest {
-
- protected Http http;
- protected HttpServletResponseImpl response;
- protected SocketInterface socket;
- protected ServletInputStreamImpl servletInputStream;
- protected String scheme;
- protected String authType = null;
- protected String remoteUser = null;
-
- protected int contentLength = -2;
- protected String contentType = null;
- protected String serverName = null;
-
- protected Hashtable parameters = null;
- protected Hashtable attributes = null;
- protected BufferedReader reader = null;
- protected ServletInputStream inputstream = null;
- protected Cookie[] cookies;
-
- //request-line variables
- protected String method = null;
- protected String reqURI = null; /* URI decoded */
- protected String protocol = null;
- protected String servletPath = null;
- protected String pathInfo = null; /* URI decoded */
- protected String queryString = null;
- protected String charset = null;
-
- protected Hashtable headers = null;
- protected HttpSessionImpl session;
- protected String requestedSessionId = null;
- protected ServletContextImpl servletContext;
-
- protected boolean parsedQueryData = false;
-
- public HttpServletRequestImpl(SocketInterface socket, Http http, HttpServletResponseImpl response) throws IOException {
- this.response = response;
- this.socket = socket;
- this.http = http;
- scheme = socket.getScheme();
-
- servletInputStream = new ServletInputStreamImpl(socket.getInputStream());
-
- response.setRequest(this);
-
- parseHeaders(); /* allocate headers Hashtable */
- }
-
- /**
- * Initialize additional request data.
- *
- * @param servletPathParam URI alias for this request
- * @param servletContextParam ServletContext for this request
- */
- public void init(String servletPathParam, ServletContextImpl servletContextParam) {
- // BUGBUG Need to deal with context path
- // Servlet 2.2 Section 5.4
- this.servletPath = servletPathParam;
- this.servletContext = servletContextParam;
-
- String tempPathInfo = reqURI.substring(servletPathParam.length());
- if ((tempPathInfo.length() == 0) || tempPathInfo.equals("/")) //$NON-NLS-1$
- {
- /* leave as null */
- } else {
- this.pathInfo = tempPathInfo;
- }
-
- if (authType == null) {
- Object obj = getAttribute(HttpContext.AUTHENTICATION_TYPE);
- if (obj instanceof String) {
- authType = (String) obj;
- }
- }
-
- if (remoteUser == null) {
- Object obj = getAttribute(HttpContext.REMOTE_USER);
- if (obj instanceof String) {
- remoteUser = (String) obj;
- }
- }
- }
-
- /**
- * Returns the value of the named attribute of the request, or
- * null if the attribute does not exist. This method allows
- * access to request information not already provided by the other
- * methods in this interface. Attribute names should follow the
- * same convention as package names.
- * The following predefined attributes are provided.
- *
- * <TABLE BORDER>
- * <tr>
- * <th>Attribute Name</th>
- * <th>Attribute Type</th>
- * <th>Description</th>
- * </tr>
- *
- * <tr>
- * <td VALIGN=TOP>javax.net.ssl.cipher_suite</td>
- * <td VALIGN=TOP>string</td>
- * <td>The string name of the SSL cipher suite in use, if the
- * request was made using SSL</td>
- * </tr>
- *
- * <tr>
- * <td VALIGN=TOP>javax.net.ssl.peer_certificates</td>
- * <td VALIGN=TOP>array of javax.security.cert.X509Certificate</td>
- * <td>The chain of X.509 certificates which authenticates the client.
- * This is only available when SSL is used with client
- * authentication is used.</td>
- * </tr>
- *
- * <tr>
- * <td VALIGN=TOP>javax.net.ssl.session</td>
- * <td VALIGN=TOP>javax.net.ssl.SSLSession</td>
- * <td>An SSL session object, if the request was made using SSL.</td>
- * </tr>
- *
- * </TABLE>
- *
- * <BR>
- * <P>The package (and hence attribute) names beginning with java.*,
- * and javax.* are reserved for use by Javasoft. Similarly, com.sun.*
- * is reserved for use by Sun Microsystems.
- *
- * @param name the name of the attribute whose value is required
- */
- public Object getAttribute(String name) {
- if (attributes != null) {
- return (attributes.get(name));
- }
- return (null);
- }
-
- /**
- * Returns an enumeration of attribute names contained in this request.
- */
-
- public Enumeration getAttributeNames() {
- if (attributes != null) {
- return (attributes.keys());
- }
- return (new Vector(0).elements());
- }
-
- /**
- * Gets the authentication scheme of this request. Same as the CGI
- * variable AUTH_TYPE.
- *
- * @return this request's authentication scheme, or null if none.
- */
- public String getAuthType() {
- return (authType);
- }
-
- /**
- * Returns the character set encoding for the input of this request.
- */
- public String getCharacterEncoding() {
- if (contentType == null) {
- getContentType(); /* parse the content type */
- }
-
- return (charset);
- }
-
- /**
- * Returns the size of the request entity data, or -1 if not known.
- * Same as the CGI variable CONTENT_LENGTH.
- */
- public int getContentLength() {
- if (contentLength == -2) {
- contentLength = getIntHeaderUpper("CONTENT-LENGTH"); //$NON-NLS-1$
- }
- return (contentLength);
- }
-
- /**
- * Returns the Internet Media Type of the request entity data, or
- * null if not known. Same as the CGI variable CONTENT_TYPE.
- */
-
- public String getContentType() {
- if (contentType == null) {
- contentType = getHeaderUpper("CONTENT-TYPE"); //$NON-NLS-1$
-
- if (contentType != null) {
- int index = contentType.indexOf(';', 0);
- if (index >= 0) {
- Tokenizer tokenizer = new Tokenizer(contentType);
-
- // TODO: verify next statement. It was String mimetype = tokenizer.getToken(";");
- tokenizer.getToken(";"); //$NON-NLS-1$
- tokenizer.getChar(); /* eat semicolon */
-
- parseloop: while (true) {
- String attribute = tokenizer.getToken("="); //$NON-NLS-1$
- char c = tokenizer.getChar();
-
- if (c != '=') {
- break parseloop; /* invalid content type */
- }
-
- String value = tokenizer.getString(";"); //$NON-NLS-1$
- c = tokenizer.getChar();
-
- if ("charset".equalsIgnoreCase(attribute)) //$NON-NLS-1$
- {
- charset = value;
- }
-
- if (c == '\0') {
- break parseloop;
- }
- }
- }
- }
- }
-
- return (contentType);
- }
-
- /**
- * Gets an array of cookies found in this request. If no cookies are present, an empty
- * array was returned.
- * @return the array of cookies found in this request
- */
- public Cookie[] getCookies() {
- parseCookies();
-
- return ((Cookie[]) cookies.clone());
- }
-
- /**
- * Gets the value of the requested date header field of this
- * request. If the header can't be converted to a date, the method
- * throws an IllegalArgumentException. The case of the header
- * field name is ignored.
- *
- * From HTTP/1.1 RFC 2616
- * 3.3.1 Full Date
- *
- * HTTP applications have historically allowed three different formats
- * for the representation of date/time stamps:
- *
- * Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123
- * Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036
- * Sun Nov 6 08:49:37 1994 ; ANSI C's asctime() format
- *
- * The first format is preferred as an Internet standard and represents
- * a fixed-length subset of that defined by RFC 1123 [8] (an update to
- * RFC 822 [9]). The second format is in common use, but is based on the
- * obsolete RFC 850 [12] date format and lacks a four-digit year.
- * HTTP/1.1 clients and servers that parse the date value MUST accept
- * all three formats (for compatibility with HTTP/1.0), though they MUST
- * only generate the RFC 1123 format for representing HTTP-date values
- * in header fields. See section 19.3 for further information.
- *
- * Note: Recipients of date values are encouraged to be robust in
- * accepting date values that may have been sent by non-HTTP
- * applications, as is sometimes the case when retrieving or posting
- * messages via proxies/gateways to SMTP or NNTP.
- *
- * All HTTP date/time stamps MUST be represented in Greenwich Mean Time
- * (GMT), without exception. For the purposes of HTTP, GMT is exactly
- * equal to UTC (Coordinated Universal Time). This is indicated in the
- * first two formats by the inclusion of "GMT" as the three-letter
- * abbreviation for time zone, and MUST be assumed when reading the
- * asctime format. HTTP-date is case sensitive and MUST NOT include
- * additional LWS beyond that specifically included as SP in the
- * grammar.
- *
- * HTTP-date = rfc1123-date | rfc850-date | asctime-date
- * rfc1123-date = wkday "," SP date1 SP time SP "GMT"
- * rfc850-date = weekday "," SP date2 SP time SP "GMT"
- * asctime-date = wkday SP date3 SP time SP 4DIGIT
- * date1 = 2DIGIT SP month SP 4DIGIT
- * ; day month year (e.g., 02 Jun 1982)
- * date2 = 2DIGIT "-" month "-" 2DIGIT
- * ; day-month-year (e.g., 02-Jun-82)
- * date3 = month SP ( 2DIGIT | ( SP 1DIGIT ))
- * ; month day (e.g., Jun 2)
- * time = 2DIGIT ":" 2DIGIT ":" 2DIGIT
- * ; 00:00:00 - 23:59:59
- * wkday = "Mon" | "Tue" | "Wed"
- * | "Thu" | "Fri" | "Sat" | "Sun"
- * weekday = "Monday" | "Tuesday" | "Wednesday"
- * | "Thursday" | "Friday" | "Saturday" | "Sunday"
- * month = "Jan" | "Feb" | "Mar" | "Apr"
- * | "May" | "Jun" | "Jul" | "Aug"
- * | "Sep" | "Oct" | "Nov" | "Dec"
- *
- * Note: HTTP requirements for the date/time stamp format apply only
- * to their usage within the protocol stream. Clients and servers are
- * not required to use these formats for user presentation, request
- * logging, etc.
- *
- * @param name the String containing the name of the requested
- * header field
- * @return the value the requested date header field, or -1 if not
- * found.
- */
- public long getDateHeader(String name) {
- //headers are stored as strings and must be converted
- String date = getHeader(name);
-
- if (date != null) {
- HttpDate d = new HttpDate(date);
-
- if (d.isValid()) {
- return (d.getAsLong()); // Parsed OK, so get the value as a Long
- }
- throw new IllegalArgumentException();
- }
-
- return (-1);
- }
-
- /**
- * Gets the value of the requested header field of this request.
- * The case of the header field name is ignored.
- *
- * @param name the String containing the name of the requested
- * header field
- * @return the value of the requested header field, or null if not
- * known.
- */
-
- //This should be case insensitive
- public String getHeader(String name) {
- return ((String) headers.get(name.toUpperCase()));
- }
-
- /**
- * Gets the header names for this request.
- *
- * @return an enumeration of strings representing the header names
- * for this request. Some server implementations do not allow
- * headers to be accessed in this way, in which case this method
- * will return null.
- */
- public Enumeration getHeaderNames() {
- return (headers.keys());
- }
-
- protected String getHeaderUpper(String name) {
- return ((String) headers.get(name));
- }
-
- /**
- * Returns an input stream for reading binary data in the request body.
- *
- * @see getReader
- * @exception IllegalStateException if getReader has been
- * called on this same request.
- * @exception IOException on other I/O related errors.
- */
- public ServletInputStream getInputStream() {
- if (inputstream == null) {
- synchronized (this) {
- if (inputstream == null) {
- if (reader != null) {
- throw new IllegalStateException();
- }
-
- inputstream = servletInputStream.getServletInputStream(getContentLength());
- }
- }
- }
-
- return (inputstream);
- }
-
- /**
- * Gets the value of the specified integer header field of this
- * request. The case of the header field name is ignored. If the
- * header can't be converted to an integer, the method throws a
- * NumberFormatException.
- *
- * @param name the String containing the name of the requested
- * header field
- * @return the value of the requested header field, or -1 if not
- * found.
- */
-
- //This lookup is case insensitive
- public int getIntHeader(String name) {
- String value = getHeader(name);
-
- if (value != null) {
- return (Integer.parseInt(value));
- }
-
- return (-1);
- }
-
- protected int getIntHeaderUpper(String name) {
- String value = getHeaderUpper(name);
-
- if (value != null) {
- return (Integer.parseInt(value));
- }
-
- return (-1);
- }
-
- /**
- * Gets the HTTP method (for example, GET, POST, PUT) with which
- * this request was made. Same as the CGI variable REQUEST_METHOD.
- *
- * @return the HTTP method with which this request was made
- */
- public String getMethod() {
- return (method);
- }
-
- /**
- * Returns a string containing the lone value of the specified
- * parameter, or null if the parameter does not exist. For example,
- * in an HTTP servlet this method would return the value of the
- * specified query string parameter. Servlet writers should use
- * this method only when they are sure that there is only one value
- * for the parameter. If the parameter has (or could have)
- * multiple values, servlet writers should use
- * getParameterValues. If a multiple valued parameter name is
- * passed as an argument, the return value is implementation
- * dependent.
- *
- * @see #getParameterValues
- *
- * @param name the name of the parameter whose value is required.
- */
- public String getParameter(String name) {
- String[] values = getParameterValues(name);
-
- if ((values != null) && (values.length > 0)) {
- return (values[0]);
- }
-
- return (null);
- }
-
- /**
- * Returns the parameter names for this request as an enumeration
- * of strings, or an empty enumeration if there are no parameters
- * or the input stream is empty. The input stream would be empty
- * if all the data had been read from the stream returned by the
- * method getInputStream.
- */
- public Enumeration getParameterNames() {
- if (!parsedQueryData) {
- parseQueryData();
- }
-
- if (parameters != null) {
- return (parameters.keys());
- }
-
- return (new Vector(0).elements());
- }
-
- /**
- * Returns the values of the specified parameter for the request as
- * an array of strings, or null if the named parameter does not
- * exist. For example, in an HTTP servlet this method would return
- * the values of the specified query string or posted form as an
- * array of strings.
- *
- * @param name the name of the parameter whose value is required.
- * @see javax.servlet.ServletRequest#getParameter
- */
- public String[] getParameterValues(String name) {
- if (!parsedQueryData) {
- parseQueryData();
- }
-
- if (parameters != null) {
- return ((String[]) parameters.get(name));
- }
-
- return (null);
- }
-
- /**
- * Gets any optional extra path information following the servlet
- * path of this request's URI, but immediately preceding its query
- * string. Same as the CGI variable PATH_INFO.
- *
- * @return the optional path information following the servlet
- * path, but before the query string, in this request's URI; null
- * if this request's URI contains no extra path information
- */
- public String getPathInfo() {
- return (pathInfo);
- }
-
- /**
- * Gets any optional extra path information following the servlet
- * path of this request's URI, but immediately preceding its query
- * string, and translates it to a real path. Similar to the CGI
- * variable PATH_TRANSLATED
- *
- * @return extra path information translated to a real path or null
- * if no extra path information is in the request's URI
- */
- public String getPathTranslated() {
- // JSP 1.0 Section B.5
- return servletContext.getRealPath(getPathInfo());
- }
-
- /**
- * Returns the protocol and version of the request as a string of
- * the form <code>&lt;protocol&gt;/&lt;major version&gt;.&lt;minor
- * version&gt</code>. Same as the CGI variable SERVER_PROTOCOL.
- */
- public String getProtocol() {
- return (protocol);
- }
-
- /**
- * Gets any query string that is part of the HTTP request URI.
- * Same as the CGI variable QUERY_STRING.
- *
- * @return query string that is part of this request's URI, or null
- * if it contains no query string
- */
- public String getQueryString() {
- return (queryString);
- }
-
- /**
- * Returns a buffered reader for reading text in the request body.
- * This translates character set encodings as appropriate.
- *
- * @see getInputStream
- *
- * @exception UnsupportedEncodingException if the character set encoding
- * is unsupported, so the text can't be correctly decoded.
- * @exception IllegalStateException if getInputStream has been
- * called on this same request.
- * @exception IOException on other I/O related errors.
- */
- public BufferedReader getReader() {
- if (reader == null) {
- synchronized (this) {
- if (reader == null) {
- if (inputstream != null) {
- throw new IllegalStateException();
- }
-
- // BUGBUG Must create reader with charset getCharacterEncoding or iso-8859-1 if null.
- // Servlet 2.3 Section 4.9
- reader = new BufferedReader(new InputStreamReader(servletInputStream.getServletInputStream(getContentLength())));
- }
- }
- }
-
- return (reader);
- }
-
- /**
- * Applies alias rules to the specified virtual path and returns
- * the corresponding real path, or null if the translation can not
- * be performed for any reason. For example, an HTTP servlet would
- * resolve the path using the virtual docroot, if virtual hosting
- * is enabled, and with the default docroot otherwise. Calling
- * this method with the string "/" as an argument returns the
- * document root.
- *
- * @param path the virtual path to be translated to a real path
- * *deprecated
- */
- public String getRealPath(String path) {
- return servletContext.getRealPath(path);
- }
-
- /**
- * Returns the IP address of the agent that sent the request.
- * Same as the CGI variable REMOTE_ADDR.
- */
- public String getRemoteAddr() {
- return (socket.getInetAddress().getHostAddress());
- }
-
- /**
- * Returns the fully qualified host name of the agent that sent the
- * request. Same as the CGI variable REMOTE_HOST.
- */
- public String getRemoteHost() {
- return (socket.getInetAddress().getHostName());
- }
-
- /**
- * Gets the name of the user making this request. The user name is
- * set with HTTP authentication. Whether the user name will
- * continue to be sent with each subsequent communication is
- * browser-dependent. Same as the CGI variable REMOTE_USER.
- *
- * @return the name of the user making this request, or null if not
- * known.
- */
- public String getRemoteUser() {
- return (remoteUser);
- }
-
- /**
- * Returns the session id specified with this request. This may differ from
- * the session id in the current session if the session id given by the
- * client was invalid for whatever reason and a new session was created.
- * This method will return null if the request does not have a session
- * associated with it.
- *
- * @return the session id specified by this request, or null if the
- * request did not specify a session id
- *
- * @see #isRequestedSessionIdValid */
- public String getRequestedSessionId() {
- parseCookies(); /* allocate cookies array */
-
- if (requestedSessionId == null) {
- String sessionCookieName = HttpSessionImpl.sessionCookieName;
- int numCookies = cookies.length;
- for (int i = 0; i < numCookies; i++) {
- Cookie cookie = cookies[i];
- if (sessionCookieName.equals(cookie.getName())) {
- requestedSessionId = cookie.getValue();
- break;
- }
- }
- }
-
- return (requestedSessionId);
- }
-
- /**
- * Gets, from the first line of the HTTP request, the part of this
- * request's URI that is to the left of any query string.
- * For example,
- *
- * <blockquote>
- * <table>
- * <tr align=left><th>First line of HTTP request<th>
- * <th>Return from <code>getRequestURI</code>
- * <tr><td>POST /some/path.html HTTP/1.1<td><td>/some/path.html
- * <tr><td>GET http://foo.bar/a.html HTTP/1.0
- * <td><td>http://foo.bar/a.html
- * <tr><td>HEAD /xyz?a=b HTTP/1.1<td><td>/xyz
- * </table>
- * </blockquote>
- *
- * <p>To reconstruct a URL with a URL scheme and host, use the
- * method javax.servlet.http.HttpUtils.getRequestURL, which returns
- * a StringBuffer.
- *
- * @return this request's URI
- * @see javax.servlet.http.HttpUtils#getRequestURL
- */
- public String getRequestURI() {
- // BUGBUG this should probably be URI encoded?
- // Servlet 2.2 Section 5.4
- return (reqURI);
- }
-
- /**
- * Returns the scheme of the URL used in this request, for example
- * "http", "https", or "ftp". Different schemes have different
- * rules for constructing URLs, as noted in RFC 1738. The URL used
- * to create a request may be reconstructed using this scheme, the
- * server name and port, and additional information such as URIs.
- */
- public String getScheme() {
- return (scheme);
- }
-
- /**
- * Returns the host name of the server that received the request.
- * Same as the CGI variable SERVER_NAME.
- */
- public String getServerName() {
-
- if (serverName == null) {
- String value = getHeaderUpper("HOST"); //$NON-NLS-1$
- if (value != null) {
- int n = value.indexOf(':');
- if (n < 0) {
- serverName = value;
- } else {
- serverName = value.substring(0, n).trim();
- }
- } else {
- serverName = socket.getLocalAddress().getHostName();
- }
- }
- return serverName;
- }
-
- /**
- * Returns the port number on which this request was received.
- * Same as the CGI variable SERVER_PORT.
- */
- public int getServerPort() {
- return (socket.getLocalPort());
- }
-
- /**
- * Gets the part of this request's URI that refers to the servlet
- * being invoked. Analogous to the CGI variable SCRIPT_NAME.
- *
- * @return the servlet being invoked, as contained in this
- * request's URI
- */
- public String getServletPath() {
- return (servletPath);
- }
-
- /**
- * Returns the current valid session associated with this request.
- * A session will be created for the
- * request if there is not already a session associated with the request.
- *
- * To ensure the session is properly
- * maintained, the servlet developer must call this method before the
- * response is committed.
- *
- * @return the session associated with this request.
- */
- public HttpSession getSession() {
- return (getSession(true));
- }
-
- /**
- * Returns the current valid session associated with this request.
- * If there is not already a session associated with the request,
- * a session will be created for the request only
- * if the argument is true.
- *
- * To ensure the session is properly
- * maintained, the servlet developer must call this method before the
- * response is committed.
- *
- * If the create flag is set to false and no session
- * is associated with this request, then this method will return null.
- *
- * <p><b>Note</b>: to ensure the session is properly maintained,
- * the servlet developer must call this method (at least once)
- * before any output is written to the response.
- *
- * <p>Additionally, application-writers need to be aware that newly
- * created sessions (that is, sessions for which
- * <code>HttpSession.isNew</code> returns true) do not have any
- * application-specific state.
- *
- * @return the session associated with this request or null if
- * create was false and no valid session is associated
- * with this request.
- */
- public synchronized HttpSession getSession(boolean create) {
- if (session != null) /* if session cached in this request */
- {
- /* test to see if the session is still valid */
- if (session.isValid(false)) {
- return (session);
- }
-
- session = null; /* dereference invalid session */
- } else {
- /* Session is not cached in this request
- * Check to see if the client requested a session id.
- */
-
- String sessionId = getRequestedSessionId();
- if (sessionId != null) {
- session = http.getSession(sessionId);
-
- if (session != null) /* valid session in cache */
- {
- return (session);
- }
- }
- }
-
- // we didn't get a valid session, so create one if desired
- if (create) {
- session = new HttpSessionImpl(http);
- response.addCookie(session.getCookie());
- return (session);
- }
-
- // Nothing we did produced a valid session, and the caller
- // didn't ask us to create one.
- return (null);
- }
-
- /**
- * Checks whether the session id specified by this request came in
- * as a cookie. (The requested session may not be one returned by
- * the <code>getSession</code> method.)
- *
- * @return true if the session id specified by this request came in
- * as a cookie; false otherwise
- *
- * @see #getSession
- */
- public boolean isRequestedSessionIdFromCookie() {
- /* We always use cookies. If there is a requestedSessionId,
- * it came from a Cookie.
- */
- return (getRequestedSessionId() != null);
- }
-
- /**
- * Checks whether the session id specified by this request came in
- * as part of the URL. (The requested session may not be the one
- * returned by the <code>getSession</code> method.)
- *
- * @return true if the session id specified by the request for this
- * session came in as part of the URL; false otherwise
- *
- * @see #getSession
- *
- * @deprecated use isRequestSessionIdFromURL() instead
- */
- public boolean isRequestedSessionIdFromUrl() {
- return (isRequestedSessionIdFromURL());
- }
-
- /**
- * Checks whether the session id specified by this request came in
- * as part of the URL. (The requested session may not be the one
- * returned by the <code>getSession</code> method.)
- *
- * @return true if the session id specified by the request for this
- * session came in as part of the URL; false otherwise
- *
- * @see #getSession
- */
-
- public boolean isRequestedSessionIdFromURL() {
- /* We do not support URL rewriting. We use cookies. */
- return (false);
- }
-
- /**
- * This method checks whether this request is associated with a session
- * that is currently valid. If the session used by the request is not valid,
- * it will not be returned via the getSession method.
- *
- * @return true if the request session is valid.
- *
- * @see #getRequestedSessionId
- * @see javax.servlet.http.HttpSessionContext
- * @see #getSession
- */
- public boolean isRequestedSessionIdValid() {
- HttpSession currentSession = getSession(false); /* get current session, if any */
-
- if (currentSession != null) /* if there is a session, see if it the requested session */
- {
- return (currentSession.getId().equals(getRequestedSessionId()));
- }
-
- return (false);
- }
-
- protected synchronized void parseCookies() {
- if (cookies == null) {
- nocookies: {
- String cookieHeader = getHeaderUpper("COOKIE"); //$NON-NLS-1$
- if (cookieHeader == null) {
- break nocookies;
- }
- Vector cookieVector = new Vector(20);
- int cookieVersion = 0;
-
- //parse through cookie header for all cookies
-
- Tokenizer tokenizer = new Tokenizer(cookieHeader);
-
- String name = tokenizer.getToken("="); //$NON-NLS-1$
- char c = tokenizer.getChar();
- String value;
-
- if (name.equals("$Version")) //$NON-NLS-1$
- {
- if (c != '=') {
- if (Http.DEBUG) {
- http.logDebug("Cookie parse error", new Exception()); //$NON-NLS-1$
- }
- break nocookies;
- }
-
- value = tokenizer.getString(";,"); //$NON-NLS-1$
-
- try {
- cookieVersion = Integer.parseInt(value);
- } catch (NumberFormatException e) {
- if (Http.DEBUG) {
- http.logDebug("Cookie version error", e); //$NON-NLS-1$
- }
- }
-
- name = null;
- }
-
- parseloop: while (true) {
- if (name == null) {
- name = tokenizer.getToken("="); //$NON-NLS-1$
- c = tokenizer.getChar();
- }
-
- if (c != '=') {
- if (Http.DEBUG) {
- http.logDebug("Cookie parse error", new Exception()); //$NON-NLS-1$
- }
- break nocookies;
- }
-
- value = tokenizer.getString(";,"); //$NON-NLS-1$
- c = tokenizer.getChar();
-
- Cookie cookie;
- try {
- cookie = new Cookie(name, value);
- } catch (IllegalArgumentException e) {
- if (Http.DEBUG) {
- http.logDebug("Cookie constructor error", e); //$NON-NLS-1$
- }
- break nocookies;
- }
- cookie.setVersion(cookieVersion);
-
- cookieVector.addElement(cookie);
-
- if (c == '\0') {
- break parseloop;
- }
-
- name = tokenizer.getToken("="); //$NON-NLS-1$
- c = tokenizer.getChar();
- if (name.equals("$Path")) //$NON-NLS-1$
- {
- if (c != '=') {
- if (Http.DEBUG) {
- http.logDebug("Cookie parse error", new Exception()); //$NON-NLS-1$
- }
- break nocookies;
- }
- cookie.setPath(tokenizer.getString(";,")); //$NON-NLS-1$
-
- c = tokenizer.getChar();
- if (c == '\0') {
- break parseloop;
- }
-
- name = tokenizer.getToken("="); //$NON-NLS-1$
- c = tokenizer.getChar();
- }
-
- if (name.equals("$Domain")) //$NON-NLS-1$
- {
- if (c != '=') {
- if (Http.DEBUG) {
- http.logDebug("Cookie parse error", new Exception()); //$NON-NLS-1$
- }
- break nocookies;
- }
- cookie.setDomain(tokenizer.getString(";,")); //$NON-NLS-1$
-
- c = tokenizer.getChar();
- if (c == '\0') {
- break parseloop;
- }
-
- name = null;
- }
- }
-
- if (cookieVector.size() > 0) {
- cookies = new Cookie[cookieVector.size()];
- cookieVector.copyInto(cookies);
- return;
- }
- }
-
- cookies = new Cookie[0];
- }
- }
-
- protected void parseHeaders() throws IOException {
- headers = new Hashtable(31);
- byte[] buffer = new byte[4096];
-
- /* The first line in an http request is always the request-line. */
- String line = readHeaderLine(buffer);
-
- if (line.length() == 0) {
- throw new InterruptedIOException(HttpMsg.HTTP_NO_HEADER_LINE_READ_EXCEPTION);
- }
-
- socket.markActive(); /* indicate we are processing a request */
-
- parseRequestLine(line);
-
- /* Now we get to the headers. */
- // BUGBUG Headers can be repeated! getHeader must return the first header
- // in the request. The (2.2) getHeaders method can be used to get all
- // the headers' values.
- // Servlet 2.2 Section 5.3
- boolean firstLine = true;
- String header = null;
- StringBuffer value = new StringBuffer(256);
- while (true) {
- line = readHeaderLine(buffer);
-
- if (line.length() == 0) { //End of headers
- if (!firstLine) /* flush last line */
- {
- headers.put(header, value.toString().trim());
- }
- break;
- }
-
- // System.out.println(line);
-
- char c = line.charAt(0);
- if ((c == ' ') || (c == '\t')) /* continuation */
- {
- if (firstLine) /* if no previous line */
- {
- throw new IOException(NLS.bind(HttpMsg.HTTP_INVALID_HEADER_LINE_EXCEPTION, line));
- }
- value.append(line.substring(1));
- continue;
- }
-
- if (!firstLine) {
- headers.put(header, value.toString().trim());
- value.setLength(0); /* clear StringBuffer */
- }
-
- //use ':' as a delimeter to separate the key and the value
- int colon = line.indexOf(':', 0);
-
- // Our keys are saved as upper case so we can do case-insensitive
- // searches on them.
- header = line.substring(0, colon).toUpperCase();
- value.append(line.substring(colon + 1));
- firstLine = false;
- }//while
- }
-
- /**
- * This methods MUST only be called by one of the getParameter methods
- * Servlet 2.2 Section 5.1
- */
- protected synchronized void parseQueryData() {
- if (!parsedQueryData) {
- try {
- /* Request parameters must come from BOTH the query string
- * and the POST data. Query string must be processed before POST data.
- * Servlet 2.2 Section 5.1.
- */
-
- if (queryString != null) {
- if (parameters == null) {
- parameters = new Hashtable();
- }
-
- parseQueryString(parameters, queryString, null);
- }
-
- /* POST data must only be read if the following conditions are
- * true
- * 1. getScheme is "http" or "https"
- * 2. getMethod is "POST"
- * 3. getContextType is "application/x-www-form-urlencoded"
- * 4. servlet calls getParameter* method.
- * Servlet 2.2 Section 5.1
- */
- String content_type = getContentType();
-
- if (content_type != null) {
- int index = content_type.indexOf(';', 0);
- if (index >= 0) {
- content_type = content_type.substring(0, index).trim();
- }
- }
-
- if ("POST".equals(method) && //$NON-NLS-1$
- ("http".equals(scheme) || "https".equals(scheme)) && //$NON-NLS-1$ //$NON-NLS-2$
- "application/x-www-form-urlencoded".equals(content_type) //$NON-NLS-1$
- ) {
- int content_length = getContentLength();
- if (content_length > 0) {
- // System.out.println("Read POST data");
- /* Read the post data from the ServletInputStream */
- ServletInputStream in = getInputStream();
- byte buffer[] = new byte[content_length];
- int bytesRead = 0;
- while (bytesRead < content_length) {
- int count;
-
- try {
- count = in.read(buffer, bytesRead, content_length - bytesRead);
- } catch (IOException e) {
- throw new IllegalArgumentException();
- }
-
- if (count < 1) {
- break;
- }
-
- bytesRead += count;
- }
-
- String encoding = getCharacterEncoding();
-
- /* Must use charset getCharacterEncoding or iso-8859-1 if null.
- * Servlet 2.3 Section 4.9
- */
-
- String postData = URI.convert(buffer, 0, bytesRead, encoding);
-
- if (parameters == null) {
- parameters = new Hashtable();
- }
-
- parseQueryString(parameters, postData, encoding);
- }
- }
- } catch (Exception e) {
- //Bad query string, ignore, log and continue
- http.logError(HttpMsg.HTTP_QUERYDATA_PARSE_EXCEPTION, e);
- }
-
- parsedQueryData = true;
- }
- }
-
- /**
- * Parses a query string and builds a hashtable of key-value
- * pairs, where the values are arrays of strings. The query string
- * should have the form of a string packaged by the GET or POST
- * method. (For example, it should have its key-value pairs
- * delimited by ampersands (&) and its keys separated from its
- * values by equal signs (=).)
- *
- * <p> A key can appear one or more times in the query string.
- * Each time a key appears, its corresponding value is inserted
- * into its string array in the hash table. (So keys that appear
- * once in the query string have, in the hash table, a string array
- * of length one as their value, keys that appear twice have a
- * string array of length two, etc.)
- *
- * <p> When the keys and values are moved into the hashtable, any
- * plus signs (+) are returned to spaces and characters sent in
- * hexadecimal notation (%xx) are converted back to characters.
- *
- * @param data query string to be parsed
- * @param result a hashtable built from the parsed key-value pairs; the
- *.hashtable's values are arrays of strings
- * @exception IllegalArgumentException if the query string is
- * invalid.
- */
- protected void parseQueryString(Hashtable result, String data, String encoding) {
- if (data == null) {
- throw new IllegalArgumentException();
- }
-
- // System.out.println("Querystring: " + data);
-
- data = data.trim(); /* Strip CRLF if present */
-
- int len = data.length();
-
- if (len >= 0) {
- int begin = 0;
-
- while (true) {
- int end = data.indexOf('&', begin);
- if (end == -1) {
- end = len;
- }
-
- int equals = data.indexOf('=', begin);
-
- String key;
- String value;
- if ((equals >= end) || (equals == -1)) {
- key = URI.decode(data, begin, end, encoding);
- value = ""; //$NON-NLS-1$
- } else {
- key = URI.decode(data, begin, equals, encoding);
- value = URI.decode(data, equals + 1, end, encoding);
- }
-
- String[] values = (String[]) result.get(key);
-
- if (values == null) {
- values = new String[1];
- values[0] = value;
- result.put(key, values);
- } else {
- int length = values.length;
- String[] newvalues = new String[length + 1];
- System.arraycopy(values, 0, newvalues, 0, length);
- newvalues[length] = value;
- result.put(key, newvalues);
- }
-
- if (end == len) {
- break;
- }
-
- begin = end + 1;
- }
- }
- }
-
- /**
- * This method was created in VisualAge.
- * @return java.lang.String
- * @param requestLine java.lang.String
- */
- protected void parseRequestLine(String requestLine) {
- if (Http.DEBUG) {
- http.logDebug("Http Request Line=\"" + requestLine + "\""); //$NON-NLS-1$ //$NON-NLS-2$
- }
- // System.out.println("Http Request Line=\"" + requestLine + "\"");
-
- int space = requestLine.indexOf(' ', 0);
- method = requestLine.substring(0, space);
-
- int nextspace = requestLine.lastIndexOf(' ');
- protocol = requestLine.substring(nextspace + 1);
-
- int query = requestLine.indexOf('?', space + 1);
-
- if ((query >= nextspace) || (query == -1)) {
- reqURI = URI.decode(requestLine, space + 1, nextspace, null);
- } else {
- reqURI = URI.decode(requestLine, space + 1, query, null);
- queryString = requestLine.substring(query + 1, nextspace);
- }
- }
-
- /**
- * This method is only used by the constructor (albiet indirectly)
- * @return java.lang.String
- */
- protected String readHeaderLine(byte[] buffer) throws IOException {
- int read = servletInputStream.readLine(buffer, 0, buffer.length);
- if (read <= 0) {
- throw new InterruptedIOException(HttpMsg.HTTP_NO_HEADER_LINE_READ_EXCEPTION);
- }
-
- // BUGBUG should use 8859_1 encoding to make string
- /* create String from byte array using 0 for high byte of chars */
- String line = URI.convert(buffer, 0, read, null);
-
- if (line.endsWith("\n")) //$NON-NLS-1$
- {
- return (line.trim()); /* trim removes trailing CRLF */
- }
-
- try {
- response.sendError(HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE);
- } finally {
- response.close();
- }
-
- throw new IOException(NLS.bind(HttpMsg.HTTP_HEADER_LINE_TOO_LONG_EXCEPTION, new Integer(buffer.length)));
- }
-
- /**
- * This method places an attribute into the request for later use by
- * other objects which will have access to this request object such as
- * nested servlets.
- *
- * @param name Attribute name
- * @param object Attribute value
- */
- public void setAttribute(String name, Object val) {
- if (attributes == null) {
- synchronized (this) {
- if (attributes == null) {
- attributes = new Hashtable(31);
- }
- }
- }
-
- if (val == null) {
- attributes.remove(name);
- } else {
- attributes.put(name, val);
- }
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#getContextPath()
- */
- public String getContextPath() throws UnsupportedOperationException {
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#getHeaders(String)
- */
- public Enumeration getHeaders(String name) throws UnsupportedOperationException {
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#getRequestURL()
- */
- public StringBuffer getRequestURL() throws UnsupportedOperationException {
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#getUserPrincipal()
- */
- public Principal getUserPrincipal() throws UnsupportedOperationException {
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
- }
-
- /**
- * @see javax.servlet.http.HttpServletRequest#isUserInRole(String)
- */
- public boolean isUserInRole(String role) throws UnsupportedOperationException {
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
- }
-
- /**
- * @see javax.servlet.ServletRequest#getLocale()
- */
- public Locale getLocale() throws UnsupportedOperationException {
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
- }
-
- /**
- * @see javax.servlet.ServletRequest#getLocales()
- */
- public Enumeration getLocales() throws UnsupportedOperationException {
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
- }
-
- /**
- * @see javax.servlet.ServletRequest#getParameterMap()
- */
- public Map getParameterMap() throws UnsupportedOperationException {
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
- }
-
- /**
- * @see javax.servlet.ServletRequest#getRequestDispatcher(String)
- */
- public RequestDispatcher getRequestDispatcher(String path) throws UnsupportedOperationException {
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
- }
-
- /**
- * @see javax.servlet.ServletRequest#isSecure()
- */
- public boolean isSecure() throws UnsupportedOperationException {
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
- }
-
- /**
- * @see javax.servlet.ServletRequest#removeAttribute(String)
- */
- public void removeAttribute(String name) throws UnsupportedOperationException {
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
- }
-
- /**
- * @see javax.servlet.ServletRequest#setCharacterEncoding(String)
- */
- public void setCharacterEncoding(String env) throws UnsupportedEncodingException, UnsupportedOperationException {
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
- }
-
- /* For compilation only. Will not implement.
- *
- */
- public String getLocalAddr() {
- //return(socket.getInetAddress().getLocalHost().getHostAddress());
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
- }
-
- /* For compilation only. Will not implement.
- *
- */
- public String getLocalName() {
- //return(socket.getInetAddress().getLocalHost().getHostName());
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
- }
-
- /* For compilation only. Will not implement.
- *
- */
- public int getLocalPort() {
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
- }
-
- /* For compilation only. Will not implement.
- *
- */
- public int getRemotePort() {
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
- }
-}
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/HttpServletResponseImpl.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/HttpServletResponseImpl.java
deleted file mode 100644
index 1f88be48d..000000000
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/HttpServletResponseImpl.java
+++ /dev/null
@@ -1,861 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1999, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.http.servlet;
-
-import java.io.*;
-import java.util.*;
-import javax.servlet.ServletOutputStream;
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletResponse;
-import org.eclipse.equinox.http.*;
-import org.eclipse.equinox.socket.SocketInterface;
-
-/**
- * The implementation of the HttpServletResponse interface.
- *
- * Per Servlet 2.2 Section 3.3.3.3, this object need not be thread-safe.
- **/
-
-public class HttpServletResponseImpl implements HttpServletResponse {
- private Http http;
- protected HttpServletRequestImpl request;
- private SocketInterface socket;
- protected ServletOutputStreamImpl servletOutputStream;
- protected String charset = null;
- protected static final String defaultCharset = "ISO-8859-1"; //$NON-NLS-1$
-
- protected int contentLength = 0;
- protected String contentType = null;
- protected Vector cookies = null;
- protected Hashtable headers = null;
- protected int status = SC_OK;
- protected String statusString = "OK"; //$NON-NLS-1$
-
- private boolean gotOutputStream = false;
- protected PrintWriter writer = null;
-
- private boolean keepAlive = false;
-
- public HttpServletResponseImpl(SocketInterface socket, Http http) throws IOException {
- this.http = http;
- this.socket = socket;
- servletOutputStream = new ServletOutputStreamImpl(socket.getOutputStream(), this);
- }
-
- /**
- * Called by the request in its constructor.
- */
- protected void setRequest(HttpServletRequestImpl request) {
- this.request = request;
- }
-
- /**
- * Adds the specified cookie to the response. It can be called
- * multiple times to set more than one cookie.
- *
- * @param cookie the Cookie to return to the client
- */
- public void addCookie(Cookie cookie) {
- if (cookies == null) {
- synchronized (this) {
- if (cookies == null) {
- cookies = new Vector(20);
- }
- }
- }
-
- synchronized (cookies) {
- if (!cookies.contains(cookie)) {
- //System.out.println("addCookie: "+cookie.getName()+"="+cookie.getValue());
- cookies.addElement(cookie);
- }
- }
-
- //http.logDebug("ServletResponse::addCookie: added cookie "+cookie.getName());
- }
-
- /**
- * Checks whether the response message header has a field with
- * the specified name.
- *
- * @param name the header field name
- * @return true if the response message header has a field with
- * the specified name; false otherwise
- */
- public boolean containsHeader(String name) {
- if (headers == null) {
- return (false);
- }
-
- Object value = headers.get(name);
-
- if (value != null) {
- return (true);
- }
-
- Enumeration headerEnumeration = headers.keys();
-
- while (headerEnumeration.hasMoreElements()) {
- String key = (String) headerEnumeration.nextElement();
-
- if (name.equalsIgnoreCase(key)) {
- return (true);
- }
- }
-
- return (false);
- }
-
- /**
- * Encodes the specified URL for use in the
- * <code>sendRedirect</code> method or, if encoding is not needed,
- * returns the URL unchanged. The implementation of this method
- * should include the logic to determine whether the session ID
- * needs to be encoded in the URL. Because the rules for making
- * this determination differ from those used to decide whether to
- * encode a normal link, this method is seperate from the
- * <code>encodeUrl</code> method.
- *
- * <p>All URLs sent to the HttpServletResponse.sendRedirect
- * method should be run through this method. Otherwise, URL
- * rewriting cannot be used with browsers which do not support
- * cookies.
- *
- * @param url the url to be encoded.
- * @return the encoded URL if encoding is needed; the unchanged URL
- * otherwise.
- * deprecated
- *
- * @see #sendRedirect
- * @see #encodeUrl
- */
-
- public String encodeRedirectUrl(String url) {
- return (encodeRedirectURL(url));
- }
-
- /**
- * Encodes the specified URL for use in the
- * <code>sendRedirect</code> method or, if encoding is not needed,
- * returns the URL unchanged. The implementation of this method
- * should include the logic to determine whether the session ID
- * needs to be encoded in the URL. Because the rules for making
- * this determination differ from those used to decide whether to
- * encode a normal link, this method is seperate from the
- * <code>encodeUrl</code> method.
- *
- * <p>All URLs sent to the HttpServletResponse.sendRedirect
- * method should be run through this method. Otherwise, URL
- * rewriting canont be used with browsers which do not support
- * cookies.
- *
- * <p>After this method is called, the response should be considered
- * to be committed and should not be written to.
- *
- * @param url the url to be encoded.
- * @return the encoded URL if encoding is needed; the unchanged URL
- * otherwise.
- *
- * @see #sendRedirect
- * @see #encodeUrl
- */
-
- public String encodeRedirectURL(String url) {
- return (url);
- }
-
- /**
- * Encodes the specified URL by including the session ID in it,
- * or, if encoding is not needed, returns the URL unchanged.
- * The implementation of this method should include the logic to
- * determine whether the session ID needs to be encoded in the URL.
- * For example, if the browser supports cookies, or session
- * tracking is turned off, URL encoding is unnecessary.
- *
- * <p>All URLs emitted by a Servlet should be run through this
- * method. Otherwise, URL rewriting cannot be used with browsers
- * which do not support cookies.
- *
- * @param url the url to be encoded.
- * @return the encoded URL if encoding is needed; the unchanged URL
- * otherwise.
- * deprecated
- */
- public String encodeUrl(String url) {
- return (encodeURL(url));
- }
-
- /**
- * Encodes the specified URL by including the session ID in it,
- * or, if encoding is not needed, returns the URL unchanged.
- * The implementation of this method should include the logic to
- * determine whether the session ID needs to be encoded in the URL.
- * For example, if the browser supports cookies, or session
- * tracking is turned off, URL encoding is unnecessary.
- *
- * <p>All URLs emitted by a Servlet should be run through this
- * method. Otherwise, URL rewriting cannot be used with browsers
- * which do not support cookies.
- *
- * @param url the url to be encoded.
- * @return the encoded URL if encoding is needed; the unchanged URL
- * otherwise.
- */
-
- public String encodeURL(String url) {
- return (url);
- }
-
- /**
- * Close the response output.
- *
- */
- public void close() {
- if (writer != null) {
- writer.close();
- } else {
- try {
- servletOutputStream.close();
- } catch (IOException e) {
- // TODO: consider logging
- }
- }
-
- if (!keepAlive) /* if the no Keep-Alive, then close socket */
- {
- try {
- socket.close();
- } catch (IOException e) {
- // TODO: consider logging
- }
- }
- }
-
- /**
- * Returns the character set encoding used for this MIME body.
- * The character encoding is either the one specified in the
- * assigned content type, or one which the client understands
- * as specified in the Accept-Charset header of the request.
- * If no charset can be determined, it defaults to the
- * value of the System property 'file.encoding' if that
- * is a supported character set. If it is not supported, then
- * we use <tt>ISO-8859-1</tt> as the character set.
- */
- public String getCharacterEncoding() {
- if (charset == null) {
- OutputStream dummy = new ByteArrayOutputStream();
- // BUGBUG Per the spec, the default charset is ISO8859_1
- // Servlet 2.3 Section 5.4
-
- /* Get the default file encoding charset */
- String fileEncoding = (new SecureAction()).getProperty("file.encoding", defaultCharset); //$NON-NLS-1$
- if ((fileEncoding == null) || (fileEncoding.length() < 1)) {
- fileEncoding = defaultCharset;
- }
- String fileEncodingAlias = null;
-
- /* We need to look at Accept-Charset from the request to
- * select the encoding charset.
- */
- String accept = request.getHeaderUpper("ACCEPT-CHARSET"); //$NON-NLS-1$
-
- if (accept != null) {
- /*
- * We prefer the file.encoding charset if specified
- * in the Accept-Charset and supported by the JRE. Otherwise,
- * we simply select the first value supported by the
- * JRE. We do not support the q value in Accept-Charset.
- */
-
- Tokenizer tokenizer = new Tokenizer(accept);
-
- parseloop: while (true) {
- String acceptCharset = tokenizer.getToken(",;"); //$NON-NLS-1$
-
- if (!acceptCharset.equals("*")) //$NON-NLS-1$
- {
- try /* is charset valid? */
- {
- String encodingAlias = new OutputStreamWriter(dummy, acceptCharset).getEncoding();
-
- if (charset == null) /* charset has not been set */
- {
- charset = acceptCharset;
- } else {
- if (fileEncodingAlias == null) {
- try {
- fileEncodingAlias = new OutputStreamWriter(dummy, fileEncoding).getEncoding();
- } catch (UnsupportedEncodingException ee) {
- // TODO: consider logging
- }
- }
-
- if (encodingAlias.equals(fileEncodingAlias)) {
- charset = acceptCharset; /* prefer the file.encoding charset */
-
- break parseloop;
- }
- }
- } catch (UnsupportedEncodingException e) {
- /* charset is not supported */
- }
- }
-
- char c = tokenizer.getChar();
-
- if (c == ';') {
- tokenizer.getToken(","); /* ignore q value *///$NON-NLS-1$
- c = tokenizer.getChar();
- }
-
- if (c == '\0') {
- break parseloop;
- }
- }
- }
-
- if (charset == null) /* if Accept-Charset did not produce a valid charset */
- {
- charset = fileEncoding;
-
- try /* is charset valid? */
- {
- new OutputStreamWriter(dummy, charset);
- } catch (UnsupportedEncodingException e) {
- /* charset is not supported */
- charset = defaultCharset;
- }
- }
- }
-
- return (charset);
- }
-
- /**
- * Returns an output stream for writing binary response data.
- *
- * @see getWriter
- * @exception IllegalStateException if getWriter has been
- * called on this same request.
- * @exception IOException if an I/O exception has occurred
- */
- public ServletOutputStream getOutputStream() {
- if (!gotOutputStream) {
- synchronized (this) {
- if (writer != null) {
- throw new IllegalStateException();
- }
- gotOutputStream = true;
- }
- }
-
- return (servletOutputStream);
- }
-
- /**
- * Returns a print writer for writing formatted text responses. The
- * MIME type of the response will be modified, if necessary, to reflect
- * the character encoding used, through the <em>charset=...</em>
- * property. This means that the content type must be set before
- * calling this method.
- *
- * @see getOutputStream
- * @see setContentType
- *
- * @exception UnsupportedEncodingException if no such charset can
- * be provided
- * @exception IllegalStateException if getOutputStream has been
- * called on this same request.
- * @exception IOException on other errors.
- */
- public PrintWriter getWriter() throws IOException {
- if (writer == null) {
- synchronized (this) {
- if (writer == null) {
- if (gotOutputStream) {
- throw new IllegalStateException();
- }
-
- String encoding = getCharacterEncoding();
-
- writer = new ServletPrintWriter(servletOutputStream, encoding);
-
- if (contentType == null) {
- // BUGBUG Must not set a default content type.
- // Servlet 2.3 Section 5.3
- contentType = "text/plain; charset=" + encoding; //$NON-NLS-1$
-
- setHeader("Content-Type", contentType); //$NON-NLS-1$
- } else {
- if (contentType.toLowerCase().indexOf("charset=") == -1) // 99372 //$NON-NLS-1$
- {
- contentType = contentType + "; charset=" + encoding; //$NON-NLS-1$
-
- setHeader("Content-Type", contentType); //$NON-NLS-1$
- }
- }
- }
- }
- }
-
- return (writer);
- }
-
- boolean gotStreamOrWriter() {
- return (writer != null || gotOutputStream);
- }
-
- /**
- * Sends an error response to the client using the specified
- * status code and a default message.
- * @param sc the status code
- * @exception IOException If an I/O error has occurred.
- */
- public void sendError(int statusCode) throws IOException {
- // BUGBUG Must clear buffer if response has not yet been committed
- // or throw an IllegalStateException.
- sendError(statusCode, http.getStatusPhrase(statusCode));
- }
-
- /**
- * Sends an error response to the client using the specified status
- * code and descriptive message. If setStatus has previously been
- * called, it is reset to the error status code. The message is
- * sent as the body of an HTML page, which is returned to the user
- * to describe the problem. The page is sent with a default HTML
- * header; the message is enclosed in simple body tags
- * (&lt;body&gt;&lt;/body&gt;).
- *
- * @param sc the status code
- * @param msg the detail message
- * @exception IOException If an I/O error has occurred.
- */
- public void sendError(int sc, String msg) throws IOException {
- // BUGBUG Must clear buffer if response has not yet been committed
- // or throw an IllegalStateException.
- status = sc;
- statusString = msg;
-
- if (Http.DEBUG) {
- http.logDebug("Error: " + sc + " - " + msg); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- servletOutputStream.print("<html><body><h3>"); //$NON-NLS-1$
- servletOutputStream.print(sc);
- servletOutputStream.print(" - "); //$NON-NLS-1$
- servletOutputStream.print(msg);
- servletOutputStream.print("</h3></body></html>"); //$NON-NLS-1$
- servletOutputStream.close(); /* commit and close the response */
-
- }
-
- /**
- * Sends a temporary redirect response to the client using the
- * specified redirect location URL. The URL must be absolute (for
- * example, <code><em>https://hostname/path/file.html</em></code>).
- * Relative URLs are not permitted here.
- *
- * @param location the redirect location URL
- * @exception IOException If an I/O error has occurred.
- */
- public void sendRedirect(String location) throws IOException {
- // BUGBUG The input URL may be relative. We must translate to
- // a fully qualified URL (it should already have been encoded).
- // If this cannot be done, throw an IllegalArgument exception.
- // BUGBUG Must clear buffer if response has not yet been committed
- // or throw an IllegalStateException.
- setStatus(SC_MOVED_TEMPORARILY);
- setHeader("Location", location); //$NON-NLS-1$
- servletOutputStream.close(); /* commit and close the response */
- }
-
- /**
- * Sets the content length for this response.
- *
- * @param len the content length
- */
-
- public void setContentLength(int len) {
- // BUGBUG response should be considered commited and closed
- // when content length has been written.
- // Not sure if content length is bytes or chars?
- contentLength = len;
- setIntHeader("Content-Length", len); //$NON-NLS-1$
- }
-
- /**
- * Sets the content type for this response. This type may later
- * be implicitly modified by addition of properties such as the MIME
- * <em>charset=&lt;value&gt;</em> if the service finds it necessary,
- * and the appropriate media type property has not been set.
- *
- * <p>This response property may only be assigned one time. If a
- * writer is to be used to write a text response, this method must
- * be called before the method <code>getWriter</code>. If an
- * output stream will be used to write a response, this method must
- * be called before the output stream is used to write response
- * data.
- *
- * @param type the content's MIME type
- * @see getOutputStream
- * @see getWriter */
- public void setContentType(String type) {
- if (contentType == null) {
- synchronized (this) {
- if (contentType == null) {
- contentType = type;
-
- setHeader("Content-Type", type); //$NON-NLS-1$
-
- int index = type.indexOf(';', 0);
- if (index >= 0) {
- Tokenizer tokenizer = new Tokenizer(type);
-
- // TODO: verify next statement. It was String mimetype = tokenizer.getToken(";");
- tokenizer.getToken(";"); //$NON-NLS-1$
- tokenizer.getChar(); /* eat semicolon */
-
- parseloop: while (true) {
- String attribute = tokenizer.getToken("="); //$NON-NLS-1$
- char c = tokenizer.getChar();
-
- if (c != '=') {
- break parseloop; /* invalid content type */
- }
-
- String value = tokenizer.getString(";"); //$NON-NLS-1$
- c = tokenizer.getChar();
-
- if ("charset".equalsIgnoreCase(attribute)) //$NON-NLS-1$
- {
- charset = value;
- }
-
- if (c == '\0') {
- break parseloop;
- }
- }
- }
- }
- }
- }
- }
-
- /**
- * This method was created in VisualAge.
- */
- protected void setCookies() {
- if (cookies == null) {
- return;
- }
-
- int numCookies = cookies.size();
-
- if (numCookies > 0) {
- StringBuffer value = new StringBuffer(256);
-
- for (int i = 0; i < numCookies; i++) {
- Cookie cookie = (Cookie) cookies.elementAt(i);
-
- if (i > 0) {
- value.append(',');
- }
-
- value.append(cookie.getName());
- value.append("=\""); //$NON-NLS-1$
- value.append(cookie.getValue());
- value.append('\"');
- if ((cookie.getVersion()) != 0) {
- value.append(";Version="); //$NON-NLS-1$
- value.append(cookie.getVersion());
- }
- if ((cookie.getComment()) != null) {
- value.append(";Comment=\""); //$NON-NLS-1$
- value.append(cookie.getComment());
- value.append('\"');
- }
- if ((cookie.getDomain()) != null) {
- value.append(";Domain=\""); //$NON-NLS-1$
- value.append(cookie.getDomain());
- value.append('\"');
- }
- if ((cookie.getMaxAge()) != -1) {
- value.append(";Max-Age=\""); //$NON-NLS-1$
- value.append(cookie.getMaxAge());
- value.append('\"');
- }
- if ((cookie.getPath()) != null) {
- value.append(";Path=\""); //$NON-NLS-1$
- value.append(cookie.getPath());
- value.append('\"');
- }
- if (cookie.getSecure()) {
- value.append(";Secure"); //$NON-NLS-1$
- }
- }
-
- setHeader("Set-Cookie", value.toString()); //$NON-NLS-1$
- //System.out.println("Set-Cookie: "+value.toString());
- }
- }
-
- /**
- *
- * Adds a field to the response header with the given name and
- * date-valued field. The date is specified in terms of
- * milliseconds since the epoch. If the date field had already
- * been set, the new value overwrites the previous one. The
- * <code>containsHeader</code> method can be used to test for the
- * presence of a header before setting its value.
- *
- * @param name the name of the header field
- * @param value the header field's date value
- *
- * @see #containsHeader
- */
- public void setDateHeader(String name, long date) {
- HttpDate d = new HttpDate(date);
- setHeader(name, d.toString());
- }
-
- /**
- *
- * Adds a field to the response header with the given name and value.
- * If the field had already been set, the new value overwrites the
- * previous one. The <code>containsHeader</code> method can be
- * used to test for the presence of a header before setting its
- * value.
- *
- * @param name the name of the header field
- * @param value the header field's value
- *
- * @see #containsHeader
- */
- public void setHeader(String name, String value) {
- // BUGBUG Headers set after the response is committed must be ignored
- // Servlet 2.2 Section 6.2
- if (headers == null) {
- synchronized (this) {
- if (headers == null) {
- headers = new Hashtable(31);
- }
- }
- }
- headers.put(name, value);
- }
-
- /**
- * Adds a field to the response header with the given name and
- * integer value. If the field had already been set, the new value
- * overwrites the previous one. The <code>containsHeader</code>
- * method can be used to test for the presence of a header before
- * setting its value.
- *
- * @param name the name of the header field
- * @param value the header field's integer value
- *
- * @see #containsHeader
- */
- public void setIntHeader(String name, int value) {
- setHeader(name, String.valueOf(value));
- }
-
- /**
- * Sets the status code for this response. This method is used to
- * set the return status code when there is no error (for example,
- * for the status codes SC_OK or SC_MOVED_TEMPORARILY). If there
- * is an error, the <code>sendError</code> method should be used
- * instead.
- *
- * @param sc the status code
- *
- * @see #sendError
- */
- public void setStatus(int statusCode) {
- status = statusCode;
- statusString = http.getStatusPhrase(statusCode);
- }
-
- /**
- * Sets the status code and message for this response. If the
- * field had already been set, the new value overwrites the
- * previous one. The message is sent as the body of an HTML
- * page, which is returned to the user to describe the problem.
- * The page is sent with a default HTML header; the message
- * is enclosed in simple body tags (&lt;body&gt;&lt;/body&gt;).
- *
- * @param sc the status code
- * @param sm the status message
- * deprecated
- */
- public void setStatus(int si, String ss) {
- status = si;
- statusString = ss;
-
- }
-
- /**
- * Write the response headers to the ServletOutputStream.
- *
- * @param length Content length of the of the buffered content
- * or -1 if the length is unknown.
- */
- void writeHeaders(int length) throws IOException {
- setCookies();
-
- if ((length != -1) && !containsHeader("Content-Length")) //$NON-NLS-1$
- {
- setContentLength(length);
- }
-
- if (containsHeader("Content-Length")) //$NON-NLS-1$
- {
- String requestConnection = request.getHeaderUpper("CONNECTION"); //$NON-NLS-1$
-
- if (requestConnection != null) {
- if (requestConnection.toLowerCase().indexOf("keep-alive") >= 0) //$NON-NLS-1$
- {
- setHeader("Connection", "Keep-Alive"); //$NON-NLS-1$ //$NON-NLS-2$
-
- keepAlive = true;
- }
- }
- }
-
- if (!keepAlive) {
- setHeader("Connection", "close"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- servletOutputStream.print("HTTP/1.0 "); //$NON-NLS-1$
- servletOutputStream.print(status);
- servletOutputStream.print(" "); //$NON-NLS-1$
- servletOutputStream.println(statusString);
-
- // System.out.print("HTTP/1.0 ");
- // System.out.print(status);
- // System.out.print(" ");
- // System.out.println(statusString);
-
- /* Write response headers */
- if (headers != null) {
- Enumeration headerEnumeration = headers.keys();
- while (headerEnumeration.hasMoreElements()) {
- String name = (String) headerEnumeration.nextElement();
- String value = (String) headers.get(name);
- servletOutputStream.print(name);
- servletOutputStream.print(": "); //$NON-NLS-1$
- servletOutputStream.println(value);
-
- // System.out.print(name);
- // System.out.print(": ");
- // System.out.println(value);
- }
- }
-
- servletOutputStream.println(); /* Terminate the headers */
-
- // System.out.println();
- }
-
- /**
- * @see javax.servlet.http.HttpServletResponse#addDateHeader(String, long)
- */
- public void addDateHeader(String name, long date) throws UnsupportedOperationException {
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
- }
-
- /**
- * @see javax.servlet.http.HttpServletResponse#addHeader(String, String)
- */
- public void addHeader(String name, String value) throws UnsupportedOperationException {
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
- }
-
- /**
- * @see javax.servlet.http.HttpServletResponse#addIntHeader(String, int)
- */
- public void addIntHeader(String name, int value) throws UnsupportedOperationException {
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
- }
-
- /**
- * @see javax.servlet.ServletResponse#flushBuffer()
- */
- public void flushBuffer() throws IOException, UnsupportedOperationException {
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
- }
-
- /**
- * @see javax.servlet.ServletResponse#getBufferSize()
- */
- public int getBufferSize() throws UnsupportedOperationException {
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
- }
-
- /**
- * @see javax.servlet.ServletResponse#getLocale()
- */
- public Locale getLocale() throws UnsupportedOperationException {
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
- }
-
- /**
- * @see javax.servlet.ServletResponse#isCommitted()
- */
- public boolean isCommitted() throws UnsupportedOperationException {
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
- }
-
- /**
- * @see javax.servlet.ServletResponse#reset()
- */
- public void reset() throws UnsupportedOperationException {
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
- }
-
- /**
- * @see javax.servlet.ServletResponse#resetBuffer()
- */
- public void resetBuffer() throws UnsupportedOperationException {
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
- }
-
- /**
- * @see javax.servlet.ServletResponse#setBufferSize(int)
- */
- public void setBufferSize(int size) throws UnsupportedOperationException {
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
- }
-
- /**
- * @see javax.servlet.ServletResponse#setLocale(Locale)
- */
- public void setLocale(Locale loc) throws UnsupportedOperationException {
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
- }
-
- /* JavaServlet 2.4 API - For compilation only. Will not implement.
- *
- */
- public String getContentType() {
- //return contentType;
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
- }
-
- /* For compilation only. Will not implement.
- *
- */
- public void setCharacterEncoding(String arg0) {
- //this.contentType = contentType;
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
-
- }
-}
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/HttpSessionContextImpl.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/HttpSessionContextImpl.java
deleted file mode 100644
index 03e9d6948..000000000
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/HttpSessionContextImpl.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1999, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.http.servlet;
-
-import java.util.Enumeration;
-import java.util.Vector;
-import javax.servlet.http.HttpSession;
-import javax.servlet.http.HttpSessionContext;
-
-/**
- * A HttpSessionContext is a grouping of HttpSessions associated with a single
- * entity. This interface gives servlets access to
- * methods for listing the IDs and for retrieving a session based on its ID.
- *
- * <p>Servlets get the HttpSessionContext object by calling the
- * getSessionContext()
- * method of HttpSession.
- *
- * @see HttpSession
- * @depracated
- */
-public class HttpSessionContextImpl implements HttpSessionContext {
-
- /**
- * Returns an enumeration of all of the session IDs in this context.
- *
- * @return an enumeration of all session IDs in this context
- * @deprecated
- */
- public Enumeration getIds() {
- return ((new Vector(0)).elements());
- }
-
- /**
- * Returns the session bound to the specified session ID.
- *
- * @param sessionID the ID of a particular session object
- * @return the session name. Returns null if the session ID does not refer
- * to a valid session.
- * @depracated
- */
- public HttpSession getSession(String sessionId) {
- return (null);
- }
-}
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/HttpSessionImpl.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/HttpSessionImpl.java
deleted file mode 100644
index 32486a68f..000000000
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/HttpSessionImpl.java
+++ /dev/null
@@ -1,501 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1999, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.http.servlet;
-
-import java.util.Enumeration;
-import java.util.Hashtable;
-import javax.servlet.ServletContext;
-import javax.servlet.http.*;
-import org.eclipse.equinox.http.Http;
-import org.eclipse.equinox.http.HttpMsg;
-
-/**
- * The implementation of the HttpSession interface.
- *
- * <pre>
- *
- * //Get the session object - "request" represents the HTTP servlet request
- * HttpSession session = request.getSession(true);
- * <BR>
- * //Get the session data value - an Integer object is read from
- * //the session, incremented, then written back to the session.
- * //sessiontest.counter identifies values in the session
- * Integer ival = (Integer) session.getValue("sessiontest.counter");
- * if (ival==null)
- * ival = new Integer(1);
- * else
- * ival = new Integer(ival.intValue() + 1);
- * session.putValue("sessiontest.counter", ival);
- *
- * </pre>
- *
- * <P> When an application layer stores or removes data from the
- * session, the session layer checks whether the object implements
- * HttpSessionBindingListener. If it does, then the object is notified
- * that it has been bound or unbound from the session.
- *
- * <P>An implementation of HttpSession represents the server's view
- * of the session. The server considers a session to be new until
- * it has been joined by the
- * client. Until the client joins the session, the isNew method
- * returns true. A value of true can indicate one of these three cases:
- * <UL>
- * <LI>the client does not yet know about the session
- * <LI>the session has not yet begun
- * <LI>the client chooses not to join the session. This case will occur
- * if the client supports
- * only cookies and chooses to reject any cookies sent by the server.
- * If the server supports URL rewriting, this case will not commonly occur.
- * </UL>
- *
- * <P>It is the responsibility of developers
- * to design their applications to account for situations where a client
- * has not joined a session. For example, in the following code
- * snippet isNew is called to determine whether a session is new. If it
- * is, the server will require the client to start a session by directing
- * the client to a welcome page <tt>welcomeURL</tt> where
- * a user might be required to enter some information and send it to the
- * server before gaining access to
- * subsequent pages.
- *
- * <pre>
- * //Get the session object - "request" represents the HTTP servlet request
- * HttpSession session = request.getSession(true);
- * <BR>
- * //insist that the client starts a session
- * //before access to data is allowed
- * //"response" represents the HTTP servlet response
- * if (session.isNew()) {
- * response.sendRedirect (welcomeURL);
- * }
- *
- * </pre>
- *
- * @see HttpSessionBindingListener
- * @see HttpSessionContext
- *
- */
-
-public class HttpSessionImpl implements HttpSession {
- protected Http http;
- protected String sessionId;
- protected Hashtable values;
- protected long creationTime; /* milliseconds */
- protected long lastAccess; /* milliseconds */
- protected boolean isValid;
- protected boolean canExpire;
- protected Cookie cookie;
- protected long maxInactive; /* milliseconds */
- // BUGBUG cookie name MUST be "JSESSIONID"
- // Servlet 2.2 Section 7.1.2
- protected static final String sessionCookieName = "org.eclipse.equinox.http.session"; //$NON-NLS-1$
-
- protected HttpSessionImpl(Http http) {
- this.http = http;
- lastAccess = -1;
- maxInactive = -1;
- canExpire = false;
- isValid = true;
- sessionId = String.valueOf(hashCode());
- values = new Hashtable();
- creationTime = System.currentTimeMillis();
- cookie = new Cookie(sessionCookieName, sessionId);
- // BUGBUG Sessions should be ServletContext specific. That is
- // the ServletContext should manage the sessions.
- // Servlet 2.2 Section 7.3
- http.addSession(this);
- }
-
- /**
- * Return the cookie associated with this session.
- *
- * @return Session cookie
- */
- protected Cookie getCookie() {
- return (cookie);
- }
-
- /**
- * Returns the time at which this session representation was created,
- * in milliseconds since midnight, January 1, 1970 UTC.
- *
- * @return the time when the session was created
- */
- public long getCreationTime() {
- return (creationTime);
- }
-
- /**
- * Returns the identifier assigned to this session. An HttpSession's
- * identifier is a unique string that is created and maintained by
- * HttpSessionContext.
- *
- * @return the identifier assigned to this session
- */
- public String getId() {
- return (sessionId);
- }
-
- /**
- * Returns the last time the client sent a request carrying the identifier
- * assigned to the session, or -1 if the session is new. Time is expressed
- * as milliseconds since midnight, January 1,
- * 1970 UTC.
- *
- * Application level operations, such as getting or setting a value
- * associated with the session, do not affect the access time.
- *
- * <P> This information is particularly useful in session management
- * policies. For example,
- * <UL>
- * <LI>a session manager could leave all sessions
- * which have not been used in a long time
- * in a given context.
- * <LI>the sessions can be sorted according to age to optimize some task.
- * </UL>
- *
- * @return the last time the client sent a request carrying the identifier
- * assigned to the session
- */
- public long getLastAccessedTime() {
- return (lastAccess);
- }
-
- /**
- * Returns the maximum amount of time, in seconds, that a session is
- * guaranteed to be maintained in the servlet engine without a request from
- * the client. After the maximum inactive time, the session may be expired
- * by the servlet engine. If this session will not expire, this method will
- * return -1. This method should throw an IllegalStateException if it is
- * called after this session has been invalidated.
- *
- * @return
- * @throws IllegalStateException
- */
- public int getMaxInactiveInterval() {
- checkValid();
-
- if (canExpire) {
- return ((int) (maxInactive / 1000L));
- }
- return (-1);
- }
-
- /**
- * Sets the amount of time that a session can be inactive
- * before the servlet engine is allowed to expire it.
- *
- * @param interval Time in seconds.
- */
- public void setMaxInactiveInterval(int interval) {
- if (isValid) {
- if (interval == -1) {
- maxInactive = -1;
- canExpire = false;
- } else {
- if (interval < 0) {
- throw new IllegalArgumentException("negative value"); //$NON-NLS-1$
- }
- maxInactive = interval * 1000L;
- canExpire = true;
- }
- }
- }
-
- /**
- * Returns the context object within which sessions on the server are held.
- *
- * This method has been deprecated as all the methods of HttpSessionContext
- * are deprecated. This method should now return an object which has an
- * empty implementation of the HttpSessionContext interface.
- *
- * @return An empty implementation of the HttpSessionContext interface.
- * @deprecated As of Servlet version 2.1.
- */
- public HttpSessionContext getSessionContext() {
- return (new HttpSessionContextImpl());
- }
-
- /**
- * Returns the object bound to the given name in the session's
- * application layer data. Returns null if there is no such binding.
- *
- * @param name the name of the binding to find
- * @return the value bound to that name, or null if the binding does
- * not exist.
- * @exception IllegalStateException if an attempt is made to access
- * HttpSession's session data after it has been invalidated
- */
- public Object getValue(String name) {
- checkValid();
-
- return (values.get(name));
- }
-
- /**
- * Returns an array of the names of all the application layer
- * data objects bound into the session. For example, if you want to delete
- * all of the data objects bound into the session, use this method to
- * obtain their names.
- *
- * @return an array containing the names of all of the application layer
- * data objects bound into the session
- * @exception IllegalStateException if an attempt is made to access
- * session data after the session has been invalidated
- */
- public String[] getValueNames() {
- checkValid();
-
- return (getValueNames0());
- }
-
- private String[] getValueNames0() {
- synchronized (values) {
- int size = values.size();
- String[] names = new String[size];
-
- if (size > 0) {
- int i = 0;
- Enumeration valueEnumeration = values.keys();
- while (valueEnumeration.hasMoreElements()) {
- names[i] = (String) valueEnumeration.nextElement();
- i++;
- }
- }
-
- return (names);
- }
- }
-
- /**
- * Causes this representation of the session to be invalidated and removed
- * from its context.
- *
- */
- public synchronized void invalidate() {
- if (isValid) {
- /*
- * Remove session.
- */
- http.removeSession(this);
-
- /*
- * Unbind values.
- */
- String[] names = getValueNames0();
- int size = names.length;
-
- for (int i = 0; i < size; i++) {
- String name = names[i];
-
- Object oldValue = values.remove(name);
-
- unbound(name, oldValue);
- }
-
- /*
- * invalidate session
- */
- isValid = false;
- values = null;
- canExpire = false;
- }
- }
-
- /**
- * A session is considered to be "new" if it has been created by the server,
- * but the client has not yet acknowledged joining the session. For example,
- * if the server supported only cookie-based sessions and the client had
- * completely disabled the use of cookies, then calls to
- * HttpServletRequest.getSession() would
- * always return "new" sessions.
- *
- * @return true if the session has been created by the server but the
- * client has not yet acknowledged joining the session; false otherwise
- * @exception IllegalStateException if an attempt is made to access
- * session data after the session has been invalidated
- */
- public boolean isNew() {
- checkValid();
-
- return (lastAccess == -1);
- }
-
- /**
- * Binds the specified object into the session's application layer data
- * with the given name. Any existing binding with the same name is
- * replaced. New (or existing) values that implement the
- * HttpSessionBindingListener interface will call its
- * valueBound() method.
- *
- * @param name the name to which the data object will be bound. This
- * parameter cannot be null.
- * @param value the data object to be bound. This parameter cannot be null.
- * @exception IllegalStateException if an attempt is made to access
- * session data after the session has been invalidated
- */
- public void putValue(String name, Object value) {
- checkValid();
-
- Object oldValue = values.put(name, value);
-
- unbound(name, oldValue);
-
- // BUGBUG valueBound must be called before the object is available
- // via getValue.
- // Servlet 2.2 Section 7.4
- bound(name, value);
- }
-
- /**
- * Notify HttpSessionBindingListener of valueBound event.
- *
- * @param name the name to which the data object will be bound. This
- * parameter cannot be null.
- * @param value the data object to be bound. This parameter cannot be null.
- */
- private void bound(String name, Object value) {
- if (value instanceof HttpSessionBindingListener) {
- HttpSessionBindingEvent e = new HttpSessionBindingEvent(this, name);
-
- try {
- ((HttpSessionBindingListener) value).valueBound(e);
- } catch (Throwable t) {
- if (Http.DEBUG) {
- http.logDebug("HttpSessionImpl.putValue event exception", t); //$NON-NLS-1$
- }
- }
- }
- }
-
- /**
- * Removes the object bound to the given name in the session's
- * application layer data. Does nothing if there is no object
- * bound to the given name. The value that implements the
- * HttpSessionBindingListener interface will call its
- * valueUnbound() method.
- *
- * @param name the name of the object to remove
- * @exception IllegalStateException if an attempt is made to access
- * session data after the session has been invalidated
- */
- public void removeValue(String name) {
- checkValid();
-
- Object oldValue = values.remove(name);
-
- unbound(name, oldValue);
- }
-
- /**
- * Notify HttpSessionBindingListener of valueUnbound event.
- *
- * @param name the name to which the data object will be bound. This
- * parameter cannot be null.
- * @param value the data object to be bound.
- */
- private void unbound(String name, Object value) {
- if (value instanceof HttpSessionBindingListener) {
- HttpSessionBindingEvent e = new HttpSessionBindingEvent(this, name);
-
- try {
- ((HttpSessionBindingListener) value).valueUnbound(e);
- } catch (Throwable t) {
- if (Http.DEBUG) {
- http.logDebug("HttpSessionImpl.removeValue event exception", t); //$NON-NLS-1$
- }
- }
- }
- }
-
- /**
- * If the session has expired, invalidate it.
- * If access it true and the session is valid, update
- * the lastAccess time.
- *
- * @return true if the session is valid.
- */
- public boolean isValid(boolean access) {
- if (canExpire) {
- long currentTime = System.currentTimeMillis();
-
- long compareTime = (lastAccess == -1) ? creationTime : lastAccess;
-
- if ((currentTime - compareTime) > maxInactive) {
- invalidate();
- }
- }
-
- if (access && isValid) {
- lastAccess = System.currentTimeMillis();
- }
-
- return (isValid);
- }
-
- /**
- * If the session has expired, invalidate it.
- * If the session is invalid, throw an IllegalStateException
- *
- * @throws IllegalStateException.
- */
- private void checkValid() {
- if (canExpire) {
- long currentTime = System.currentTimeMillis();
-
- long compareTime = (lastAccess == -1) ? creationTime : lastAccess;
-
- if ((currentTime - compareTime) > maxInactive) {
- invalidate();
- }
- }
-
- if (!isValid) {
- throw new IllegalStateException("HttpSession has been invalidated"); //$NON-NLS-1$
- }
- }
-
- /**
- * @see javax.servlet.http.HttpSession#getAttribute(String)
- */
- public Object getAttribute(String name) throws UnsupportedOperationException {
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
- }
-
- /**
- * @see javax.servlet.http.HttpSession#getAttributeNames()
- */
- public Enumeration getAttributeNames() throws UnsupportedOperationException {
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
- }
-
- /**
- * @see javax.servlet.http.HttpSession#getServletContext()
- */
- public ServletContext getServletContext() throws UnsupportedOperationException {
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
- }
-
- /**
- * @see javax.servlet.http.HttpSession#removeAttribute(String)
- */
- public void removeAttribute(String name) throws UnsupportedOperationException {
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
- }
-
- /**
- * @see javax.servlet.http.HttpSession#setAttribute(String, Object)
- */
- public void setAttribute(String name, Object value) throws UnsupportedOperationException {
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/RequestDispatcherImpl.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/RequestDispatcherImpl.java
deleted file mode 100644
index a89a6ed03..000000000
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/RequestDispatcherImpl.java
+++ /dev/null
@@ -1,294 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1999, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.http.servlet;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.Locale;
-import javax.servlet.*;
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletResponse;
-import org.eclipse.equinox.http.HttpMsg;
-import org.eclipse.equinox.http.Registration;
-
-public class RequestDispatcherImpl implements RequestDispatcher {
- protected Registration reg;
- protected String requestURI;
-
- class Response implements HttpServletResponse {
- protected ServletResponse response;
-
- protected Response(ServletResponse response) {
- this.response = response;
- }
-
- public String getCharacterEncoding() {
- return (null);
- }
-
- public PrintWriter getWriter() throws IOException {
- return (response.getWriter());
- }
-
- public ServletOutputStream getOutputStream() throws IOException {
- return (response.getOutputStream());
- }
-
- public String encodeRedirectURL(String url) {
- return (null);
- }
-
- public String encodeRedirectUrl(String url) {
- return (null);
- }
-
- public String encodeURL(String url) {
- return (null);
- }
-
- public String encodeUrl(String url) {
- return (null);
- }
-
- public void sendRedirect(String url) {
- // do nothing
- }
-
- public boolean containsHeader(String header) {
- return (false);
- }
-
- public void addCookie(Cookie cookie) {
- // do nothing
- }
-
- public void sendError(int errorCode) {
- // do nothing
- }
-
- public void sendError(int errorCode, String error) {
- // do nothing
- }
-
- public void setContentLength(int length) {
- // do nothing
- }
-
- public void setContentType(String contentType) {
- // do nothing
- }
-
- public void setStatus(int status) {
- // do nothing
- }
-
- public void setStatus(int status, String statusPhrase) {
- // do nothing
- }
-
- public void setHeader(String key, String value) {
- // do nothing
- }
-
- public void setIntHeader(String key, int value) {
- // do nothing
- }
-
- public void setDateHeader(String key, long date) {
- // do nothing
- }
-
- /**
- * @see javax.servlet.http.HttpServletResponse#addDateHeader(String, long)
- */
- public void addDateHeader(String name, long date) throws UnsupportedOperationException {
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
- }
-
- /**
- * @see javax.servlet.http.HttpServletResponse#addHeader(String, String)
- */
- public void addHeader(String name, String value) throws UnsupportedOperationException {
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
- }
-
- /**
- * @see javax.servlet.http.HttpServletResponse#addIntHeader(String, int)
- */
- public void addIntHeader(String name, int value) throws UnsupportedOperationException {
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
- }
-
- /**
- * @see javax.servlet.ServletResponse#flushBuffer()
- */
- public void flushBuffer() throws IOException, UnsupportedOperationException {
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
- }
-
- /**
- * @see javax.servlet.ServletResponse#getBufferSize()
- */
- public int getBufferSize() throws UnsupportedOperationException {
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
- }
-
- /**
- * @see javax.servlet.ServletResponse#getLocale()
- */
- public Locale getLocale() throws UnsupportedOperationException {
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
- }
-
- /**
- * @see javax.servlet.ServletResponse#isCommitted()
- */
- public boolean isCommitted() throws UnsupportedOperationException {
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
- }
-
- /**
- * @see javax.servlet.ServletResponse#reset()
- */
- public void reset() throws UnsupportedOperationException {
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
- }
-
- /**
- * @see javax.servlet.ServletResponse#resetBuffer()
- */
- public void resetBuffer() throws UnsupportedOperationException {
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
- }
-
- /**
- * @see javax.servlet.ServletResponse#setBufferSize(int)
- */
- public void setBufferSize(int size) throws UnsupportedOperationException {
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
- }
-
- /**
- * @see javax.servlet.ServletResponse#setLocale(Locale)
- */
- public void setLocale(Locale loc) throws UnsupportedOperationException {
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
- }
-
- /*
- * JavaServlet 2.4 API - For complilation only - Not Implemented
- */
- public String getContentType() {
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
- }
-
- /*
- * JavaServlet 2.4 API - For complilation only - Not Implemented
- */
- public void setCharacterEncoding(String arg0) {
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
-
- }
-
- }
-
- public RequestDispatcherImpl(Registration reg, String requestURI) {
- this.reg = reg;
- this.requestURI = requestURI;
- }
-
- /**
- * Used for forwarding a request from this servlet to another
- * resource on the server. This method is useful when one servlet
- * does preliminary processing of a request and wants to let
- * another object generate the response.
- *
- * <p>The <tt>request</tt> object passed to the target object
- * will have its request URL path and other path parameters
- * adjusted to reflect the target URL path of the target ojbect.
- *
- * <p>You cannot use this method if a <tt>ServletOutputStream</tt>
- * object or <tt>PrintWriter</tt> object has been obtained from
- * the response. In that case, the method throws an
- * <tt>IllegalStateException</tt>
- *
- * @param request the client's request on the servlet
- * @param response the client's response from the servlet
- * @exception ServletException if a servlet exception is thrown by the
- * target servlet
- * @exception IOException if an I/O Exception occurs
- * @exception IllegalStateException if the ServletOutputStream or a writer
- * had allready been obtained from the response object
- */
- public void forward(ServletRequest req, ServletResponse res) throws ServletException, IOException {
- // BUGBUG If the response has already been committed, then an
- // IllegalStateException must be thrown. Otherwise, the response
- // buffer must be cleared before calling.
- // Servlet 2.2 Section 8.4
- try {
- HttpServletRequestImpl request = (HttpServletRequestImpl) req;
- HttpServletResponseImpl response = (HttpServletResponseImpl) res;
-
- if (response.gotStreamOrWriter()) {
- throw new IllegalStateException();
- }
-
- String newRequestLine = request.getMethod() + " " + requestURI + " " + request.getProtocol(); //$NON-NLS-1$ //$NON-NLS-2$
- request.parseRequestLine(newRequestLine);
-
- reg.service(request, response);
-
- // BUGBUG Response must be committed and closed before returning.
- // Servlet 2.2 Section 8.4
- } catch (ClassCastException e) {
- throw new ServletException(HttpMsg.HTTP_SERVLET_EXCEPTION, e);
- }
- }
-
- /**
- * Used for including the content generated by another server
- * resource in the body of a response. In essence, this method
- * enables programmatic server side includes.
- *
- * <p>The request object passed to the target object will reflect
- * the request URL path and path info of the calling request.
- * The response object only has access to the calling servlet's
- * <tt>ServletOutputStream</tt> object or <tt>PrintWriter</tt>
- * object.
- *
- * <p>An included servlet cannot set headers. If the included
- * servlet calls a method that may need to set headers (such as
- * sessions might need to), the method is not guaranteed to work.
- * As a servlet developer, you must ensure that any methods
- * that might need direct access to headers are properly resolved.
- * To ensure that a session works correctly, start the session
- * outside of the included servlet, even if you use session tracking.
- *
- * @param request the client's request on the servlet
- * @param response the client's response from the servlet
- * @exception ServletException if a servlet exception is thrown by the
- * target servlet
- * @exception IOException if the ServletOutputStream or a writer
- * had already been obtained from the response object
- */
- public void include(ServletRequest req, ServletResponse res) throws ServletException, IOException {
- // BUGBUG need to set javax.servlet.include.* request
- // attributes before calling.
- // Servlet 2.2 Section 8.3.1
- try {
- ServletResponse response = new Response(res);
-
- reg.service(req, response);
- } catch (ClassCastException e) {
- throw new ServletException(HttpMsg.HTTP_SERVLET_EXCEPTION, e);
- }
- }
-}
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/ServletConfigImpl.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/ServletConfigImpl.java
deleted file mode 100644
index dea55d091..000000000
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/ServletConfigImpl.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1999, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.http.servlet;
-
-import java.util.*;
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletContext;
-import org.eclipse.equinox.http.HttpMsg;
-
-public class ServletConfigImpl implements ServletConfig {
- protected ServletContext servletContext;
- protected Dictionary initParams;
-
- public ServletConfigImpl(ServletContext context, Dictionary params) {
- servletContext = context;
- initParams = params;
- }
-
- /**
- *
- * Returns a string containing the value of the named
- * initialization parameter of the servlet, or null if the
- * parameter does not exist. Init parameters have a single string
- * value; it is the responsibility of the servlet writer to
- * interpret the string.
- *
- * @param name the name of the parameter whose value is requested
- */
- public String getInitParameter(String name) {
- if (initParams != null) {
- return ((String) initParams.get(name));
- }
- return (null);
- }
-
- /**
- * Returns the names of the servlet's initialization parameters
- * as an enumeration of strings, or an empty enumeration if there
- * are no initialization parameters.
- */
- public Enumeration getInitParameterNames() {
- if (initParams != null) {
- return (initParams.keys());
- }
- return (new Vector(0).elements());
- }
-
- /**
- * Returns the context for the servlet.
- */
-
- public ServletContext getServletContext() {
- return (servletContext);
- }
-
- /**
- * @see javax.servlet.ServletConfig#getServletName()
- */
- public String getServletName() throws UnsupportedOperationException {
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/ServletContextImpl.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/ServletContextImpl.java
deleted file mode 100644
index c26830b06..000000000
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/ServletContextImpl.java
+++ /dev/null
@@ -1,446 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1999, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.http.servlet;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.*;
-import javax.servlet.*;
-import org.eclipse.equinox.http.*;
-import org.osgi.service.http.HttpContext;
-
-public class ServletContextImpl implements ServletContext {
- protected Hashtable attributes = null;
- protected Http http;
- protected HttpListener listener;
- protected HttpContext httpContext;
- protected int useCount;
-
- public ServletContextImpl(Http http, HttpListener listener, HttpContext httpContext) {
- this.http = http;
- this.listener = listener;
- this.httpContext = httpContext;
- useCount = 0;
- }
-
- public int incrUseCount() {
- useCount++;
-
- return (useCount);
- }
-
- public int decrUseCount() {
- useCount--;
-
- return (useCount);
- }
-
- /**
- * Returns the value of the named attribute of the network service,
- * or null if the attribute does not exist. This method allows
- * access to additional information about the service, not already
- * provided by the other methods in this interface. Attribute names
- * should follow the same convention as package names. The package
- * names java.* and javax.* are reserved for use by Javasoft, and
- * com.sun.* is reserved for use by Sun Microsystems.
- *
- * @param name the name of the attribute whose value is required
- * @return the value of the attribute, or null if the attribute
- * does not exist.
- */
- public Object getAttribute(String name) {
- if (attributes != null) {
- return (attributes.get(name));
- }
-
- return (null);
- }
-
- /**
- * Returns an enumeration of the attribute names present in this
- * context.
- */
-
- public Enumeration getAttributeNames() {
- if (attributes != null) {
- return (attributes.keys());
- }
-
- return ((new Vector(0).elements()));
- }
-
- /**
- * Returns a <tt>ServletContext</tt> object for a particular
- * URL path. This allows servlets to potentially gain access
- * to the resources and to obtain <tt>RequestDispatcher</tt>
- * objects from the target context.
- *
- * <p>In security concious environments, the servlet engine
- * may always return null for any given URL path.
- *
- * @param uripath
- */
-
- //We should be the only ServletContext out there.
- public ServletContext getContext(String uripath) {
- Registration reg = listener.getRegistration(uripath);
-
- if (reg == null) {
- return (null);
- }
-
- if (httpContext != reg.getHttpContext()) {
- return (null);
- }
-
- return (this);
- }
-
- /**
- * Returns the major version of the servlet API that this
- * servlet engine supports. All 2.1 compliant implementations
- * must return the integer 2 from this method.
- *
- * @return 2
- */
-
- public int getMajorVersion() {
- return (2);
- }
-
- /**
- * Returns the mime type of the specified file, or null if not known.
- * @param file name of the file whose mime type is required
- */
- public String getMimeType(String file) {
- String mimeType = httpContext.getMimeType(file);
- if (mimeType != null)
- return (mimeType);
- return (http.getMimeType(file));
- }
-
- /**
- * Returns the minor version of the servlet API that this
- * servlet engine supports. All 2.1 compliant implementations
- * must return the integer 1 from this method.
- *
- * @return 1
- */
-
- public int getMinorVersion() {
- return (1);
- }
-
- /**
- * Applies alias rules to the specified virtual path in URL path
- * format, that is, <tt>/dir/dir/file.ext</tt>. Returns a
- * String representing the corresponding real path in the
- * format that is appropriate for the operating system the
- * servlet engine is running under (including the proper path
- * separators).
- *
- * <p>This method returns null if the translation could not
- * be performed for any reason.
- *
- * @param path the virtual path to be translated into a real path
- */
-
- public String getRealPath(String path) {
- /* We always return null because our web applications
- * originate in bundles and there is no path on the local
- * file system for the bundles contents.
- */
- return (null);
- }
-
- /**
- * Returns a <tt>RequestDispatcher</tt> object for the specified
- * URL path if the context knows of an active source (such as
- * a servlet, JSP page, CGI script, etc) of content for the
- * particular path. This format of the URL path must be of the
- * form <tt>/dir/dir/file.ext</tt>. The servlet engine is responsible
- * for implementing whatever functionality is required to
- * wrap the target source with an implementation of the
- * <tt>RequestDispatcher</tt> interface.
- *
- * <p>This method will return null if the context cannot provide
- * a dispatcher for the path provided.
- *
- * @param urlpath Path to use to look up the target server resource
- * @see RequestDispatcher
- */
- public RequestDispatcher getRequestDispatcher(String urlpath) {
- // BUGBUG need to support query string in the urlpath
- // Servlet 2.2 Section 8.1.1
-
- if (Http.DEBUG) {
- http.logDebug(" getRequestDispatcher: " + urlpath); //$NON-NLS-1$
- }
-
- Registration reg = listener.getRegistration(urlpath);
-
- if (reg == null) {
- return (null);
- }
-
- if (httpContext != reg.getHttpContext()) {
- return (null);
- }
-
- return (new RequestDispatcherImpl(reg, urlpath));
- }
-
- /**
- * Returns a URL object of a resource that is mapped to a
- * corresponding URL path. The URL path must be of the form
- * <tt>/dir/dir/file.ext</tt>. This method allows a servlet
- * to access content to be served from the servlet engines
- * document space in a system independent manner. Resources
- * could be located on the local file system, a remote
- * file system, a database, or a remote network site.
- *
- * <p>This method may return null if there is no resource
- * mapped to the given URL path.
- *
- * <p>The servlet engine must implement whatever URL handlers
- * and <tt>URLConnection</tt> objects are necessary to access
- * the given content.
- *
- * <p>This method does not fill the same purpose as the
- * <tt>getResource</tt> method of <tt>java.lang.Class</tt>.
- * The method in <tt>java.lang.Class</tt> looks up resources
- * based on class loader. This method allows servlet engines
- * to make resources avaialble to a servlet from any source
- * without regards to class loaders, location, etc.
- *
- * @param path Path of the content resource
- * @exception MalformedURLException if the resource path is
- * not properly formed.
- */
-
- public URL getResource(String path) throws MalformedURLException {
- return (httpContext.getResource(path));
-
- }
-
- /**
- * Returns an <tt>InputStream</tt> object allowing access to
- * a resource that is mapped to a corresponding URL path. The
- * URL path must be of the form <tt>/dir/dir/file.ext</tt>.
- *
- * <p>Note that meta-information such as content length and
- * content type that are available when using the
- * <tt>getResource</tt> method of this class are lost when
- * using this method.
- *
- * <p>This method may return null if there is no resource
- * mapped to the given URL path.
- * <p>The servlet engine must implement whatever URL handlers
- * and <tt>URLConnection</tt> objects are necessary to access
- * the given content.
- *
- * <p>This method does not fill the same purpose as the
- * <tt>getResourceAsStream</tt> method of <tt>java.lang.Class</tt>.
- * The method in <tt>java.lang.Class</tt> looks up resources
- * based on class loader. This method allows servlet engines
- * to make resources avaialble to a servlet from any source
- * without regards to class loaders, location, etc.
- *
- * @param name
- */
-
- public InputStream getResourceAsStream(String path) {
- try {
- URL url = httpContext.getResource(path);
- if (url != null)
- return url.openStream();
- } catch (IOException ex) {
- // TODO: consider logging
- }
- return null;
- }
-
- /**
- * Returns the name and version of the network service under which
- * the servlet is running. The form of this string must begin with
- * <tt>&lt;servername&gt;/&lt;versionnumber&gt;</tt>. For example
- * the Java Web Server could return a string of the form
- * <tt>Java Web Server/1.1.3</tt>. Other optional information
- * can be returned in parenthesis after the primary string. For
- * example, <tt>Java Web Server/1.1.3 (JDK 1.1.6; Windows NT 4.0 x86)
- * </tt>.
- */
- public String getServerInfo() {
- return ("IBM Service Management Framework HttpService/1.0"); //$NON-NLS-1$
- }
-
- /**
- * Originally defined to return a servlet from the context
- * with the specified name. This method has been deprecated and
- * only remains to preserve binary compatibility.
- * This method will always return null.
- *
- * @deprecated This method has been deprecated for
- * servlet lifecycle reasons. This method will be permanently
- * removed in a future version of the Servlet API.
- */
- public Servlet getServlet(String name) {
- return (null);
- }
-
- /**
- * Originally defined to return an <tt>Enumeration</tt> of
- * <tt>String</tt> objects containing all the servlet names
- * known to this context.
- * This method has been deprecated and only remains to preserve
- * binary compatibility. This methd must always return an
- * empty enumeration.
- *
- * @deprecated This method has been deprecated for
- * servlet lifecycle reasons. This method will be permanently
- * removed in a future version of the Servlet API.
- */
- public Enumeration getServletNames() {
- return ((new Vector(0).elements()));
- }
-
- /**
- * Originally defined to return an <tt>Enumeration</tt> of
- * <tt>Servlet</tt> objects containing all the servlets
- * known to this context.
- * This method has been deprecated and only remains to preserve
- * binary compatibility. This method must always return an empty
- * enumeration.
- *
- * @deprecated This method has been deprecated for
- * servlet lifecycle reasons. This method will be permanently
- * removed in a future version of the Servlet API.
- */
- public Enumeration getServlets() {
- return ((new Vector(0).elements()));
- }
-
- /**
- * Logs the specified message and a stack trace of the given
- * exception to the context's log. The
- * name and type of the servlet log is servlet engine specific,
- * but is normally an event log.
- *
- * @param exception the exception to be written
- * @param msg the message to be written
- *
- * @deprecated Use log(String message, Throwable t) instead
- */
- public void log(Exception exception, String msg) {
- log(msg, exception);
- }
-
- /**
- * Logs the specified message to the context's log. The
- * name and type of the servlet log is servlet engine specific,
- * but is normally an event log.
- *
- * @param msg the message to be written
- */
- public void log(String msg) {
- http.logInfo(msg);
- }
-
- /**
- * Logs the specified message and a stack trace of the given
- * <tt>Throwable</tt> object to the context's log. The
- * name and type of the servlet log is servlet engine specific,
- * but is normally an event log.
- *
- * @param msg the message to be written
- * @param throwable the exception to be written
- */
-
- public void log(String message, Throwable throwable) {
- http.logError(message, throwable);
- }
-
- /**
- * Removes the attribute from the context that is bound to a particular
- * name.
- *
- * @param name the name of the attribute to remove from the context
- */
-
- public void removeAttribute(String name) {
- if (attributes != null) {
- attributes.remove(name);
- }
- }
-
- /**
- * Binds an object to a given name in this context. If an object
- * is allready bound into the context with the given name,
- * it will be replaced.
- *
- * Attribute names should follow the same convention as package names.
- * Names matching java.*, javax.*, and sun.* are reserved for
- * definition by this specification or by the reference implementation.
- *
- * @param name the name of the attribute to store
- * @param value the value of the attribute
- */
-
- public void setAttribute(String name, Object object) {
- if (attributes == null) {
- synchronized (this) {
- if (attributes == null) {
- attributes = new Hashtable(31);
- }
- }
- }
-
- attributes.put(name, object);
- }
-
- /**
- * @see javax.servlet.ServletContext#getInitParameter(String)
- */
- public String getInitParameter(String name) throws UnsupportedOperationException {
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
- }
-
- /**
- * @see javax.servlet.ServletContext#getInitParameterNames()
- */
- public Enumeration getInitParameterNames() throws UnsupportedOperationException {
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
- }
-
- /**
- * @see javax.servlet.ServletContext#getNamedDispatcher(String)
- */
- public RequestDispatcher getNamedDispatcher(String name) throws UnsupportedOperationException {
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
- }
-
- /**
- * @see javax.servlet.ServletContext#getResourcePaths(String)
- */
- public Set getResourcePaths(String path) throws UnsupportedOperationException {
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
- }
-
- /**
- * @see javax.servlet.ServletContext#getServletContextName()
- */
- public String getServletContextName() throws UnsupportedOperationException {
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/ServletInputStreamImpl.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/ServletInputStreamImpl.java
deleted file mode 100644
index 37c326f2d..000000000
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/ServletInputStreamImpl.java
+++ /dev/null
@@ -1,515 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1999, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.http.servlet;
-
-import java.io.IOException;
-import java.io.InputStream;
-import javax.servlet.ServletInputStream;
-
-/**
- * An input stream for reading servlet requests, it provides an
- * efficient readLine method. This is an abstract class, to be
- * implemented by a network services writer. For some application
- * protocols, such as the HTTP POST and PUT methods, servlet writers
- * use the input stream to get data from clients. They access the
- * input stream via the ServletRequest's getInputStream method,
- * available from within the servlet's service method. Subclasses of
- * ServletInputStream must provide an implementation of the read()
- * method.
- *
- * <p>
- * This InputStream Object just forwards all requests to the real InputStream object
- * It is intended that that would be the real Sock InputStream. This has some
- * problems if we ever need to restart the stream with another Servlet/etc, so this
- * may need to change some day change.
- */
-public class ServletInputStreamImpl extends ServletInputStream {
- private InputStream in;
- private ServletInputStream servletInputStream = null;
-
- protected ServletInputStreamImpl(InputStream in) {
- super();
- this.in = in;
- }
-
- private void checkOpen() throws IOException {
- if (in == null) {
- throw new IOException("ServletInputStream closed"); //$NON-NLS-1$
- }
- }
-
- /**
- * Returns the number of bytes that can be read from this input
- * stream without blocking. The available method of
- * <code>InputStream</code> returns <code>0</code>. This method
- * <B>should</B> be overridden by subclasses.
- *
- * @return the number of bytes that can be read from this input stream
- * without blocking.
- * @exception IOException if an I/O error occurs.
- * @since JDK1.0
- */
- public int available() throws IOException {
- checkOpen();
-
- return in.available();
- }
-
- /**
- * Closes this input stream and releases any system resources
- * associated with the stream.
- * <p>
- * The <code>close</code> method of <code>InputStream</code> does nothing.
- *
- * @exception IOException if an I/O error occurs.
- * @since JDK1.0
- */
- public void close() throws IOException {
- in = null;
- }
-
- /**
- * Return the ServletInputStream to use for reading data after the
- * HTTP headers have been read. If a Content-Length header is available
- *
- * @param len Content-Length of InputStream
- * @return InputStream for use by servlets
- * @exception
- */
- ServletInputStream getServletInputStream(int len) {
- if (servletInputStream == null) {
- synchronized (this) {
- if (servletInputStream == null) {
- if (len > 0) {
- servletInputStream = new ContentLength(this, len);
- } else {
- servletInputStream = this;
- }
- }
- }
- }
-
- return servletInputStream;
- }
-
- /**
- * Marks the current position in this input stream. A subsequent
- * call to the <code>reset</code> method repositions this stream at
- * the last marked position so that subsequent reads re-read the same
- * bytes.
- * <p>
- * The <code>readlimit</code> arguments tells this input stream to
- * allow that many bytes to be read before the mark position gets
- * invalidated.
- * <p>
- * The <code>mark</code> method of <code>InputStream</code> does nothing.
- *
- * @param readlimit the maximum limit of bytes that can be read before
- * the mark position becomes invalid.
- * @see java.io.InputStream#reset()
- * @since JDK1.0
- */
- public void mark(int readLimit) {
- in.mark(readLimit);
- }
-
- /**
- * Tests if this input stream supports the <code>mark</code>
- * and <code>reset</code> methods. The <code>markSupported</code>
- * method of <code>InputStream</code> returns <code>false</code>.
- *
- * @return <code>true</code> if this true type supports the mark and reset
- * method; <code>false</code> otherwise.
- * @see java.io.InputStream#mark(int)
- * @see java.io.InputStream#reset()
- * @since JDK1.0
- */
- public boolean markSupported() {
- return in.markSupported();
- }
-
- /**
- * Reads the next byte of data from this input stream. The value
- * byte is returned as an <code>int</code> in the range
- * <code>0</code> to <code>255</code>. If no byte is available
- * because the end of the stream has been reached, the value
- * <code>-1</code> is returned. This method blocks until input data
- * is available, the end of the stream is detected, or an exception
- * is thrown.
- * <p>
- * A subclass must provide an implementation of this method.
- *
- * @return the next byte of data, or <code>-1</code> if the end of the
- * stream is reached.
- * @exception IOException if an I/O error occurs.
- * @since JDK1.0
- */
- public int read() throws IOException {
- checkOpen();
-
- return in.read();
- }
-
- /**
- * Reads up to <code>b.length</code> bytes of data from this input
- * stream into an array of bytes.
- * <p>
- * The <code>read</code> method of <code>InputStream</code> calls
- * the <code>read</code> method of three arguments with the arguments
- * <code>b</code>, <code>0</code>, and <code>b.length</code>.
- *
- * @param b the buffer into which the data is read.
- * @return the total number of bytes read into the buffer, or
- * <code>-1</code> is there is no more data because the end of
- * the stream has been reached.
- * @exception IOException if an I/O error occurs.
- * @see java.io.InputStream#read(byte[], int, int)
- * @since JDK1.0
- */
- public int read(byte[] b) throws IOException {
- checkOpen();
-
- return in.read(b, 0, b.length);
- }
-
- /**
- * Reads up to <code>len</code> bytes of data from this input stream
- * into an array of bytes. This method blocks until some input is
- * available. If the argument <code>b</code> is <code>null</code>, a
- * <code>NullPointerException</code> is thrown.
- * <p>
- * The <code>read</code> method of <code>InputStream</code> reads a
- * single byte at a time using the read method of zero arguments to
- * fill in the array. Subclasses are encouraged to provide a more
- * efficient implementation of this method.
- *
- * @param b the buffer into which the data is read.
- * @param off the start offset of the data.
- * @param len the maximum number of bytes read.
- * @return the total number of bytes read into the buffer, or
- * <code>-1</code> if there is no more data because the end of
- * the stream has been reached.
- * @exception IOException if an I/O error occurs.
- * @see java.io.InputStream#read()
- * @since JDK1.0
- */
- public int read(byte[] b, int off, int len) throws IOException {
- checkOpen();
-
- return in.read(b, off, len);
- }
-
- /**
- * Repositions this stream to the position at the time the
- * <code>mark</code> method was last called on this input stream.
- * <p>
- * The <code>reset</code> method of <code>InputStream</code> throws
- * an <code>IOException</code>, because input streams, by default, do
- * not support <code>mark</code> and <code>reset</code>.
- * <p>
- * Stream marks are intended to be used in
- * situations where you need to read ahead a little to see what's in
- * the stream. Often this is most easily done by invoking some
- * general parser. If the stream is of the type handled by the
- * parser, it just chugs along happily. If the stream is not of
- * that type, the parser should toss an exception when it fails,
- * which, if it happens within readlimit bytes, allows the outer
- * code to reset the stream and try another parser.
- *
- * @exception IOException if this stream has not been marked or if the
- * mark has been invalidated.
- * @see java.io.InputStream#mark(int)
- * @see java.io.IOException
- * @since JDK1.0
- */
- public void reset() throws IOException {
- checkOpen();
-
- in.reset();
- }
-
- /**
- * Skips over and discards <code>n</code> bytes of data from this
- * input stream. The <code>skip</code> method may, for a variety of
- * reasons, end up skipping over some smaller number of bytes,
- * possibly <code>0</code>. The actual number of bytes skipped is
- * returned.
- * <p>
- * The <code>skip</code> method of <code>InputStream</code> creates
- * a byte array of length <code>n</code> and then reads into it until
- * <code>n</code> bytes have been read or the end of the stream has
- * been reached. Subclasses are encouraged to provide a more
- * efficient implementation of this method.
- *
- * @param n the number of bytes to be skipped.
- * @return the actual number of bytes skipped.
- * @exception IOException if an I/O error occurs.
- * @since JDK1.0
- */
- public long skip(long len) throws IOException {
- checkOpen();
-
- return in.skip(len);
- }
-
- /**
- * ServletInputStream which limit readable data to the specified content length.
- * After the number of bytes have been read, EOF(-1) is returned from the read
- * method.
- *
- */
- static class ContentLength extends ServletInputStream {
- private int contentLength;
- private int mark;
- private ServletInputStream in;
-
- ContentLength(ServletInputStream in, int len) {
- super();
- this.in = in;
- contentLength = len;
- mark = len;
- }
-
- /**
- * Returns the number of bytes that can be read from this input
- * stream without blocking. The available method of
- * <code>InputStream</code> returns <code>0</code>. This method
- * <B>should</B> be overridden by subclasses.
- *
- * @return the number of bytes that can be read from this input stream
- * without blocking.
- * @exception IOException if an I/O error occurs.
- * @since JDK1.0
- */
- public int available() throws IOException {
- int avail = in.available();
-
- if (contentLength < avail) {
- return contentLength;
- }
-
- return avail;
- }
-
- /**
- * Closes this input stream and releases any system resources
- * associated with the stream.
- * <p>
- * The <code>close</code> method of <code>InputStream</code> does nothing.
- *
- * @exception IOException if an I/O error occurs.
- * @since JDK1.0
- */
- public void close() throws IOException {
- in.close();
- }
-
- /**
- * Marks the current position in this input stream. A subsequent
- * call to the <code>reset</code> method repositions this stream at
- * the last marked position so that subsequent reads re-read the same
- * bytes.
- * <p>
- * The <code>readlimit</code> arguments tells this input stream to
- * allow that many bytes to be read before the mark position gets
- * invalidated.
- * <p>
- * The <code>mark</code> method of <code>InputStream</code> does nothing.
- *
- * @param readlimit the maximum limit of bytes that can be read before
- * the mark position becomes invalid.
- * @see java.io.InputStream#reset()
- * @since JDK1.0
- */
- public void mark(int readLimit) {
- in.mark(readLimit);
-
- mark = contentLength;
- }
-
- /**
- * Tests if this input stream supports the <code>mark</code>
- * and <code>reset</code> methods. The <code>markSupported</code>
- * method of <code>InputStream</code> returns <code>false</code>.
- *
- * @return <code>true</code> if this true type supports the mark and reset
- * method; <code>false</code> otherwise.
- * @see java.io.InputStream#mark(int)
- * @see java.io.InputStream#reset()
- * @since JDK1.0
- */
- public boolean markSupported() {
- return in.markSupported();
- }
-
- /**
- * Reads the next byte of data from this input stream. The value
- * byte is returned as an <code>int</code> in the range
- * <code>0</code> to <code>255</code>. If no byte is available
- * because the end of the stream has been reached, the value
- * <code>-1</code> is returned. This method blocks until input data
- * is available, the end of the stream is detected, or an exception
- * is thrown.
- * <p>
- * A subclass must provide an implementation of this method.
- *
- * @return the next byte of data, or <code>-1</code> if the end of the
- * stream is reached.
- * @exception IOException if an I/O error occurs.
- * @since JDK1.0
- */
- public int read() throws IOException {
- if (contentLength <= 0) {
- return -1;
- }
-
- int read = in.read();
-
- contentLength--;
-
- return read;
- }
-
- /**
- * Reads up to <code>b.length</code> bytes of data from this input
- * stream into an array of bytes.
- * <p>
- * The <code>read</code> method of <code>InputStream</code> calls
- * the <code>read</code> method of three arguments with the arguments
- * <code>b</code>, <code>0</code>, and <code>b.length</code>.
- *
- * @param b the buffer into which the data is read.
- * @return the total number of bytes read into the buffer, or
- * <code>-1</code> is there is no more data because the end of
- * the stream has been reached.
- * @exception IOException if an I/O error occurs.
- * @see java.io.InputStream#read(byte[], int, int)
- * @since JDK1.0
- */
- public int read(byte[] b) throws IOException {
- if (contentLength <= 0) {
- return -1;
- }
-
- int len = b.length;
-
- if (contentLength < len) {
- len = contentLength;
- }
-
- int read = in.read(b, 0, len);
-
- contentLength -= read;
-
- return read;
- }
-
- /**
- * Reads up to <code>len</code> bytes of data from this input stream
- * into an array of bytes. This method blocks until some input is
- * available. If the argument <code>b</code> is <code>null</code>, a
- * <code>NullPointerException</code> is thrown.
- * <p>
- * The <code>read</code> method of <code>InputStream</code> reads a
- * single byte at a time using the read method of zero arguments to
- * fill in the array. Subclasses are encouraged to provide a more
- * efficient implementation of this method.
- *
- * @param b the buffer into which the data is read.
- * @param off the start offset of the data.
- * @param len the maximum number of bytes read.
- * @return the total number of bytes read into the buffer, or
- * <code>-1</code> if there is no more data because the end of
- * the stream has been reached.
- * @exception IOException if an I/O error occurs.
- * @see java.io.InputStream#read()
- * @since JDK1.0
- */
- public int read(byte[] b, int off, int len) throws IOException {
- if (contentLength <= 0) {
- return -1;
- }
-
- if (contentLength < len) {
- len = contentLength;
- }
-
- int read = in.read(b, off, len);
-
- contentLength -= read;
-
- return read;
- }
-
- /**
- * Repositions this stream to the position at the time the
- * <code>mark</code> method was last called on this input stream.
- * <p>
- * The <code>reset</code> method of <code>InputStream</code> throws
- * an <code>IOException</code>, because input streams, by default, do
- * not support <code>mark</code> and <code>reset</code>.
- * <p>
- * Stream marks are intended to be used in
- * situations where you need to read ahead a little to see what's in
- * the stream. Often this is most easily done by invoking some
- * general parser. If the stream is of the type handled by the
- * parser, it just chugs along happily. If the stream is not of
- * that type, the parser should toss an exception when it fails,
- * which, if it happens within readlimit bytes, allows the outer
- * code to reset the stream and try another parser.
- *
- * @exception IOException if this stream has not been marked or if the
- * mark has been invalidated.
- * @see java.io.InputStream#mark(int)
- * @see java.io.IOException
- * @since JDK1.0
- */
- public void reset() throws IOException {
- in.reset();
-
- contentLength = mark;
- }
-
- /**
- * Skips over and discards <code>n</code> bytes of data from this
- * input stream. The <code>skip</code> method may, for a variety of
- * reasons, end up skipping over some smaller number of bytes,
- * possibly <code>0</code>. The actual number of bytes skipped is
- * returned.
- * <p>
- * The <code>skip</code> method of <code>InputStream</code> creates
- * a byte array of length <code>n</code> and then reads into it until
- * <code>n</code> bytes have been read or the end of the stream has
- * been reached. Subclasses are encouraged to provide a more
- * efficient implementation of this method.
- *
- * @param n the number of bytes to be skipped.
- * @return the actual number of bytes skipped.
- * @exception IOException if an I/O error occurs.
- * @since JDK1.0
- */
- public long skip(long len) throws IOException {
- if (contentLength <= 0) {
- return 0;
- }
-
- if (contentLength < len) {
- len = contentLength;
- }
-
- long skipped = in.skip(len);
-
- contentLength -= skipped;
-
- return skipped;
- }
- }
-}
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/ServletOutputStreamImpl.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/ServletOutputStreamImpl.java
deleted file mode 100644
index ae62e5eb0..000000000
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/ServletOutputStreamImpl.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1999, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.http.servlet;
-
-import java.io.*;
-import javax.servlet.ServletOutputStream;
-
-/**
- * The implementation of javax.servlet.ServletOutputStream.
- *
- * When a flush or close method is called on an implementation of this class, any
- * data buffered by the servlet engine is sent to the client and the response is
- * considered to be "committed". Note that calling close on an object of this type
- * doesn't necessarily close the underlying socket stream.
- */
-
-//BUGBUG - override print methods for better performance!!!!
-class ServletOutputStreamImpl extends ServletOutputStream {
- /** Actual output stream */
- private OutputStream realOut;
-
- /** response object */
- private HttpServletResponseImpl response;
-
- /** false if the ServletOutputStream has been closed */
- private boolean open;
-
- /** Place to buffer the output data */
- private ByteArrayOutputStream buffer;
-
- /** Place to buffer the output data */
- private OutputStream out;
-
- /** true if we need to write the response headers */
- private boolean writeHeaders;
-
- /** true if the flush method should flush */
- private boolean flush;
-
- /** true if this ServletOutputStream is closing */
- private boolean closing;
-
- ServletOutputStreamImpl(OutputStream realOut, HttpServletResponseImpl response) {
- this.realOut = realOut;
- this.response = response;
-
- // BUGBUG Make the default buffer size configurable.
- buffer = new ByteArrayOutputStream(8192); /* start with a 8k buffer */
- out = buffer; /* begin with buffer */
- open = true;
- writeHeaders = true;
- closing = false;
- flush = true;
- }
-
- /**
- * This method is called by a wrapper to disable normal flush
- * function until the close method is called.
- */
- synchronized void disableFlush() {
- flush = false; /* disable flush until we are closed */
- }
-
- public synchronized void close() throws IOException {
- if (open) {
- closing = true; /* allow content size to be calculated */
- flush = true; /* enable normal flush function */
-
- flush();
-
- open = false; /* disable this ServletOutputStream */
- }
- }
-
- public synchronized void flush() throws IOException {
- if (open) {
- if (writeHeaders) {
- if (flush) {
- /* These must be set before calling writeHeaders */
- writeHeaders = false;
- out = realOut;
-
- /* write the response headers */
- response.writeHeaders(closing ? buffer.size() : -1);
-
- /* copy the buffered output to the real OutputStream */
- buffer.writeTo(out);
-
- /* dereference buffer so it may be garbage collected */
- buffer = null;
-
- out.flush();
- }
- } else {
- out.flush();
- }
- } else {
- throw new IOException("closed"); //$NON-NLS-1$
- }
- }
-
- public synchronized void write(byte[] bytes) throws IOException {
- if (open) {
- out.write(bytes, 0, bytes.length);
- } else {
- throw new IOException("closed"); //$NON-NLS-1$
- }
- }
-
- public synchronized void write(byte[] bytes, int off, int len) throws IOException {
- if (open) {
- out.write(bytes, off, len);
- } else {
- throw new IOException("closed"); //$NON-NLS-1$
- }
- }
-
- public synchronized void write(int b) throws IOException {
- if (open) {
- out.write(b);
- } else {
- throw new IOException("closed"); //$NON-NLS-1$
- }
- }
-}
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/ServletPrintWriter.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/ServletPrintWriter.java
deleted file mode 100644
index e4c1bb55b..000000000
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/ServletPrintWriter.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1999, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.http.servlet;
-
-import java.io.*;
-
-/**
- * PrintWriter subclass for servlets. This class wraps a
- * ServletOutputStream to support Content-Length generation.
- */
-class ServletPrintWriter extends PrintWriter {
- /** underlying ServletOutputStream */
- private ServletOutputStreamImpl out;
-
- /**
- * Create the PrintWriter w/o autoflush for the specified encoding.
- *
- * @param out Underlying ServletOutputStream.
- * @param encoding Encoding to use for the
- * @throws UnsupportedEncodingException if the encoding is not supported.
- */
- ServletPrintWriter(ServletOutputStreamImpl out, String encoding) throws UnsupportedEncodingException {
- super(new OutputStreamWriter(out, encoding), false);
-
- this.out = out;
- }
-
- /**
- * Close this PrintWriter.
- *
- * Tell the underlying ServletOutputStream we are closing.
- */
- public void close() {
- out.disableFlush(); /* disable flush operation until closed */
-
- super.close();
- }
-}
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/status.codes b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/status.codes
deleted file mode 100644
index bb4fe9cf6..000000000
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/status.codes
+++ /dev/null
@@ -1,52 +0,0 @@
-###############################################################################
-# Copyright (c) 2005 IBM Corporation.
-# 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:
-# IBM Corporation - initial API and implementation
-###############################################################################
-
-# This file is used by the web server to provide a mapping of status code to
-# status phrases.
-# Format: StatusCode StatusPhrase
-
-100 Continue
-101 Switching Protocols
-200 OK
-201 Created
-202 Accepted
-203 Non-Authoritative Information
-204 No Content
-205 Reset Content
-206 Partial Content
-300 Multiple Choices
-301 Moved Permanently
-302 Moved Temporarily
-303 See Other
-304 Not Modified
-305 Use Proxy
-400 Bad Request
-401 Unauthorized
-402 Payment Required
-403 Forbidden
-404 Not Found
-405 Method Not Allowed
-406 Not Acceptable
-407 Proxy Authentication Required
-408 Request Time-out
-409 Conflict
-410 Gone
-411 Length Required
-412 Precondition Failed
-413 Request Entity Too Large
-414 Request-URI Too Large
-415 Unsupported Media Type
-500 Internal Server Error
-501 Not Implemented
-502 Bad Gateway
-503 Service Unavailable
-504 Gateway Time-out
-505 HTTP Version not supported
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/socket/ServerSocketInterface.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/socket/ServerSocketInterface.java
deleted file mode 100644
index fd4addf6b..000000000
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/socket/ServerSocketInterface.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1999, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.socket;
-
-/** ServerSocketInterface.java
- *
- *
- */
-
-import java.io.IOException;
-
-public interface ServerSocketInterface {
- public SocketInterface acceptSock() throws IOException;
-
- public void close() throws IOException;
-
- public void setAddress(String address);
-
- public String getAddress();
-
- public int getLocalPort();
-
- public String getScheme();
-}
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/socket/SocketInterface.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/socket/SocketInterface.java
deleted file mode 100644
index b84bd147d..000000000
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/socket/SocketInterface.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1999, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.socket;
-
-/** SocketInterface.java
- *
- *
- */
-
-import java.io.*;
-import java.net.InetAddress;
-import java.net.SocketException;
-
-public interface SocketInterface {
- /* Standard java.net.Socket methods */
- public void close() throws IOException;
-
- public InetAddress getInetAddress();
-
- public InetAddress getLocalAddress();
-
- public int getLocalPort();
-
- public InputStream getInputStream() throws IOException;
-
- public OutputStream getOutputStream() throws IOException;
-
- public void setSoTimeout(int timeout) throws SocketException;
-
- public int getSoTimeout() throws SocketException;
-
- /* Http Methods */
- /**
- * Return the scheme this socket is using.
- *
- * @return Either "http" or "https".
- */
- public String getScheme();
-
- /**
- * Test to see if the socket has been closed.
- *
- * @return true if close has been called on this socket.
- */
- public boolean isClosed();
-
- /**
- * Test to see if the socket is active.
- *
- * @return true if markActive has been called.
- */
- public boolean isActive();
-
- /**
- * Mark the socket active.
- *
- */
- public void markActive();
-
- /**
- * Mark the socket inactive.
- *
- */
- public void markInactive();
-}
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/socket/https/HttpsServerSocket.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/socket/https/HttpsServerSocket.java
deleted file mode 100644
index 3cc7e0c6d..000000000
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/socket/https/HttpsServerSocket.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1999, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.socket.https;
-
-import java.io.IOException;
-import java.net.*;
-import javax.net.ServerSocketFactory;
-import org.eclipse.equinox.socket.ServerSocketInterface;
-import org.eclipse.equinox.socket.SocketInterface;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.util.tracker.ServiceTracker;
-import org.osgi.util.tracker.ServiceTrackerCustomizer;
-
-public class HttpsServerSocket implements ServerSocketInterface, ServiceTrackerCustomizer {
-
- protected String address = null;
- protected BundleContext context = null;
- protected int port = 443;
- protected int backlog = 50;
- protected InetAddress bindAddr = null;
-
- protected ServiceTracker st = null;
- protected ServerSocketFactory ssf = null;
- protected ServerSocket ss = null;
- protected ServerSocket dummyss = null;
-
- /**
- * Constructor for HttpsServerSockets
- */
- public HttpsServerSocket(BundleContext context, int port) throws IOException {
- this(context, port, 50);
- }
-
- /**
- * HttpServerSocket constructor comment.
- * @param port int
- * @param backlog int
- * @exception java.io.IOException The exception description.
- */
- public HttpsServerSocket(BundleContext context, int port, int backlog) throws java.io.IOException {
- this(context, port, backlog, null);
- }
-
- /**
- * HttpServerSocket constructor comment.
- * @param port int
- * @param backlog int
- * @param bindAddr java.net.InetAddress
- * @exception java.io.IOException The exception description.
- */
- public HttpsServerSocket(BundleContext context, int port, int backlog, InetAddress bindAddr) throws java.io.IOException {
- this.context = context;
- this.port = port;
- this.backlog = backlog;
- this.bindAddr = bindAddr;
- // Try to configure a normal ServerSocket with the settings to see
- // if the ServerSocket can be created. If no exception is thrown
- // then the port is available
- dummyss = new ServerSocket(port, backlog, bindAddr);
-
- st = new ServiceTracker(context, "javax.net.ssl.SSLServerSocketFactory", this); //$NON-NLS-1$
- st.open();
- }
-
- /**
- * @see ServerSocketInterface#acceptSock()
- */
- public synchronized SocketInterface acceptSock() throws IOException {
- while (this.ssf == null) {
- try {
- wait();
- } catch (InterruptedException e) {
- throw new IOException();
- }
- }
- if (ss == null) {
- if (dummyss != null) {
- dummyss.close();
- dummyss = null;
- }
- ss = ssf.createServerSocket(port, backlog, bindAddr);
- }
- Socket socket = ss.accept();
- return new HttpsSocket(socket);
- }
-
- /**
- * @see ServerSocketInterface#close()
- */
- public void close() throws IOException {
- if (ss != null) {
- ss.close();
- }
- }
-
- /**
- * @see ServerSocketInterface#getLocalPort()
- */
- public int getLocalPort() {
- if (ss != null) {
- return ss.getLocalPort();
- }
- return 0;
- }
-
- /**
- * @see ServerSocketInterface#getScheme()
- */
- public String getScheme() {
- return ("https"); //$NON-NLS-1$
- }
-
- public String getAddress() {
- return address;
- }
-
- public void setAddress(String address) {
- this.address = address;
- }
-
- public synchronized Object addingService(ServiceReference reference) {
- if (ssf == null) {
- ssf = (ServerSocketFactory) context.getService(reference);
- notify();
- return ssf;
- }
- return null;
- }
-
- public void modifiedService(ServiceReference reference, Object service) {
- // do nothing
- }
-
- public synchronized void removedService(ServiceReference reference, Object service) {
- ssf = null;
- if (ss != null) {
- try {
- ss.close();
- } catch (IOException e) {
- // TODO: consider logging
- }
- ss = null;
- }
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/socket/https/HttpsSocket.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/socket/https/HttpsSocket.java
deleted file mode 100644
index 082015bb3..000000000
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/socket/https/HttpsSocket.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1999, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.socket.https;
-
-import java.io.*;
-import java.net.*;
-import org.eclipse.equinox.socket.SocketInterface;
-
-public class HttpsSocket implements SocketInterface {
- protected Socket socket;
- protected boolean closed = false;
- private boolean active = false;
- private InputStream in = null;
-
- public HttpsSocket(Socket socket) {
- this.socket = socket;
- }
-
- public void close() throws IOException {
- closed = true;
- socket.close();
- }
-
- public InetAddress getInetAddress() {
- return socket.getInetAddress();
- }
-
- public InetAddress getLocalAddress() {
- return socket.getLocalAddress();
- }
-
- public int getLocalPort() {
- return socket.getLocalPort();
- }
-
- /**
- * Wrap the real socket input stream in a buffered input stream
- *
- * @return a buffered InputStream which wraps the real input stream.
- * @throws IOException
- */
- public InputStream getInputStream() throws IOException {
- if (in == null) {
- synchronized (this) {
- if (in == null) {
- in = new BufferedInputStream(socket.getInputStream());
- }
- }
- }
-
- return in;
- }
-
- public OutputStream getOutputStream() throws IOException {
- return socket.getOutputStream();
- }
-
- public void setSoTimeout(int timeout) throws SocketException {
- socket.setSoTimeout(timeout);
- }
-
- public int getSoTimeout() throws SocketException {
- return socket.getSoTimeout();
- }
-
- /**
- * Return the scheme this socket is using.
- *
- * @return "https".
- */
- public String getScheme() {
- return "https"; //$NON-NLS-1$
- }
-
- /**
- * Test to see if the socket is closed.
- *
- * @return true if close has been called.
- */
- public boolean isClosed() {
- return closed;
- }
-
- /**
- * Test to see if the socket is active.
- *
- * @return true if markActive has been called.
- */
- public boolean isActive() {
- return active;
- }
-
- /**
- * Mark the socket active.
- *
- */
- public void markActive() {
- active = true;
- }
-
- /**
- * Mark the socket inactive.
- *
- */
- public void markInactive() {
- active = false;
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.log/.classpath b/bundles/org.eclipse.equinox.log/.classpath
deleted file mode 100644
index 1fa3e6803..000000000
--- a/bundles/org.eclipse.equinox.log/.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"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/bundles/org.eclipse.equinox.log/.cvsignore b/bundles/org.eclipse.equinox.log/.cvsignore
deleted file mode 100644
index ba077a403..000000000
--- a/bundles/org.eclipse.equinox.log/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
diff --git a/bundles/org.eclipse.equinox.log/.project b/bundles/org.eclipse.equinox.log/.project
deleted file mode 100644
index 3c43dd106..000000000
--- a/bundles/org.eclipse.equinox.log/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.equinox.log</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.jdt.core.javanature</nature>
- <nature>org.eclipse.pde.PluginNature</nature>
- </natures>
-</projectDescription>
diff --git a/bundles/org.eclipse.equinox.log/.settings/org.eclipse.jdt.core.prefs b/bundles/org.eclipse.equinox.log/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 53241a752..000000000
--- a/bundles/org.eclipse.equinox.log/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,49 +0,0 @@
-#Fri Dec 16 09:20:31 CST 2005
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
-org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
-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=warning
-org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
-org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
-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=warning
-org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
-org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
-org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
-org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
-org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
-org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
-org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore
-org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
-org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
-org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning
-org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
-org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
-org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
-org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.unusedImport=error
-org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
-org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
-org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
-org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
diff --git a/bundles/org.eclipse.equinox.log/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.log/META-INF/MANIFEST.MF
deleted file mode 100644
index 35116c6d7..000000000
--- a/bundles/org.eclipse.equinox.log/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,16 +0,0 @@
-Bundle-ManifestVersion: 2
-Bundle-Vendor: %bundleVendor
-Bundle-Version: 1.0.0.qualifier
-Bundle-Activator: org.eclipse.equinox.log.Activator
-Bundle-Copyright: %bundleCopyright
-Bundle-SymbolicName: org.eclipse.equinox.log
-Bundle-Name: %bundleName
-Export-Service: org.osgi.service.log.LogReaderService,
- org.osgi.service.log.LogService
-Import-Package: org.eclipse.osgi.framework.eventmgr,
- org.osgi.framework;version="1.1",
- org.osgi.service.cm;version="1.0",
- org.osgi.service.log;version="1.2",
- org.eclipse.osgi.util
-Export-Package: org.eclipse.equinox.log;x-internal:=true
-Bundle-Localization: plugin
diff --git a/bundles/org.eclipse.equinox.log/OSGI-INF/l10n/bundle_en.properties b/bundles/org.eclipse.equinox.log/OSGI-INF/l10n/bundle_en.properties
deleted file mode 100644
index 3691b8f2b..000000000
--- a/bundles/org.eclipse.equinox.log/OSGI-INF/l10n/bundle_en.properties
+++ /dev/null
@@ -1,21 +0,0 @@
-###############################################################################
-# Copyright (c) 1999, 2005 IBM Corporation.
-# 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:
-# IBM Corporation - initial API and implementation
-###############################################################################
-# NLS_MESSAGEFORMAT_ALL
-LOG_SIZE=Log Size
-LOG_SIZE_DESC=The size of the log, in number of entries
-LOG_THRESHOLD=The level of logging
-LOG_THRESHOLD_DESC=The minimum severity level of logged messages
-ERROR=Error
-WARNING=Warning
-INFO=Informational
-DEBUG=Debug
-LOG_SETTINGS=Log Service Settings
-LOG_SETTINGS_DESC=The Log Service settings that may be configured
diff --git a/bundles/org.eclipse.equinox.log/OSGI-INF/metatype/METADATA.XML b/bundles/org.eclipse.equinox.log/OSGI-INF/metatype/METADATA.XML
deleted file mode 100644
index 006da539b..000000000
--- a/bundles/org.eclipse.equinox.log/OSGI-INF/metatype/METADATA.XML
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<metatype:MetaData xmlns:metatype="http://www.osgi.org/xmlns/metatype/v1.0.0">
- <OCD id="org.eclipse.equinox.log.Log" name="%LOG_SETTINGS" description="%LOG_SETTINGS_DESC">
- <AD id="log.size" name="%LOG_SIZE" type="Integer" default="100" cardinality="0" min="10" max="2000" description="%LOG_SIZE_DESC" required="true"/>
- <AD id="log.threshold" name="%LOG_THRESHOLD" type="Integer" default="4" cardinality="0" min="1" max="4" description="%LOG_THRESHOLD_DESC" required="true">
- <Option label= "%ERROR" value="1"/>
- <Option label= "%WARNING" value="2"/>
- <Option label= "%INFO" value="3"/>
- <Option label= "%DEBUG" value="4"/>
- </AD>
- </OCD>
- <Designate pid="org.eclipse.equinox.log.Log">
- <Object ocdref="org.eclipse.equinox.log.Log"/>
- </Designate>
-</metatype:MetaData>
diff --git a/bundles/org.eclipse.equinox.log/about.html b/bundles/org.eclipse.equinox.log/about.html
deleted file mode 100644
index b2f1e6bad..000000000
--- a/bundles/org.eclipse.equinox.log/about.html
+++ /dev/null
@@ -1,22 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
-<!-- saved from url=(0043)http://www.eclipse.org/legal/epl/about.html -->
-<HTML><HEAD><TITLE>About</TITLE>
-<META http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-<META content="MSHTML 6.00.2800.1498" name=GENERATOR></HEAD>
-<BODY lang=EN-US>
-<H2>About This Content</H2>
-<P>February 24, 2005</P>
-<H3>License</H3>
-<P>The Eclipse Foundation makes available all content in this plug-in
-("Content"). Unless otherwise indicated below, the Content is provided to you
-under the terms and conditions of the Eclipse Public License Version 1.0
-("EPL"). A copy of the EPL is available at <A
-href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</A>.
-For purposes of the EPL, "Program" will mean the Content.</P>
-<P>If you did not receive this Content directly from the Eclipse Foundation, the
-Content is being redistributed by another party ("Redistributor") and different
-terms and conditions may apply to your use of any object code in the Content.
-Check the Redistributor's license that was provided with the Content. If no such
-license exists, contact the Redistributor. Unless otherwise indicated below, the
-terms and conditions of the EPL still apply to any source code in the
-Content.</P></BODY></HTML>
diff --git a/bundles/org.eclipse.equinox.log/build.properties b/bundles/org.eclipse.equinox.log/build.properties
deleted file mode 100644
index 873261924..000000000
--- a/bundles/org.eclipse.equinox.log/build.properties
+++ /dev/null
@@ -1,17 +0,0 @@
-###############################################################################
-# Copyright (c) 2005 IBM Corporation.
-# 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:
-# IBM Corporation - initial API and implementation
-###############################################################################
-bin.includes = META-INF/,\
- plugin*.properties,\
- about.html,\
- .
-src.includes = about.html
-source.. = src/
-output.. = bin/
diff --git a/bundles/org.eclipse.equinox.log/plugin.properties b/bundles/org.eclipse.equinox.log/plugin.properties
deleted file mode 100644
index 09d786974..000000000
--- a/bundles/org.eclipse.equinox.log/plugin.properties
+++ /dev/null
@@ -1,13 +0,0 @@
-###############################################################################
-# Copyright (c) 2005 IBM Corporation.
-# 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:
-# IBM Corporation - initial API and implementation
-###############################################################################
-bundleVendor = Eclipse.org
-bundleName = Log Service
-bundleCopyright = Copyright (c) IBM Corp. 1999, 2005
diff --git a/bundles/org.eclipse.equinox.log/src/org/eclipse/equinox/log/Activator.java b/bundles/org.eclipse.equinox.log/src/org/eclipse/equinox/log/Activator.java
deleted file mode 100644
index 6af7eedbb..000000000
--- a/bundles/org.eclipse.equinox.log/src/org/eclipse/equinox/log/Activator.java
+++ /dev/null
@@ -1,533 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1999, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.log;
-
-import java.util.*;
-import org.eclipse.osgi.framework.eventmgr.*;
-import org.eclipse.osgi.util.NLS;
-import org.osgi.framework.*;
-import org.osgi.service.cm.ConfigurationException;
-import org.osgi.service.cm.ManagedService;
-import org.osgi.service.log.LogService;
-
-/**
- * An array of LogEntries which wraps when full.
- */
-public class Activator implements BundleActivator, EventDispatcher, BundleListener, FrameworkListener, ServiceListener, ManagedService {
- protected BundleContext context;
-
- /** List of LogReaderServices for bundle's LogEntry listeners. */
- protected EventListeners logEvent;
- /** EventManager for event delivery. */
- protected EventManager eventManager;
-
- protected ServiceRegistration logservice;
- protected ServiceRegistration logreaderservice;
- protected ServiceRegistration logmanagedservice;
-
- /** default log size value */
- protected static final int DEFAULT_LOG_SIZE = 100;
-
- /** default log threshold value */
- protected static final int DEFAULT_LOG_THRESHOLD = LogService.LOG_DEBUG;
-
- /** current logsize value */
- protected int logSize = DEFAULT_LOG_SIZE;
- /** current logthreshold value */
- protected int logThreshold = DEFAULT_LOG_THRESHOLD;
-
- protected LogEntry[] logEntries;
- protected int head;
- protected int tail;
-
- /** The timestamp of the last log entry (to avoid duplicates). */
- protected long lastTimestamp = 0;
-
- /** key into properties for logsize value */
- protected static final String keyLogSize = "log.size"; //$NON-NLS-1$
- /** key into properties for log threshold value */
- protected static final String keyLogThreshold = "log.threshold"; //$NON-NLS-1$
- /** Pid that log service uses when it registers a CM Managed Service */
- protected static final String LOGSERVICEPID = "org.eclipse.equinox.log.Log"; //$NON-NLS-1$
-
- /**
- * BundleActivator.start method. We can now initialize the bundle
- * and register the services.
- *
- */
- public void start(BundleContext bundleContext) {
- this.context = bundleContext;
-
- eventManager = new EventManager("Log Event Dispatcher"); //$NON-NLS-1$
- logEvent = new EventListeners();
-
- logEntries = new LogEntry[logSize];
- head = 0;
- tail = 0;
- String initmessage = NLS.bind(LogMsg.Log_created_Log_Size, String.valueOf(logSize), String.valueOf(logThreshold));
- logEntries[0] = new LogEntry(LogService.LOG_INFO, initmessage, bundleContext.getBundle(), null, null);
-
- bundleContext.addBundleListener(this);
- bundleContext.addServiceListener(this);
- bundleContext.addFrameworkListener(this);
-
- registerLogService();
- registerLogReaderService();
-
- registerManagedService();
- }
-
- /**
- * BundleActivator.stop method. We must now clean up and terminate
- * execution.
- *
- */
- public synchronized void stop(BundleContext bundleContext) {
- if (logmanagedservice != null) {
- logmanagedservice.unregister();
- logmanagedservice = null;
- }
-
- /* remove my listeners before unregistering myself */
- this.context.removeBundleListener(this);
- this.context.removeServiceListener(this);
- this.context.removeFrameworkListener(this);
-
- if (logservice != null) {
- logservice.unregister();
- logservice = null;
- }
- if (logreaderservice != null) {
- logreaderservice.unregister();
- logreaderservice = null;
- }
-
- /* destroy my event manager */
- if (logEvent != null) {
- logEvent.removeAllListeners();
- logEvent = null;
- }
-
- if (eventManager != null) {
- eventManager.close();
- eventManager = null;
- }
-
- logEntries = null;
-
- this.context = null;
- }
-
- /**
- * Log a bundle message. This is used internally by all of the public
- * log() methods as the common point through which all logging must
- * go through.
- * @param level The severity of the message. (Should be one of the four
- * predefined severities.)
- * @param message Human readable string describing the condition.
- * @param context The BundleContext creating the log entry
- * @param sd The ServiceDescription of the service that this message
- * is associated with.
- * @param exception The exception that reflects the condition.
- */
- protected void log(int level, String message, Bundle bundle, ServiceReference reference, Throwable exception)
-
- {
- LogEntry logentry = new LogEntry(level, message, bundle, reference, exception);
-
- synchronized (this) {
- if (context == null) {
- return;
- }
-
- // Make the timestamp unique, log listener's might use it as a key
- if (logentry.time <= lastTimestamp) {
- logentry.time = ++lastTimestamp;
- } else {
- lastTimestamp = logentry.time;
- }
-
- if (level <= logThreshold) { /* if level is within logging threshold */
- addLogEntry(logentry);
- }
- }
-
- /* queue to hold set of listeners */
- ListenerQueue listeners = new ListenerQueue(eventManager);
-
- /* queue to hold set of BundleContexts w/ listeners */
- ListenerQueue contexts = new ListenerQueue(eventManager);
-
- /* add set of BundleContexts w/ listeners to queue */
- contexts.queueListeners(logEvent, this);
-
- /* synchronously dispatch to populate listeners queue */
- contexts.dispatchEventSynchronous(0, listeners);
-
- /* dispatch event to set of listeners */
- listeners.dispatchEventAsynchronous(0, logentry);
- }
-
- public void dispatchEvent(Object l, Object lo, int action, Object object) {
- LogReaderService logreader = (LogReaderService) l;
-
- EventListeners listeners = logreader.logEvent;
-
- if (listeners != null) {
- ListenerQueue queue = (ListenerQueue) object;
-
- queue.queueListeners(listeners, logreader);
- }
- }
-
- /**
- * This method must be called while synchronized.
- *
- */
- protected void addLogEntry(LogEntry logentry) {
- tail = (tail + 1) % logSize;
- logEntries[tail] = logentry;
- if (head == tail) {
- head = (head + 1) % logSize;
- }
- }
-
- protected synchronized Enumeration logEntries() {
- final int tempHead = this.head;
- final int tempTail = this.tail;
- final int templogSize = this.logSize;
- final LogEntry[] tempLogEntries = this.logEntries;
-
- return (new Enumeration() {
- private int item;
- private LogEntry[] enumentries;
-
- {
- // The array is created in the log reader's memory space
- if (tempHead <= tempTail) {
- item = tempTail - tempHead + 1;
- enumentries = new LogEntry[item];
- System.arraycopy(tempLogEntries, tempHead, enumentries, 0, item);
- } else { // log is full
- int firstcopy = templogSize - tempHead;
- item = firstcopy + tempTail + 1;
- enumentries = new LogEntry[item];
- System.arraycopy(tempLogEntries, tempHead, enumentries, 0, firstcopy);
- System.arraycopy(tempLogEntries, 0, enumentries, firstcopy, item - firstcopy);
- }
- }
-
- public boolean hasMoreElements() {
- if (item > 0) {
- return (true);
- }
- enumentries = null; /* release the storage */
- return (false);
- }
-
- /** Returns an Object of type LogEntry */
- public Object nextElement() {
- if (item > 0) {
- item--;
- LogEntry entry = (enumentries[item]).copy();
- enumentries[item] = null; /* release the storage as we go */
- return (entry);
- }
- enumentries = null; /* release the storage */
- throw new NoSuchElementException();
- }
- });
- }
-
- /**
- * BundleListener.bundleChanged method.
- *
- */
- public void bundleChanged(BundleEvent event) {
- log(LogService.LOG_INFO, getBundleEventTypeName(event.getType()), event.getBundle(), null, null);
- }
-
- /**
- * ServiceListener.serviceChanged method.
- *
- */
- public void serviceChanged(ServiceEvent event) {
- ServiceReference reference = event.getServiceReference();
-
- int eventType = event.getType();
-
- int logType = (eventType == ServiceEvent.MODIFIED) ? LogService.LOG_DEBUG : LogService.LOG_INFO;
-
- log(logType, getServiceEventTypeName(eventType), reference.getBundle(), reference, null);
- }
-
- /**
- * FrameworkListener.frameworkEvent method.
- *
- */
- public void frameworkEvent(FrameworkEvent event) {
- int type = event.getType();
-
- if (type == FrameworkEvent.ERROR) {
- log(LogService.LOG_ERROR, getFrameworkEventTypeName(type), event.getBundle(), null, event.getThrowable());
- } else {
- log(LogService.LOG_INFO, getFrameworkEventTypeName(type), event.getBundle(), null, null);
- }
- }
-
- /**
- * Convert BundleEvent type to a string.
- *
- */
- protected static String getBundleEventTypeName(int type) {
- switch (type) {
- case BundleEvent.INSTALLED :
- return ("BundleEvent INSTALLED"); //$NON-NLS-1$
-
- case BundleEvent.RESOLVED :
- return ("BundleEvent RESOLVED"); //$NON-NLS-1$
-
- case BundleEvent.STARTED :
- return ("BundleEvent STARTED"); //$NON-NLS-1$
-
- case BundleEvent.STARTING :
- return ("BundleEvent STARTING"); //$NON-NLS-1$
-
- case BundleEvent.STOPPED :
- return ("BundleEvent STOPPED"); //$NON-NLS-1$
-
- case BundleEvent.STOPPING :
- return ("BundleEvent STOPPING"); //$NON-NLS-1$
-
- case BundleEvent.UNINSTALLED :
- return ("BundleEvent UNINSTALLED"); //$NON-NLS-1$
-
- case BundleEvent.UNRESOLVED :
- return ("BundleEvent UNRESOLVED"); //$NON-NLS-1$
-
- case BundleEvent.UPDATED :
- return ("BundleEvent UPDATED"); //$NON-NLS-1$
-
- default :
- return (NLS.bind(LogMsg.BundleEvent, Integer.toHexString(type)));
- }
- }
-
- /**
- * Convert ServiceEvent type to a string.
- *
- */
- protected static String getServiceEventTypeName(int type) {
- switch (type) {
- case ServiceEvent.REGISTERED :
- return ("ServiceEvent REGISTERED"); //$NON-NLS-1$
-
- case ServiceEvent.MODIFIED :
- return ("ServiceEvent MODIFIED"); //$NON-NLS-1$
-
- case ServiceEvent.UNREGISTERING :
- return ("ServiceEvent UNREGISTERING"); //$NON-NLS-1$
-
- default :
- return (NLS.bind(LogMsg.ServiceEvent, Integer.toHexString(type)));
- }
- }
-
- /**
- * Convert FrameworkEvent type to a string.
- *
- */
- protected static String getFrameworkEventTypeName(int type) {
- switch (type) {
- case FrameworkEvent.ERROR :
- return ("FrameworkEvent ERROR"); //$NON-NLS-1$
-
- case FrameworkEvent.INFO :
- return ("FrameworkEvent INFO"); //$NON-NLS-1$
-
- case FrameworkEvent.PACKAGES_REFRESHED :
- return ("FrameworkEvent PACKAGES REFRESHED"); //$NON-NLS-1$
-
- case FrameworkEvent.STARTED :
- return ("FrameworkEvent STARTED"); //$NON-NLS-1$
-
- case FrameworkEvent.STARTLEVEL_CHANGED :
- return ("FrameworkEvent STARTLEVEL CHANGED"); //$NON-NLS-1$
-
- case FrameworkEvent.WARNING :
- return ("FrameworkEvent WARNING"); //$NON-NLS-1$
-
- default :
- return (NLS.bind(LogMsg.FrameworkEvent, Integer.toHexString(type)));
- }
- }
-
- /**
- * Update the configuration for a ManagedService.
- *
- * <p> When the implementation of updated(Dictionary) detects any kind of
- * error in the configuration properties, it should create a
- * new ConfigurationException which describes the problem. This
- * can allow a management system to provide useful information to
- * a human administrator.
- * <p> If this method throws any other Exception, the
- * ConfigurationAdmin must catch it and should log it.
- * <p> The ConfigurationAdmin must call this method on a thread
- * other than the thread which initiated the call-back. This
- * implies that implementors of ManagedService can be assured
- * that the call-back will not take place during registration
- * when they execute the registration in a synchronized method.
- *
- * @param properties configuration properties, or null
- * @throws ConfigurationException when the update fails
- **/
- public synchronized void updated(Dictionary properties) throws ConfigurationException {
- /* Since updated is called asynchronously, we may have stopped
- * after the decision was made to call.
- */
- if (context != null) {
- if (properties == null) {
- /* We have no configuration; we will just use our defaults */
- return;
- }
-
- int size = logSize;
- int threshold = logThreshold;
-
- /* Get configuration values and validate */
- Object property = properties.get(keyLogSize);
- if (property != null) /* if null we will just use the default */
- {
- if (!(property instanceof Integer)) {
- throw new ConfigurationException(keyLogSize, "not an Integer"); //$NON-NLS-1$
- }
-
- size = ((Integer) property).intValue();
-
- if ((size < 10) || (size > 2000)) {
- throw new ConfigurationException(keyLogSize, "must be in the range 10-2000"); //$NON-NLS-1$
- }
- }
-
- property = properties.get(keyLogThreshold);
- if (property != null) /* if null we will just use the default */
- {
- if (!(property instanceof Integer)) {
- throw new ConfigurationException(keyLogThreshold, "not an Integer"); //$NON-NLS-1$
- }
-
- threshold = ((Integer) property).intValue();
-
- if ((threshold < LogService.LOG_ERROR) || (threshold > LogService.LOG_DEBUG)) {
- throw new ConfigurationException(keyLogThreshold, "must be one of the LogService defined Log levels"); //$NON-NLS-1$
- }
- }
-
- /* Configuration values have been validated */
- if (size != logSize) {
- updateLogSize(size);
- }
-
- if (threshold != logThreshold) {
- updateLogThreshold(threshold);
- }
- }
- }
-
- /**
- * This method must be called while synchronized.
- *
- */
- private void updateLogSize(int size) {
- LogEntry[] newlog = new LogEntry[size];
-
- if (head <= tail) { /* log is not full */
- int count = tail - head + 1;
- if (size > count) { /* is new log bigger? */
- System.arraycopy(logEntries, head, newlog, 0, count);
- tail = count - 1;
- } else { /* new log smaller */
- System.arraycopy(logEntries, head + count - size, newlog, 0, size);
- tail = size - 1;
- }
- } else { /* log is full */
- int count = tail + 1 + logSize - head;
- if (size > count) { /* is new log bigger? */
- int boundary = logSize - head;
- System.arraycopy(logEntries, head, newlog, 0, boundary);
- System.arraycopy(logEntries, 0, newlog, boundary, count - boundary);
- tail = count - 1;
- } else { /* new log smaller */
- if ((tail + 1) < size) { /* is log big enough to hold first half? */
- int boundary = size - (tail + 1);
- System.arraycopy(logEntries, logSize - boundary, newlog, 0, boundary);
- System.arraycopy(logEntries, 0, newlog, boundary, tail + 1);
- } else {
- System.arraycopy(logEntries, tail + 1 - size, newlog, 0, size); //9626
- }
- tail = size - 1;
- }
- }
-
- logEntries = newlog;
- logSize = size;
-
- head = 0;
-
- String changemessage = NLS.bind(LogMsg.Log_modified_Log_Size, String.valueOf(logSize));
-
- log(LogService.LOG_INFO, changemessage, context.getBundle(), null, null);
- }
-
- /**
- * This method must be called while synchronized.
- *
- */
- private void updateLogThreshold(int threshold) {
- logThreshold = threshold;
-
- String changemessage = NLS.bind(LogMsg.Log_modified_Log_Threshold, String.valueOf(logThreshold));
-
- log(LogService.LOG_INFO, changemessage, context.getBundle(), null, null);
- }
-
- protected void registerManagedService() {
- /* Register a Managed Service to handle updates to the Log configuration values */
- Hashtable properties = new Hashtable(7);
-
- properties.put(Constants.SERVICE_VENDOR, "IBM"); //$NON-NLS-1$
- properties.put(Constants.SERVICE_DESCRIPTION, LogMsg.OSGi_Log_Service_IBM_Implementation);
- properties.put(Constants.SERVICE_PID, LOGSERVICEPID);
-
- logmanagedservice = context.registerService(ManagedService.class.getName(), this, properties);
- }
-
- private void registerLogService() {
- Hashtable properties = new Hashtable(7);
-
- properties.put(Constants.SERVICE_VENDOR, "IBM"); //$NON-NLS-1$
- properties.put(Constants.SERVICE_DESCRIPTION, LogMsg.OSGi_Log_Service_IBM_Implementation);
- properties.put(Constants.SERVICE_PID, LogServiceImpl.class.getName());
-
- logservice = context.registerService(LogService.class.getName(), new LogServiceFactory(this), properties);
-
- }
-
- private void registerLogReaderService() {
- Hashtable properties = new Hashtable(7);
-
- properties.put(Constants.SERVICE_VENDOR, "IBM"); //$NON-NLS-1$
- properties.put(Constants.SERVICE_DESCRIPTION, LogMsg.OSGi_Log_Service_IBM_Implementation);
- properties.put(Constants.SERVICE_PID, LogReaderService.class.getName());
-
- logreaderservice = context.registerService(org.osgi.service.log.LogReaderService.class.getName(), new LogReaderServiceFactory(this), properties);
- }
-}
diff --git a/bundles/org.eclipse.equinox.log/src/org/eclipse/equinox/log/ExternalMessages.properties b/bundles/org.eclipse.equinox.log/src/org/eclipse/equinox/log/ExternalMessages.properties
deleted file mode 100644
index afe1d75cd..000000000
--- a/bundles/org.eclipse.equinox.log/src/org/eclipse/equinox/log/ExternalMessages.properties
+++ /dev/null
@@ -1,19 +0,0 @@
-###############################################################################
-# Copyright (c) 1999, 2005 IBM Corporation.
-# 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:
-# IBM Corporation - initial API and implementation
-###############################################################################
-# NLS_MESSAGEFORMAT_ALL
-
-Log_created_Log_Size=Log created; Log Size={0}; Log Threshold={1}
-Log_modified_Log_Size=Log modified; Log Size={0}
-Log_modified_Log_Threshold=Log modified; Log Threshold={0}
-OSGi_Log_Service_IBM_Implementation=OSGi Log Service - IBM Implementation
-BundleEvent=BundleEvent {0}
-ServiceEvent=ServiceEvent {0}
-FrameworkEvent=FrameworkEvent {0} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.log/src/org/eclipse/equinox/log/LogEntry.java b/bundles/org.eclipse.equinox.log/src/org/eclipse/equinox/log/LogEntry.java
deleted file mode 100644
index d4b5ee03d..000000000
--- a/bundles/org.eclipse.equinox.log/src/org/eclipse/equinox/log/LogEntry.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1999, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.log;
-
-import org.osgi.framework.Bundle;
-import org.osgi.framework.ServiceReference;
-
-/**
- * The memory space aware LogEntry implementation.
- */
-public class LogEntry implements org.osgi.service.log.LogEntry, Cloneable {
- /**
- * The severity of the log entry that should be one of the
- * four levels defined in the <code>LogService</code> interface.
- */
- protected int level;
-
- /** The <code>System.currentTimeMillis()</code> the entry was made. */
- protected long time;
-
- /** The bundle that created the log entry. */
- protected Bundle bundle;
-
- /** The service reference that caused the log entry. */
- protected ServiceReference serviceReference;
-
- /** The log message. */
- protected String message;
-
- /**
- * The copy of the exception that caused the log
- * or <code>null</code>.
- */
- protected LoggedException loggedException;
-
- /**
- * Creates a log entry,
- *
- * @param level the severity (one of 4 as defined by LogService)
- * @param message the message text
- * @param bundle the bundle that created the entry
- * @param reference the reference to the service associated with the entry
- * @param exception the exception that caused that log entry or <code>null</code>
- */
- protected LogEntry(int level, String message, Bundle bundle, ServiceReference reference, Throwable exception) {
- this.time = System.currentTimeMillis();
- this.level = level;
-
- // make a copy of the message so it lives in this memory space
- if (message != null) {
- this.message = new String(message.toCharArray());
- }
-
- this.bundle = bundle;
- this.serviceReference = reference;
-
- // Make a copy of the exception in this memory space
- if (exception != null) {
- this.loggedException = new LoggedException(exception);
- }
- }
-
- /**
- * Returns the bundle that created this log entry.
- */
- public Bundle getBundle() {
- return (bundle);
- }
-
- /**
- * Returns the service that this log entry is associated with.
- */
- public ServiceReference getServiceReference() {
- return (serviceReference);
- }
-
- /**
- * Returns the severity of the log entry.
- * Should be one of the four levels defined in LogService.
- */
- public int getLevel() {
- return (level);
- }
-
- /**
- * Returns the human readable message that was
- * recorded with this log entry.
- */
- public String getMessage() {
- return (message);
- }
-
- /**
- * Returns the exception that was recorded with this log entry.
- *
- * A {@link LoggedException) that contains information about
- * the original exception is returned.
- */
- public Throwable getException() {
- return (loggedException);
- }
-
- /**
- * Returns the time log entry was created.
- */
- public long getTime() {
- return (time);
- }
-
- /**
- * Returns a copy of this log entry. The copy will contain
- * references to clopies of the internal data, not references
- * to the original internal data of this <code>LogEntry</code> object.
- *
- * @return A deep copy of this log entry.
- */
- public LogEntry copy() {
- LogEntry copy = new LogEntry(level, message, bundle, serviceReference, loggedException);
- copy.time = time;
- return (copy);
- }
-}
diff --git a/bundles/org.eclipse.equinox.log/src/org/eclipse/equinox/log/LogMsg.java b/bundles/org.eclipse.equinox.log/src/org/eclipse/equinox/log/LogMsg.java
deleted file mode 100644
index d7a8d52c8..000000000
--- a/bundles/org.eclipse.equinox.log/src/org/eclipse/equinox/log/LogMsg.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.log;
-
-import org.eclipse.osgi.util.NLS;
-
-public class LogMsg extends NLS {
- private static final String BUNDLE_NAME = "org.eclipse.equinox.log.ExternalMessages"; //$NON-NLS-1$
-
- public static String Log_created_Log_Size;
- public static String Log_modified_Log_Size;
- public static String Log_modified_Log_Threshold;
- public static String OSGi_Log_Service_IBM_Implementation;
- public static String BundleEvent;
- public static String ServiceEvent;
- public static String FrameworkEvent;
-
- static {
- // initialize resource bundles
- NLS.initializeMessages(BUNDLE_NAME, LogMsg.class);
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.log/src/org/eclipse/equinox/log/LogReaderService.java b/bundles/org.eclipse.equinox.log/src/org/eclipse/equinox/log/LogReaderService.java
deleted file mode 100644
index b6f92e3d2..000000000
--- a/bundles/org.eclipse.equinox.log/src/org/eclipse/equinox/log/LogReaderService.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1999, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.log;
-
-import java.util.Enumeration;
-import java.util.Vector;
-import org.eclipse.osgi.framework.eventmgr.EventDispatcher;
-import org.eclipse.osgi.framework.eventmgr.EventListeners;
-import org.osgi.framework.Bundle;
-import org.osgi.service.log.LogListener;
-
-/**
- * LogReaderService class.
- */
-
-public class LogReaderService implements org.osgi.service.log.LogReaderService, EventDispatcher {
- protected Activator log;
- protected Bundle bundle;
- protected EventListeners logEvent;
-
- protected LogReaderService(Activator log, Bundle bundle) {
- this.log = log;
- this.bundle = bundle;
- logEvent = null;
- }
-
- protected void close() {
- Activator tempLog = this.log;
- this.log = null;
- this.bundle = null;
-
- if (logEvent != null) {
- tempLog.logEvent.removeListener(this);
- logEvent.removeAllListeners();
- logEvent = null;
- }
- }
-
- public void dispatchEvent(Object l, Object lo, int action, Object object) {
- Activator tempLog = this.log;
-
- if (tempLog == null) {
- return;
- }
-
- LogListener listener = (LogListener) lo;
- listener.logged(((LogEntry) object).copy());
- }
-
- /*
- * ----------------------------------------------------------------------
- * LogReaderService Interface implementation
- * ----------------------------------------------------------------------
- */
-
- /**
- * Subscribe to log events. The LogListener will get a callback each
- * time a message is logged. The requester must have Admin permission.
- */
- public void addLogListener(LogListener listener) {
- Activator tempLog = this.log;
-
- if (tempLog == null) {
- return;
- }
-
- synchronized (tempLog.logEvent) {
- if (logEvent == null) {
- logEvent = new EventListeners();
- tempLog.logEvent.addListener(this, this);
- } else {
- logEvent.removeListener(listener);
- }
-
- logEvent.addListener(listener, listener);
- }
- }
-
- /**
- * Unsubscribe to log events. The requester must have Admin permission.
- */
- public void removeLogListener(LogListener listener) {
- Activator tempLog = this.log;
-
- if (tempLog == null) {
- return;
- }
-
- if (logEvent != null) {
- synchronized (tempLog.logEvent) {
- logEvent.removeListener(listener);
- }
- }
- }
-
- /**
- * Returns an enumeration of the last log messages. Each element will
- * be of type LogEntry. Whether the enumeration is of all the logs since
- * bootup or the recent past is implementation specific. Also whether
- * informational and debug entries are included in the logging interval
- * is implementation specific. The requester must have Admin permission.
- */
- public Enumeration getLog() {
- Activator tempLog = this.log;
-
- if (tempLog == null) {
- return (new Vector(0).elements());
- }
-
- return (tempLog.logEntries());
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.log/src/org/eclipse/equinox/log/LogReaderServiceFactory.java b/bundles/org.eclipse.equinox.log/src/org/eclipse/equinox/log/LogReaderServiceFactory.java
deleted file mode 100644
index b7fa92a88..000000000
--- a/bundles/org.eclipse.equinox.log/src/org/eclipse/equinox/log/LogReaderServiceFactory.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1999, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.log;
-
-import org.osgi.framework.*;
-
-/**
- * LogReaderServiceFactory class.
- */
-
-public class LogReaderServiceFactory implements ServiceFactory {
- protected Activator log;
-
- protected LogReaderServiceFactory(Activator log) {
- this.log = log;
- }
-
- /**
- * ServiceFactory.getService method.
- */
- public Object getService(Bundle bundle, ServiceRegistration registration) {
- return (new LogReaderService(log, bundle));
- }
-
- /**
- * ServiceFactory.ungetService method.
- */
- public void ungetService(Bundle bundle, ServiceRegistration registration, Object service) {
- ((LogReaderService) service).close();
- }
-}
diff --git a/bundles/org.eclipse.equinox.log/src/org/eclipse/equinox/log/LogServiceFactory.java b/bundles/org.eclipse.equinox.log/src/org/eclipse/equinox/log/LogServiceFactory.java
deleted file mode 100644
index c038d61f8..000000000
--- a/bundles/org.eclipse.equinox.log/src/org/eclipse/equinox/log/LogServiceFactory.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1999, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.log;
-
-import org.osgi.framework.*;
-
-/**
- * LogServiceFactory class.
- */
-
-public class LogServiceFactory implements ServiceFactory {
- protected Activator log;
-
- protected LogServiceFactory(Activator log) {
- this.log = log;
- }
-
- /**
- * ServiceFactory.getService method.
- */
- public Object getService(Bundle bundle, ServiceRegistration registration) {
- return (new LogServiceImpl(log, bundle));
- }
-
- /**
- * ServiceFactory.ungetService method.
- */
- public void ungetService(Bundle bundle, ServiceRegistration registration, Object service) {
- ((LogServiceImpl) service).close();
- }
-}
diff --git a/bundles/org.eclipse.equinox.log/src/org/eclipse/equinox/log/LogServiceImpl.java b/bundles/org.eclipse.equinox.log/src/org/eclipse/equinox/log/LogServiceImpl.java
deleted file mode 100644
index 2a7e1a8ed..000000000
--- a/bundles/org.eclipse.equinox.log/src/org/eclipse/equinox/log/LogServiceImpl.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1999, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.log;
-
-import org.osgi.framework.Bundle;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.log.LogService;
-
-/**
- * LogServiceImpl class.
- */
-
-public class LogServiceImpl implements LogService {
- protected Activator log;
- protected Bundle bundle;
-
- protected LogServiceImpl(Activator log, Bundle bundle) {
- this.log = log;
- this.bundle = bundle;
- }
-
- protected void close() {
- log = null;
- bundle = null;
- }
-
- /*
- * ----------------------------------------------------------------------
- * LogService Interface implementation
- * ----------------------------------------------------------------------
- */
-
- /**
- * Required by LogService Interface.
- * Log a bundle message. The ServiceDescription field and the
- * Throwable field of the LogEntry will be set to null.
- * @param int level - The severity of the message. (Should be one of the
- * four predefined severities.)
- * @param String message - Human readable string describing the condition.
- */
- public void log(int level, String message) {
- Activator tempLog = this.log;
-
- if (tempLog == null) {
- return;
- }
-
- tempLog.log(level, message, bundle, null, null);
- }
-
- /**
- * Required by LogService Interface.
- * Log a bundle message. The ServiceDescription field
- * of the LogEntry will be set to null.
- * @param int level - The severity of the message. (Should be one of the
- * four predefined severities.)
- * @param String message - Human readable string describing the condition.
- * @param Throwable exception - The exception that reflects the condition.
- */
- public void log(int level, String message, Throwable exception) {
- Activator tempLog = this.log;
-
- if (tempLog == null) {
- return;
- }
-
- tempLog.log(level, message, bundle, null, exception);
- }
-
- /**
- * Required by LogService Interface.
- * Log a message associated with a specific bundle service. The
- * Throwable field of the LogEntry will be set to null.
- * @param reference The ServiceReference of the service that this message
- * is associated with.
- * @param level The severity of the message. (Should be one of the
- * four predefined severities.)
- * @param message Human readable string describing the condition.
- */
- public void log(ServiceReference reference, int level, String message) {
- Activator tempLog = this.log;
-
- if (tempLog == null) {
- return;
- }
-
- tempLog.log(level, message, bundle, reference, null);
- }
-
- /**
- * Required by LogService Interface.
- * Log a bundle message.
- * @param reference The ServiceReference of the service that this message
- * is associated with.
- * @param level The severity of the message. (Should be one of the
- * four predefined severities.)
- * @param message Human readable string describing the condition.
- * @param exception The exception that reflects the condition.
- */
- public void log(ServiceReference reference, int level, String message, Throwable exception) {
- Activator tempLog = this.log;
-
- if (tempLog == null) {
- return;
- }
-
- tempLog.log(level, message, bundle, reference, exception);
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.log/src/org/eclipse/equinox/log/LoggedException.java b/bundles/org.eclipse.equinox.log/src/org/eclipse/equinox/log/LoggedException.java
deleted file mode 100644
index 6417ceed7..000000000
--- a/bundles/org.eclipse.equinox.log/src/org/eclipse/equinox/log/LoggedException.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1999, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.log;
-
-import java.io.*;
-import java.lang.reflect.*;
-
-/**
- * Encapsulate an <code>Exception</code>
- * or <code>Error</code> in a logging message.
- * <p>
- * The stack trace information of a <code>Throwable</code>
- * is transient and therefore this information is lost
- * if the throwable is serialized or cloned.<br>
- * This class extracts the stack trace information from the throwable
- * and keeps it for later retrieval.
- * <p>
- * The <code>Throwable</code> instance itself and any nested exceptions
- * are not kept in the <code>LoggedException</code> for 2 reasons:<ol>
- * <li>so no reference to that throwable is kept that would prevent
- * the removal of the memory space that hosts the throwable
- * with <em>NOFORCE</em>.</li>
- * <li>the class of the throwable can be removed from the
- * system and the class loader segments can be freed.</li>
- * </ol>
- * <p>
- */
-
-/* This class MUST be public for nested exception printing to work */
-public class LoggedException extends Throwable implements Cloneable {
-
- private static final long serialVersionUID = -7432693545895678645L;
-
- /** The fully qualified name of exception or error type. */
- String exceptionClassName;
-
- /**
- * The detail message.
- * Don't use super class field because we need to be able to
- * copy it into another memory space.
- */
- String message;
-
- /**
- * The stack trace.
- * The super class field is transient.
- */
- String stackTrace;
-
- /**
- * The nested exception if any.
- */
- LoggedException nestedException;
-
- /**
- * Creates a wrapper of the given <code>Throwable</code>,
- *
- * @param t the exception or error
- */
- public LoggedException(Throwable t) {
- super();
-
- // copy original exception message
- if (t.getMessage() != null) {
- message = new String(t.getMessage().toCharArray());
- }
- if (t instanceof LoggedException) {
- LoggedException lex = (LoggedException) t;
- exceptionClassName = lex.exceptionClassName;
- // copy stack trace
- stackTrace = new String(lex.stackTrace.toCharArray());
- } else {
- exceptionClassName = t.getClass().getName();
- // save stack trace
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- PrintStream s = new PrintStream(baos);
- t.printStackTrace(s);
- s.close();
- stackTrace = baos.toString();
-
- }
- // copy original exception class name
- exceptionClassName = new String(exceptionClassName.toCharArray());
-
- // search for a nested exception
-
- // Field[] fields = t.getClass().getFields();
- // for (int i = 0; i < fields.length; i++) {
- // try {
- // Object o = fields[i].get(t);
- // if (o != null && o instanceof Throwable) {
- // nestedException = new LoggedException((Throwable) o);
- // break;
- // }
- // } catch (IllegalAccessException e) {}
- // }
-
- Method[] methods = t.getClass().getMethods();
-
- int size = methods.length;
- Class throwable = Throwable.class;
-
- for (int i = 0; i < size; i++) {
- Method method = methods[i];
-
- if (Modifier.isPublic(method.getModifiers()) && method.getName().startsWith("get") && //$NON-NLS-1$
- throwable.isAssignableFrom(method.getReturnType()) && (method.getParameterTypes().length == 0)) {
- try {
- Throwable nested = (Throwable) method.invoke(t, null);
-
- if ((nested != null) && (nested != t)) {
- nestedException = new LoggedException(nested);
- break;
- }
- } catch (IllegalAccessException e) {
- // TODO: Consider wrapping and throwing a RuntimeException
- } catch (InvocationTargetException e) {
- // TODO: Consider wrapping and throwing a RuntimeException
- }
- }
- }
- }
-
- /**
- * Does nothing.
- * <p>
- * This is a wrapper of an <code>Exception</code> or <code>Error</code>.
- * Hence it does not need it's own stack trace filled in.
- */
- public Throwable fillInStackTrace() {
- return this;
- }
-
- /**
- * Returns the class name of the original
- * <code>Exception</code> or <code>Error</code>.
- */
- public String getExceptionClassName() {
- return exceptionClassName;
- }
-
- /**
- * Returns the human readable message describing the condition
- * of the original <code>Exception</code> or <code>Error</code>.
- */
- public String getMessage() {
- return message;
- }
-
- /**
- * Returns the nested <code>LoggedException</code>
- * or <code>null/code> if there is none.
- */
- public Throwable getNestedException() {
- return nestedException;
- }
-
- /**
- * Prints the backtrace of the original <code>Exception</code> or <code>Error</code>.
- */
- public void printStackTrace() {
- printStackTrace(System.err);
- }
-
- /**
- * Prints the backtrace of the original <code>Exception</code> or <code>Error</code>.
- */
- public void printStackTrace(PrintStream s) {
- synchronized (s) {
- s.println(stackTrace);
- }
- }
-
- /**
- * Prints the backtrace of the original <code>Exception</code> or <code>Error</code>.
- */
- public void printStackTrace(PrintWriter w) {
- synchronized (w) {
- w.println(stackTrace);
- }
- }
-
- /**
- * Returns a string representation of the original
- * <code>Exception</code> or <code>Error</code>.
- *
- * @return The string representation of the receiver.
- */
- public String toString() {
- if (message == null) {
- return exceptionClassName;
- }
- int length = exceptionClassName.length() + message.length() + 2;
- return new StringBuffer(length).append(exceptionClassName).append(": ").append(message).toString(); //$NON-NLS-1$
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.metatype/.classpath b/bundles/org.eclipse.equinox.metatype/.classpath
deleted file mode 100644
index 751c8f2e5..000000000
--- a/bundles/org.eclipse.equinox.metatype/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/bundles/org.eclipse.equinox.metatype/.cvsignore b/bundles/org.eclipse.equinox.metatype/.cvsignore
deleted file mode 100644
index ba077a403..000000000
--- a/bundles/org.eclipse.equinox.metatype/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
diff --git a/bundles/org.eclipse.equinox.metatype/.project b/bundles/org.eclipse.equinox.metatype/.project
deleted file mode 100644
index eeb18ab0a..000000000
--- a/bundles/org.eclipse.equinox.metatype/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.equinox.metatype</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/bundles/org.eclipse.equinox.metatype/.settings/org.eclipse.jdt.core.prefs b/bundles/org.eclipse.equinox.metatype/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 1d39c60da..000000000
--- a/bundles/org.eclipse.equinox.metatype/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,49 +0,0 @@
-#Fri Dec 16 09:20:40 CST 2005
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
-org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
-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=warning
-org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
-org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
-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=warning
-org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
-org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
-org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
-org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
-org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
-org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
-org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore
-org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
-org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
-org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning
-org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
-org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
-org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
-org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.unusedImport=error
-org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
-org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
-org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
-org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
diff --git a/bundles/org.eclipse.equinox.metatype/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.metatype/META-INF/MANIFEST.MF
deleted file mode 100644
index c864b97c8..000000000
--- a/bundles/org.eclipse.equinox.metatype/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,16 +0,0 @@
-Bundle-ManifestVersion: 2
-Bundle-Name: %bundleName
-Bundle-Version: 1.0.0.qualifier
-Bundle-SymbolicName: org.eclipse.equinox.metatype
-Bundle-Activator: org.eclipse.equinox.metatype.Activator
-Import-Package: org.eclipse.osgi.util,
- org.osgi.framework,
- org.osgi.service.cm,
- org.osgi.service.metatype,
- org.osgi.service.packageadmin,
- org.osgi.util.tracker
-Export-Package: org.eclipse.equinox.metatype;x-internal:=true
-Bundle-Vendor: %bundleVendor
-Bundle-Copyright: %bundleCopyright
-Bundle-Localization: plugin
-Export-Service: org.osgi.service.metatype.MetaTypeService
diff --git a/bundles/org.eclipse.equinox.metatype/about.html b/bundles/org.eclipse.equinox.metatype/about.html
deleted file mode 100644
index b2f1e6bad..000000000
--- a/bundles/org.eclipse.equinox.metatype/about.html
+++ /dev/null
@@ -1,22 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
-<!-- saved from url=(0043)http://www.eclipse.org/legal/epl/about.html -->
-<HTML><HEAD><TITLE>About</TITLE>
-<META http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-<META content="MSHTML 6.00.2800.1498" name=GENERATOR></HEAD>
-<BODY lang=EN-US>
-<H2>About This Content</H2>
-<P>February 24, 2005</P>
-<H3>License</H3>
-<P>The Eclipse Foundation makes available all content in this plug-in
-("Content"). Unless otherwise indicated below, the Content is provided to you
-under the terms and conditions of the Eclipse Public License Version 1.0
-("EPL"). A copy of the EPL is available at <A
-href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</A>.
-For purposes of the EPL, "Program" will mean the Content.</P>
-<P>If you did not receive this Content directly from the Eclipse Foundation, the
-Content is being redistributed by another party ("Redistributor") and different
-terms and conditions may apply to your use of any object code in the Content.
-Check the Redistributor's license that was provided with the Content. If no such
-license exists, contact the Redistributor. Unless otherwise indicated below, the
-terms and conditions of the EPL still apply to any source code in the
-Content.</P></BODY></HTML>
diff --git a/bundles/org.eclipse.equinox.metatype/build.properties b/bundles/org.eclipse.equinox.metatype/build.properties
deleted file mode 100644
index 873261924..000000000
--- a/bundles/org.eclipse.equinox.metatype/build.properties
+++ /dev/null
@@ -1,17 +0,0 @@
-###############################################################################
-# Copyright (c) 2005 IBM Corporation.
-# 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:
-# IBM Corporation - initial API and implementation
-###############################################################################
-bin.includes = META-INF/,\
- plugin*.properties,\
- about.html,\
- .
-src.includes = about.html
-source.. = src/
-output.. = bin/
diff --git a/bundles/org.eclipse.equinox.metatype/plugin.properties b/bundles/org.eclipse.equinox.metatype/plugin.properties
deleted file mode 100644
index 6c8069430..000000000
--- a/bundles/org.eclipse.equinox.metatype/plugin.properties
+++ /dev/null
@@ -1,13 +0,0 @@
-###############################################################################
-# Copyright (c) 2005 IBM Corporation.
-# 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:
-# IBM Corporation - initial API and implementation
-###############################################################################
-bundleVendor = Eclipse.org
-bundleName = Meta Type
-bundleCopyright = Copyright (c) IBM Corp. 2005
diff --git a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/Activator.java b/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/Activator.java
deleted file mode 100644
index ebba91abc..000000000
--- a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/Activator.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.metatype;
-
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.Hashtable;
-import javax.xml.parsers.SAXParserFactory;
-import org.osgi.framework.*;
-import org.osgi.service.packageadmin.PackageAdmin;
-import org.osgi.util.tracker.ServiceTracker;
-import org.osgi.util.tracker.ServiceTrackerCustomizer;
-
-/**
- * MetaType Activator
- */
-public class Activator implements BundleActivator, ServiceTrackerCustomizer {
-
- protected final String mtsClazz = "org.osgi.service.metatype.MetaTypeService"; //$NON-NLS-1$
- protected final String mtsPid = "org.osgi.impl.service.metatype.MetaTypeService"; //$NON-NLS-1$
- protected final static String saxFactoryClazz = "javax.xml.parsers.SAXParserFactory"; //$NON-NLS-1$
-
- private ServiceTracker _parserTracker;
- BundleContext _context;
- ServiceRegistration _mtsReg;
- MetaTypeServiceImpl _mts = null;
-
- /**
- * The current SaxParserFactory being used by the WebContainer
- */
- private SAXParserFactory _currentParserFactory = null;
-
- /**
- * The lock used when modifying the currentParserFactory
- */
- private Object lock = new Object();
-
- /*
- * (non-Javadoc)
- *
- * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
- */
- public void start(BundleContext context) throws Exception {
-
- this._context = context;
- _parserTracker = new ServiceTracker(context, saxFactoryClazz, this);
- _parserTracker.open();
- ServiceReference ref = context.getServiceReference(PackageAdmin.class.getName());
- FragmentUtils.packageAdmin = ref == null ? null : (PackageAdmin) context.getService(ref);
- Logging.debug("====== Meta Type Service starting ! ====="); //$NON-NLS-1$
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
- */
- public void stop(BundleContext context) throws Exception {
-
- Logging.debug("====== Meta Type Service stoping ! ====="); //$NON-NLS-1$
- _parserTracker.close();
- _parserTracker = null;
- FragmentUtils.packageAdmin = null;
- context = null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.osgi.util.tracker.ServiceTrackerCustomizer#addingService(org.osgi.framework.ServiceReference)
- */
- public Object addingService(ServiceReference ref) {
-
- SAXParserFactory parserFactory = (SAXParserFactory) _context.getService(ref);
- synchronized (lock) {
- if (_mts == null) {
- // Save this parserFactory as the currently used parserFactory
- _currentParserFactory = parserFactory;
- registerMetaTypeService();
- }
- }
- return parserFactory;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.osgi.util.tracker.ServiceTrackerCustomizer#modifiedService(org.osgi.framework.ServiceReference,
- * java.lang.Object)
- */
- public void modifiedService(ServiceReference ref, Object object) {
- // do nothing
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.osgi.util.tracker.ServiceTrackerCustomizer#removedService(org.osgi.framework.ServiceReference,
- * java.lang.Object)
- */
- public void removedService(ServiceReference ref, Object object) {
-
- SAXParserFactory parserFactory = (SAXParserFactory) _context.getService(ref);
-
- if (parserFactory == _currentParserFactory) {
- // This means that this SAXParserFactory was used to start the
- // MetaType Service.
- synchronized (lock) {
- _currentParserFactory = null;
-
- if (_mtsReg != null) {
- _mtsReg.unregister();
- _mtsReg = null;
- _context.removeBundleListener(_mts);
- _mts = null;
- parserFactory = null;
- }
- // See if another factory is available
- Object[] parsers = _parserTracker.getServices();
- if (parsers != null && parsers.length > 0) {
- _currentParserFactory = (SAXParserFactory) parsers[0];
- // We have another parser so lets restart the MetaType
- // Service
- registerMetaTypeService();
- }
- }
- }
- }
-
- /**
- * Internal method in MetaTypeActivator for implementing
- * ServiceTrackerCustomizer.
- */
- private void registerMetaTypeService() {
-
- final Hashtable properties = new Hashtable(7);
-
- properties.put(Constants.SERVICE_VENDOR, "IBM"); //$NON-NLS-1$
- properties.put(Constants.SERVICE_DESCRIPTION, MetaTypeMsg.SERVICE_DESCRIPTION);
- properties.put(Constants.SERVICE_PID, mtsPid);
-
- _mts = new MetaTypeServiceImpl(_context, _currentParserFactory);
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- _context.addBundleListener(_mts);
- _mtsReg = _context.registerService(mtsClazz, _mts, properties);
- return null;
- }
- });
- }
-}
diff --git a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/AttributeDefinitionImpl.java b/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/AttributeDefinitionImpl.java
deleted file mode 100644
index 93ee05504..000000000
--- a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/AttributeDefinitionImpl.java
+++ /dev/null
@@ -1,486 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.metatype;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.util.Enumeration;
-import java.util.Vector;
-import org.eclipse.osgi.util.NLS;
-import org.osgi.service.metatype.AttributeDefinition;
-
-/**
- * Implementation of AttributeDefintion
- */
-public class AttributeDefinitionImpl extends LocalizationElement implements AttributeDefinition, Cloneable {
-
- String _name;
- String _id;
- String _description;
- int _cardinality = 0;
- int _dataType;
- Object _minValue = null;
- Object _maxValue = null;
- boolean _isRequired = true;
-
- String[] _defaults = null;
- Vector _dfts_vector = new Vector(7);
- Vector _values = new Vector(7);
- Vector _labels = new Vector(7);
-
- /**
- * Constructor of class AttributeDefinitionImpl.
- */
- public AttributeDefinitionImpl(String id, String name, String description, int type, int cardinality, Object min, Object max, boolean isRequired, String localization) {
-
- this._id = id;
- this._name = name;
- this._description = description;
- this._dataType = type;
- this._cardinality = cardinality;
- this._minValue = min;
- this._maxValue = max;
- this._isRequired = isRequired;
- this._localization = localization;
- }
-
- /*
- *
- */
- public synchronized Object clone() {
-
- AttributeDefinitionImpl ad = new AttributeDefinitionImpl(_id, _name, _description, _dataType, _cardinality, _minValue, _maxValue, _isRequired, _localization);
-
- if (_defaults != null) {
- ad.setDefaultValue((String[]) _defaults.clone(), false);
- }
- if ((_labels != null) && (_values != null)) {
- ad.setOption((Vector) _labels.clone(), (Vector) _values.clone(), false);
- }
-
- return ad;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.osgi.service.metatype.AttributeDefinition#getName()
- */
- public String getName() {
- return getLocalized(_name);
- }
-
- /**
- * Method to set the name of AttributeDefinition.
- */
- void setName(String name) {
- this._name = name;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.osgi.service.metatype.AttributeDefinition#getID()
- */
- public String getID() {
- return _id;
- }
-
- /**
- * Method to set the ID of AttributeDefinition.
- */
- void setID(String id) {
- this._id = id;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.osgi.service.metatype.AttributeDefinition#getDescription()
- */
- public String getDescription() {
- return getLocalized(_description);
- }
-
- /**
- * Method to set the description of AttributeDefinition.
- */
- void setDescription(String description) {
- this._description = description;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.osgi.service.metatype.AttributeDefinition#getCardinality()
- */
- public int getCardinality() {
- return _cardinality;
- }
-
- /**
- * Method to set the cardinality of AttributeDefinition.
- */
- void setCardinality(int cardinality) {
- this._cardinality = cardinality;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.osgi.service.metatype.AttributeDefinition#getType()
- */
- public int getType() {
- return _dataType;
- }
-
- /**
- * Method to set the data type of AttributeDefinition.
- */
- void setType(int type) {
- this._dataType = type;
- }
-
- /**
- * Method to get the required flag of AttributeDefinition.
- */
- boolean isRequired() {
- return _isRequired;
- }
-
- /**
- * Method to set the required flag of AttributeDefinition.
- */
- void setRequired(boolean isRequired) {
- this._isRequired = isRequired;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.osgi.service.metatype.AttributeDefinition#getOptionLabels()
- */
- public String[] getOptionLabels() {
-
- if ((_labels == null) || (_labels.size() == 0)) {
- return null;
- }
-
- String[] returnedLabels = new String[_labels.size()];
- Enumeration labelKeys = _labels.elements();
- int i = 0;
- while (labelKeys.hasMoreElements()) {
- String labelKey = (String) labelKeys.nextElement();
- returnedLabels[i] = getLocalized(labelKey);
- i++;
- }
- return returnedLabels;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.osgi.service.metatype.AttributeDefinition#getOptionValues()
- */
- public String[] getOptionValues() {
-
- if ((_values == null) || (_values.size() == 0)) {
- return null;
- }
-
- String[] returnedValues = new String[_values.size()];
- Enumeration valueKeys = _values.elements();
- int i = 0;
- while (valueKeys.hasMoreElements()) {
- String valueKey = (String) valueKeys.nextElement();
- returnedValues[i] = getLocalized(valueKey);
- i++;
- }
- return returnedValues;
- }
-
- /**
- * Method to set the Option values of AttributeDefinition.
- */
- void setOption(Vector labels, Vector values, boolean needValidation) {
-
- if ((labels == null) || (values == null)) {
- Logging.log(Logging.ERROR, this, "setOption(Vector, Vector, boolean)", //$NON-NLS-1$
- MetaTypeMsg.NULL_OPTIONS);
- return;
- }
-
- if (labels.size() != values.size()) {
- Logging.log(Logging.ERROR, this, "setOption(Vector, Vector, boolean)", //$NON-NLS-1$
- MetaTypeMsg.INCONSISTENT_OPTIONS);
- return;
- }
-
- _labels = labels;
- _values = values;
-
- if (needValidation) {
- for (int index = 0; index < _labels.size(); index++) {
- String reason = validate((String) _values.get(index));
- if ((reason != null) && reason.length() > 0) {
- Logging.log(Logging.WARN, NLS.bind(MetaTypeMsg.INVALID_OPTIONS, _values.get(index), reason));
- _labels.remove(index);
- _values.remove(index);
- index--; // Because this one has been removed.
- }
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.osgi.service.metatype.AttributeDefinition#getDefaultValue()
- */
- public String[] getDefaultValue() {
- return _defaults;
- }
-
- /**
- * Method to set the default value of AttributeDefinition.
- * The given parameter is a comma delimited list needed to be parsed.
- */
- void setDefaultValue(String defaults_str, boolean needValidation) {
-
- ValueTokenizer vt = new ValueTokenizer(defaults_str);
- setDefaultValue(vt.getValuesAsArray(), needValidation);
- }
-
- /**
- * Method to set the default value of AttributeDefinition.
- * The given parameter is a String array of multi values.
- */
- void setDefaultValue(String[] defaults, boolean needValidation) {
-
- _defaults = defaults;
- // Do we also need to make sure if defaults are validated?
- }
-
- /**
- * Method to set the validation value - min of AttributeDefinition.
- */
- void setMinValue(Object minValue) {
- this._minValue = minValue;
- }
-
- /**
- * Method to set the validation value - max of AttributeDefinition.
- */
- void setMaxValue(Object maxValue) {
- this._maxValue = maxValue;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.osgi.service.metatype.AttributeDefinition#validate(java.lang.String)
- */
- public String validate(String value) {
-
- if (value == null) {
- return MetaTypeMsg.NULL_IS_INVALID;
- }
- if ((_minValue == null) && (_maxValue == null)) {
- if (_dataType != STRING) {
- // No validation present
- return null;
- }
- if (_values.size() < 1)
- // No validation present
- return null;
- }
-
- // Addtional validation for STRING.
- if (_dataType == STRING && _values.size() > 0 && !_values.contains(value)) {
- return NLS.bind(MetaTypeMsg.VALUE_OUT_OF_OPTION, value);
- }
-
- try {
- if (_cardinality != 0) {
- ValueTokenizer vt = new ValueTokenizer(value);
- Vector value_vector = vt.getValuesAsVector();
-
- if (value_vector.size() > Math.abs(_cardinality)) {
- return NLS.bind(MetaTypeMsg.TOO_MANY_VALUES, value, new Integer(Math.abs(_cardinality)));
- }
- for (int i = 0; i < value_vector.size(); i++) {
- String return_msg = validateRange((String) value_vector.get(i));
- if (!"".equals(return_msg)) { //$NON-NLS-1$
- // Returned String states why the value is invalid.
- return return_msg;
- }
- }
- // No problems detected
- return ""; //$NON-NLS-1$
- }
- // Only when cardinality is '0', it comes here.
- String return_msg = validateRange(value);
- return return_msg;
- } catch (Throwable t) {
- return NLS.bind(MetaTypeMsg.EXCEPTION_MESSAGE, t.getClass().getName(), t.getMessage());
- }
- }
-
- /**
- * Internal Method - to validate data in range.
- */
- private String validateRange(String value) {
-
- boolean rangeError = false;
-
- switch (_dataType) {
- case STRING :
- if ((_minValue != null) && (_maxValue != null)) {
- if (value.length() > ((Integer) _maxValue).intValue() || value.length() < ((Integer) _minValue).intValue()) {
- rangeError = true;
- }
- }
- break;
- case LONG :
- Long longVal = new Long(value);
- if (_minValue != null && longVal.compareTo((Long) _minValue) < 0) {
- rangeError = true;
- } else if (_maxValue != null && longVal.compareTo((Long) _maxValue) > 0) {
- rangeError = true;
- }
- break;
- case INTEGER :
- Integer intVal = new Integer(value);
- if (_minValue != null && intVal.compareTo((Integer) _minValue) < 0) {
- rangeError = true;
- } else if (_maxValue != null && intVal.compareTo((Integer) _maxValue) > 0) {
- rangeError = true;
- }
- break;
- case SHORT :
- Short shortVal = new Short(value);
- if (_minValue != null && shortVal.compareTo((Short) _minValue) < 0) {
- rangeError = true;
- } else if (_maxValue != null && shortVal.compareTo((Short) _maxValue) > 0) {
- rangeError = true;
- }
- break;
- case CHARACTER :
- Character charVal = new Character(value.charAt(0));
- if (_minValue != null && charVal.compareTo((Character) _minValue) < 0) {
- rangeError = true;
- } else if (_maxValue != null && charVal.compareTo((Character) _maxValue) > 0) {
- rangeError = true;
- }
- break;
- case BYTE :
- Byte byteVal = new Byte(value);
- if (_minValue != null && byteVal.compareTo((Byte) _minValue) < 0) {
- rangeError = true;
- } else if (_maxValue != null && byteVal.compareTo((Byte) _maxValue) > 0) {
- rangeError = true;
- }
- break;
- case DOUBLE :
- Double doubleVal = new Double(value);
- if (_minValue != null && doubleVal.compareTo((Double) _minValue) < 0) {
- rangeError = true;
- } else if (_maxValue != null && doubleVal.compareTo((Double) _maxValue) > 0) {
- rangeError = true;
- }
- break;
- case FLOAT :
- Float floatVal = new Float(value);
- if (_minValue != null && floatVal.compareTo((Float) _minValue) < 0) {
- rangeError = true;
- } else if (_maxValue != null && floatVal.compareTo((Float) _maxValue) > 0) {
- rangeError = true;
- }
- break;
- case BIGINTEGER :
- try {
- Class bigIntClazz = Class.forName("java.math.BigInteger"); //$NON-NLS-1$
- Constructor bigIntConstructor = bigIntClazz.getConstructor(new Class[] {String.class});
- Comparable bigIntObject = (Comparable) bigIntConstructor.newInstance(new Object[] {value});
- if (_minValue != null && bigIntObject.compareTo(_minValue) < 0) {
- rangeError = true;
- } else if (_maxValue != null && bigIntObject.compareTo(_maxValue) > 0) {
- rangeError = true;
- }
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- return null;
- } catch (SecurityException e) {
- e.printStackTrace();
- return null;
- } catch (NoSuchMethodException e) {
- e.printStackTrace();
- return null;
- } catch (IllegalArgumentException e) {
- e.printStackTrace();
- return null;
- } catch (InstantiationException e) {
- e.printStackTrace();
- return null;
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- return null;
- } catch (InvocationTargetException e) {
- e.printStackTrace();
- return null;
- }
- break;
- case BIGDECIMAL :
- try {
- Class bigDecimalClazz = Class.forName("java.math.BigDecimal"); //$NON-NLS-1$
- Constructor bigDecimalConstructor = bigDecimalClazz.getConstructor(new Class[] {String.class});
- Comparable bigDecimalObject = (Comparable) bigDecimalConstructor.newInstance(new Object[] {value});
- if (_minValue != null && bigDecimalObject.compareTo(_minValue) < 0) {
- rangeError = true;
- } else if (_maxValue != null && bigDecimalObject.compareTo(_maxValue) > 0) {
- rangeError = true;
- }
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- return null;
- } catch (SecurityException e) {
- e.printStackTrace();
- return null;
- } catch (NoSuchMethodException e) {
- e.printStackTrace();
- return null;
- } catch (IllegalArgumentException e) {
- e.printStackTrace();
- return null;
- } catch (InstantiationException e) {
- e.printStackTrace();
- return null;
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- return null;
- } catch (InvocationTargetException e) {
- e.printStackTrace();
- return null;
- }
- break;
- case BOOLEAN :
- // shouldn't ever get boolean - this is a range validation
- default :
- return null;
- }
-
- if (rangeError) {
- return (NLS.bind(MetaTypeMsg.VALUE_OUT_OF_RANGE, value));
- }
- // No problems detected
- return (""); //$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/DataParser.java b/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/DataParser.java
deleted file mode 100644
index 40085e974..000000000
--- a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/DataParser.java
+++ /dev/null
@@ -1,921 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.metatype;
-
-import java.io.*;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.net.URL;
-import java.util.*;
-import javax.xml.parsers.*;
-import org.eclipse.osgi.util.NLS;
-import org.osgi.framework.Bundle;
-import org.osgi.service.metatype.AttributeDefinition;
-import org.xml.sax.*;
-import org.xml.sax.helpers.DefaultHandler;
-
-/**
- * Meta XML Data Parser
- */
-public class DataParser {
- private static final String METADATA = "MetaData"; //$NON-NLS-1$
- private static final String LOCALIZATION = "localization"; //$NON-NLS-1$
- private static final String OCD = "OCD"; //$NON-NLS-1$
- private static final String ICON = "Icon"; //$NON-NLS-1$
- private static final String AD = "AD"; //$NON-NLS-1$
- private static final String CARDINALITY = "cardinality"; //$NON-NLS-1$
- private static final String OPTION = "Option"; //$NON-NLS-1$
- private static final String LABEL = "label"; //$NON-NLS-1$
- private static final String VALUE = "value"; //$NON-NLS-1$
- private static final String MIN = "min"; //$NON-NLS-1$
- private static final String MAX = "max"; //$NON-NLS-1$
- private static final String TYPE = "type"; //$NON-NLS-1$
- private static final String SIZE = "size"; //$NON-NLS-1$
- private static final String ID = "id"; //$NON-NLS-1$
- private static final String NAME = "name"; //$NON-NLS-1$
- private static final String DESCRIPTION = "description"; //$NON-NLS-1$
- private static final String RESOURCE = "resource"; //$NON-NLS-1$
- private static final String PID = "pid"; //$NON-NLS-1$
- private static final String DEFAULT = "default"; //$NON-NLS-1$
- private static final String ADREF = "adref"; //$NON-NLS-1$
- private static final String CONTENT = "content"; //$NON-NLS-1$
- private static final String FACTORY = "factoryPid"; //$NON-NLS-1$
- private static final String BUNDLE = "bundle"; //$NON-NLS-1$
- private static final String OPTIONAL = "optional"; //$NON-NLS-1$
- private static final String OBJECT = "Object"; //$NON-NLS-1$
- private static final String OCDREF = "ocdref"; //$NON-NLS-1$
- private static final String ATTRIBUTE = "Attribute"; //$NON-NLS-1$
- private static final String DESIGNATE = "Designate"; //$NON-NLS-1$
- private static final String MERGE = "merge"; //$NON-NLS-1$
- private static final String REQUIRED = "required"; //$NON-NLS-1$
-
- private static final String INTEGER = "Integer"; //$NON-NLS-1$
- private static final String STRING = "String"; //$NON-NLS-1$
- private static final String FLOAT = "Float"; //$NON-NLS-1$
- private static final String DOUBLE = "Double"; //$NON-NLS-1$
- private static final String BYTE = "Byte"; //$NON-NLS-1$
- private static final String LONG = "Long"; //$NON-NLS-1$
- private static final String CHAR = "Char"; //$NON-NLS-1$
- private static final String BOOLEAN = "Boolean"; //$NON-NLS-1$
- private static final String SHORT = "Short"; //$NON-NLS-1$
-
- protected Bundle _dp_bundle;
- protected URL _dp_url;
- protected SAXParserFactory _dp_parserFactory;
- protected XMLReader _dp_xmlReader;
-
- // DesignateHanders in DataParser class
- Vector _dp_designateHandlers = new Vector(7);
- // ObjectClassDefinitions in DataParser class w/ corresponding reference keys
- Hashtable _dp_OCDs = new Hashtable(7);
- // pid to ObjectClassDefinitions in DataParser class as a Hashtable
- Hashtable _dp_pid_to_OCDs_ = new Hashtable(7);
- // Localization in DataParser class
- String _dp_localization;
-
- /*
- * Constructor of class DataParser.
- */
- public DataParser(Bundle bundle, URL url, SAXParserFactory parserFactory) {
-
- this._dp_bundle = bundle;
- this._dp_url = url;
- this._dp_parserFactory = parserFactory;
- parserFactory.setValidating(false);
- }
-
- /*
- * Main method to parse specific MetaData file.
- */
- public Hashtable doParse() {
-
- try {
- SAXParser saxParser = _dp_parserFactory.newSAXParser();
- _dp_xmlReader = saxParser.getXMLReader();
- _dp_xmlReader.setContentHandler(new RootHandler());
- _dp_xmlReader.setErrorHandler(new MyErrorHandler(System.err));
- InputStream is = _dp_url.openStream();
- InputSource isource = new InputSource(is);
- Logging.log(Logging.DEBUG, "Starting to parse " + _dp_url); //$NON-NLS-1$
- _dp_xmlReader.parse(isource);
- } catch (ParserConfigurationException pce) {
- pce.printStackTrace();
- return null;
- } catch (SAXException saxe) {
- saxe.printStackTrace();
- return null;
- } catch (IOException ioe) {
- ioe.printStackTrace();
- return null;
- }
- return _dp_pid_to_OCDs_;
- }
-
- /*
- * Convert String for expected data type.
- */
- static Object convert(String value, int type) {
-
- if (value == null) {
- return null;
- }
-
- switch (type) {
- case AttributeDefinition.STRING :
- // Both the min and max of STRING are Integers.
- return new Integer(value);
- case AttributeDefinition.LONG :
- return new Long(value);
- case AttributeDefinition.INTEGER :
- return new Integer(value);
- case AttributeDefinition.SHORT :
- return new Short(value);
- case AttributeDefinition.CHARACTER :
- return new Character(value.charAt(0));
- case AttributeDefinition.BYTE :
- return new Byte(value);
- case AttributeDefinition.DOUBLE :
- return new Double(value);
- case AttributeDefinition.FLOAT :
- return new Float(value);
- case AttributeDefinition.BIGINTEGER :
- try {
- Class bigIntClazz = Class.forName("java.math.BigInteger");//$NON-NLS-1$
- Constructor bigIntConstructor = bigIntClazz.getConstructor(new Class[] {String.class});
- return bigIntConstructor.newInstance(new Object[] {value});
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- return null;
- } catch (SecurityException e) {
- e.printStackTrace();
- return null;
- } catch (NoSuchMethodException e) {
- e.printStackTrace();
- return null;
- } catch (IllegalArgumentException e) {
- e.printStackTrace();
- return null;
- } catch (InstantiationException e) {
- e.printStackTrace();
- return null;
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- return null;
- } catch (InvocationTargetException e) {
- e.printStackTrace();
- return null;
- }
- case AttributeDefinition.BIGDECIMAL :
- try {
- Class bigDecimalClazz = Class.forName("java.math.BigDecimal");//$NON-NLS-1$
- Constructor bigDecimalConstructor = bigDecimalClazz.getConstructor(new Class[] {String.class});
- return bigDecimalConstructor.newInstance(new Object[] {value});
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- return null;
- } catch (SecurityException e) {
- e.printStackTrace();
- return null;
- } catch (NoSuchMethodException e) {
- e.printStackTrace();
- return null;
- } catch (IllegalArgumentException e) {
- e.printStackTrace();
- return null;
- } catch (InstantiationException e) {
- e.printStackTrace();
- return null;
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- return null;
- } catch (InvocationTargetException e) {
- e.printStackTrace();
- return null;
- }
- case AttributeDefinition.BOOLEAN :
- return new Boolean(value);
- default :
- // Unknown data type
- return null;
- }
- }
-
- /**
- * Abstract of all Handlers.
- */
- private class AbstractHandler extends DefaultHandler {
-
- protected ContentHandler _doc_handler;
- protected boolean _isParsedDataValid = true;
-
- public AbstractHandler(ContentHandler parentHandler) {
-
- this._doc_handler = parentHandler;
- _dp_xmlReader.setContentHandler(this);
- }
-
- public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
-
- throw new SAXException(NLS.bind(MetaTypeMsg.UNEXPECTED_ELEMENT, qName));
- }
-
- public void characters(char[] buf, int start, int end) throws SAXException {
-
- String s = new String(buf, start, end).trim();
- if (s.length() > 0) {
- throw new SAXException(NLS.bind(MetaTypeMsg.UNEXPECTED_TEXT, s));
- }
- }
-
- /**
- * Called when this element and all elements nested into it have been
- * handled.
- */
- protected void finished() throws SAXException {
- // do nothing by default
- }
-
- public void endElement(String namespaceURI, String localName, String qName) throws SAXException {
-
- finished();
- // Let parent resume handling SAX events
- _dp_xmlReader.setContentHandler(_doc_handler);
- }
- }
-
- /**
- * Handler for the root element.
- */
- private class RootHandler extends DefaultHandler {
-
- public RootHandler() {
- super();
- }
-
- public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
-
- Logging.log(Logging.TRACE, "Here is AbstractHandler:startElement():" //$NON-NLS-1$
- + qName);
- String name = getName(localName, qName);
- if (name.equalsIgnoreCase(METADATA)) {
- new MetaDataHandler(this).init(name, attributes);
- } else {
- Logging.log(Logging.WARN, NLS.bind(MetaTypeMsg.UNEXPECTED_ELEMENT, name));
- }
- }
-
- public void setDocumentLocator(Locator locator) {
- // do nothing
- }
- }
-
- /**
- * Handler for the MetaData element.
- */
- private class MetaDataHandler extends AbstractHandler {
-
- public MetaDataHandler(ContentHandler handler) {
- super(handler);
- }
-
- public void init(String name, Attributes attributes) throws SAXException {
-
- Logging.log(Logging.TRACE, "Here is MetaDataHandler():init()"); //$NON-NLS-1$
- _dp_localization = attributes.getValue(LOCALIZATION);
- if (_dp_localization == null) {
- // Not a problem, because LOCALIZATION is an optional attribute.
- }
- // The global variable "_dp_localization" will be used within
- // OcdHandler and AttributeDefinitionHandler later.
- }
-
- public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
-
- Logging.log(Logging.TRACE, "Here is MetaDataHandler:startElement():" //$NON-NLS-1$
- + qName);
- String name = getName(localName, qName);
- if (name.equalsIgnoreCase(DESIGNATE)) {
- DesignateHandler designateHandler = new DesignateHandler(this);
- designateHandler.init(name, atts);
- if (designateHandler._isParsedDataValid) {
- _dp_designateHandlers.addElement(designateHandler);
- }
- } else if (name.equalsIgnoreCase(OCD)) {
- OcdHandler ocdHandler = new OcdHandler(this);
- ocdHandler.init(name, atts, _dp_OCDs);
- } else {
- Logging.log(Logging.WARN, NLS.bind(MetaTypeMsg.UNEXPECTED_ELEMENT, name));
- }
- }
-
- protected void finished() throws SAXException {
-
- Logging.log(Logging.TRACE, "Here is MetaDataHandler():finished()"); //$NON-NLS-1$
- if (_dp_designateHandlers.size() == 0) {
- // Schema defines at least one DESIGNATE is required.
- _isParsedDataValid = false;
- Logging.log(Logging.ERROR, this, "finished()", //$NON-NLS-1$
- NLS.bind(MetaTypeMsg.MISSING_ELEMENT, DESIGNATE));
- return;
- }
- Enumeration designateHandlerKeys = _dp_designateHandlers.elements();
- while (designateHandlerKeys.hasMoreElements()) {
- DesignateHandler designateHandler = (DesignateHandler) designateHandlerKeys.nextElement();
-
- ObjectClassDefinitionImpl ocd = (ObjectClassDefinitionImpl) _dp_OCDs.get(designateHandler._ocdref);
- if (ocd != null) {
- if (designateHandler._factory_val == null) {
- ocd.setType(ObjectClassDefinitionImpl.PID);
- _dp_pid_to_OCDs_.put(designateHandler._pid_val,ocd);
- } else {
- ocd.setType(ObjectClassDefinitionImpl.FPID);
- _dp_pid_to_OCDs_.put(designateHandler._factory_val,ocd);
- }
- } else {
- Logging.log(Logging.ERROR, this, "finished()", //$NON-NLS-1$
- NLS.bind(MetaTypeMsg.OCD_ID_NOT_FOUND, designateHandler._ocdref));
- }
- }
- }
- }
-
- /**
- * Handler for the ObjectClassDefinition element.
- */
- private class OcdHandler extends AbstractHandler {
-
- Hashtable _parent_OCDs_hashtable;
- // This ID "_refID" is only used for reference by Designate element,
- // not the PID or FPID of this OCD.
- String _refID;
- ObjectClassDefinitionImpl _ocd;
- Vector _ad_vector = new Vector(7);
-
- public OcdHandler(ContentHandler handler) {
- super(handler);
- }
-
- public void init(String name, Attributes atts, Hashtable ocds_hashtable) throws SAXException {
-
- Logging.log(Logging.TRACE, "Here is OcdHandler():init()"); //$NON-NLS-1$
- _parent_OCDs_hashtable = ocds_hashtable;
-
- String ocd_name_val = atts.getValue(NAME);
- if (ocd_name_val == null) {
- _isParsedDataValid = false;
- Logging.log(Logging.ERROR, this, "init(String, Attributes, Hashtable)", //$NON-NLS-1$
- NLS.bind(MetaTypeMsg.MISSING_ATTRIBUTE, NAME, name));
- return;
- }
-
- String ocd_description_val = atts.getValue(DESCRIPTION);
- if (ocd_description_val == null) {
- // Not a problem, because DESCRIPTION is an optional attribute.
- }
-
- _refID = atts.getValue(ID);
- if (_refID == null) {
- _isParsedDataValid = false;
- Logging.log(Logging.ERROR, this, "init(String, Attributes, Hashtable)", //$NON-NLS-1$
- NLS.bind(MetaTypeMsg.MISSING_ATTRIBUTE, ID, name));
- return;
- }
-
- _ocd = new ObjectClassDefinitionImpl(ocd_name_val, ocd_description_val, _refID, _dp_localization);
- }
-
- public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
-
- Logging.log(Logging.TRACE, "Here is OcdHandler:startElement():" //$NON-NLS-1$
- + qName);
- if (!_isParsedDataValid)
- return;
-
- String name = getName(localName, qName);
- if (name.equalsIgnoreCase(AD)) {
- AttributeDefinitionHandler attributeDefHandler = new AttributeDefinitionHandler(this);
- attributeDefHandler.init(name, atts, _ad_vector);
- } else if (name.equalsIgnoreCase(ICON)) {
- IconHandler iconHandler = new IconHandler(this);
- iconHandler.init(name, atts);
- if (iconHandler._isParsedDataValid) {
- // Because XML schema allows at most one icon for
- // one OCD, if more than one icons are read from
- // MetaData, then only the final icon will be kept.
- _ocd.setIcon(iconHandler._icon);
- }
- } else {
- Logging.log(Logging.WARN, NLS.bind(MetaTypeMsg.UNEXPECTED_ELEMENT, name));
- }
- }
-
- protected void finished() throws SAXException {
-
- Logging.log(Logging.TRACE, "Here is OcdHandler():finished()"); //$NON-NLS-1$
- if (!_isParsedDataValid)
- return;
-
- if (_ad_vector.size() == 0) {
- // Schema defines at least one AD is required.
- _isParsedDataValid = false;
- Logging.log(Logging.ERROR, this, "finished()", //$NON-NLS-1$
- NLS.bind(MetaTypeMsg.MISSING_ELEMENT, AD, _refID));
- return;
- }
- // OCD gets all parsed ADs.
- Enumeration adKey = _ad_vector.elements();
- while (adKey.hasMoreElements()) {
- AttributeDefinitionImpl ad = (AttributeDefinitionImpl) adKey.nextElement();
- _ocd.addAttributeDefinition(ad, ad._isRequired);
- }
-
- _parent_OCDs_hashtable.put(_refID, _ocd);
- }
- }
-
- /**
- * Handler for the Icon element.
- */
- private class IconHandler extends AbstractHandler {
-
- Icon _icon;
-
- public IconHandler(ContentHandler handler) {
- super(handler);
- }
-
- public void init(String name, Attributes atts) throws SAXException {
-
- Logging.log(Logging.TRACE, "Here is IconHandler:init()"); //$NON-NLS-1$
- String icon_resource_val = atts.getValue(RESOURCE);
- if (icon_resource_val == null) {
- _isParsedDataValid = false;
- Logging.log(Logging.ERROR, this, "init(String, Attributes)", //$NON-NLS-1$
- NLS.bind(MetaTypeMsg.MISSING_ATTRIBUTE, RESOURCE, name));
- return;
- }
-
- String icon_size_val = atts.getValue(SIZE);
- if (icon_size_val == null) {
- // Not a problem, because SIZE is an optional attribute.
- icon_size_val = "0"; //$NON-NLS-1$
- } else if (icon_size_val.equalsIgnoreCase("")) { //$NON-NLS-1$
- icon_size_val = "0"; //$NON-NLS-1$
- }
-
- _icon = new Icon(icon_resource_val, Integer.parseInt(icon_size_val), _dp_bundle);
- }
- }
-
- /**
- * Handler for the Attribute element.
- */
- private class AttributeDefinitionHandler extends AbstractHandler {
-
- AttributeDefinitionImpl _ad;
- int _dataType;
-
- Vector _parent_ADs_vector;
- Vector _optionLabel_vector = new Vector(7);
- Vector _optionValue_vector = new Vector(7);
-
- public AttributeDefinitionHandler(ContentHandler handler) {
- super(handler);
- }
-
- public void init(String name, Attributes atts, Vector ad_vector) throws SAXException {
-
- Logging.log(Logging.TRACE, "Here is AttributeDefinitionHandler():init()"); //$NON-NLS-1$
- _parent_ADs_vector = ad_vector;
-
- String ad_name_val = atts.getValue(NAME);
- if (ad_name_val == null) {
- // Not a problem, because NAME is an optional attribute.
- }
-
- String ad_description_val = atts.getValue(DESCRIPTION);
- if (ad_description_val == null) {
- // Not a problem, because DESCRIPTION is an optional attribute.
- }
-
- String ad_id_val = atts.getValue(ID);
- if (ad_id_val == null) {
- _isParsedDataValid = false;
- Logging.log(Logging.ERROR, this, "init(String, Attributes, Vector)", //$NON-NLS-1$
- NLS.bind(MetaTypeMsg.MISSING_ATTRIBUTE, ID, name));
- return;
- }
-
- String ad_type_val = atts.getValue(TYPE);
- if (ad_type_val.equalsIgnoreCase(STRING)) {
- _dataType = AttributeDefinition.STRING;
- } else if (ad_type_val.equalsIgnoreCase(LONG)) {
- _dataType = AttributeDefinition.LONG;
- } else if (ad_type_val.equalsIgnoreCase(DOUBLE)) {
- _dataType = AttributeDefinition.DOUBLE;
- } else if (ad_type_val.equalsIgnoreCase(FLOAT)) {
- _dataType = AttributeDefinition.FLOAT;
- } else if (ad_type_val.equalsIgnoreCase(INTEGER)) {
- _dataType = AttributeDefinition.INTEGER;
- } else if (ad_type_val.equalsIgnoreCase(BYTE)) {
- _dataType = AttributeDefinition.BYTE;
- } else if (ad_type_val.equalsIgnoreCase(CHAR)) {
- _dataType = AttributeDefinition.CHARACTER;
- } else if (ad_type_val.equalsIgnoreCase(BOOLEAN)) {
- _dataType = AttributeDefinition.BOOLEAN;
- } else if (ad_type_val.equalsIgnoreCase(SHORT)) {
- _dataType = AttributeDefinition.SHORT;
- } else {
- _isParsedDataValid = false;
- Logging.log(Logging.ERROR, this, "init(String, Attributes, Vector)", //$NON-NLS-1$
- NLS.bind(MetaTypeMsg.MISSING_ATTRIBUTE, TYPE, name));
- return;
-
- }
-
- String ad_cardinality_str = atts.getValue(CARDINALITY);
- int ad_cardinality_val = 0;
- if (ad_cardinality_str == null) {
- // Not a problem, because CARDINALITY is an optional attribute.
- // And the default value is 0.
- } else {
- ad_cardinality_val = Integer.parseInt(ad_cardinality_str);
- }
-
- String ad_min_val = atts.getValue(MIN);
- if (ad_min_val == null) {
- // Not a problem, because MIN is an optional attribute.
- }
-
- String ad_max_val = atts.getValue(MAX);
- if (ad_max_val == null) {
- // Not a problem, because MAX is an optional attribute.
- }
-
- String ad_defaults_str = atts.getValue(DEFAULT);
- if (ad_defaults_str == null) {
- // Not a problem, because DEFAULT is an optional attribute.
- if (ad_cardinality_val == 0) {
- // But when it is not assigned, CARDINALITY cannot be '0'.
- _isParsedDataValid = false;
- Logging.log(Logging.ERROR, this, "init(String, Attributes, Vector)", //$NON-NLS-1$
- MetaTypeMsg.NULL_DEFAULTS);
- return;
- }
- }
-
- String ad_required_val = atts.getValue(REQUIRED);
- if (ad_required_val == null) {
- // Not a problem, because REQUIRED is an optional attribute.
- // And the default value is 'true'.
- ad_required_val = Boolean.TRUE.toString();
- }
-
- _ad = new AttributeDefinitionImpl(ad_id_val, ad_name_val, ad_description_val, _dataType, ad_cardinality_val, convert(ad_min_val, _dataType), convert(ad_max_val, _dataType), Boolean.valueOf(ad_required_val).booleanValue(), _dp_localization);
-
- if (ad_cardinality_val == 0) {
- // Attribute DEFAULT has one and only one occurance.
- _ad.setDefaultValue(new String[] {ad_defaults_str}, false);
- } else {
- // Attribute DEFAULT is a comma delimited list.
- _ad.setDefaultValue(ad_defaults_str, false);
- }
- }
-
- public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
-
- Logging.log(Logging.TRACE, "Here is AttributeDefinitionHandler:startElement():" //$NON-NLS-1$
- + qName);
- if (!_isParsedDataValid)
- return;
-
- String name = getName(localName, qName);
- if (name.equalsIgnoreCase(OPTION)) {
- OptionHandler optionHandler = new OptionHandler(this);
- optionHandler.init(name, atts);
- if (optionHandler._isParsedDataValid) {
- // Only add valid Option
- _optionLabel_vector.addElement(optionHandler._label_val);
- _optionValue_vector.addElement(optionHandler._value_val);
- }
- } else {
- Logging.log(Logging.WARN, NLS.bind(MetaTypeMsg.UNEXPECTED_ELEMENT, name));
- }
- }
-
- protected void finished() throws SAXException {
-
- Logging.log(Logging.TRACE, "Here is AttributeDefinitionHandler():finished()"); //$NON-NLS-1$
- if (!_isParsedDataValid)
- return;
-
- _ad.setOption(_optionLabel_vector, _optionValue_vector, true);
- _parent_ADs_vector.addElement(_ad);
- }
- }
-
- /**
- * Handler for the Option element.
- */
- private class OptionHandler extends AbstractHandler {
-
- String _label_val;
- String _value_val;
-
- public OptionHandler(ContentHandler handler) {
- super(handler);
- }
-
- public void init(String name, Attributes atts) throws SAXException {
-
- Logging.log(Logging.TRACE, "Here is OptionHandler:init()"); //$NON-NLS-1$
- _label_val = atts.getValue(LABEL);
- if (_label_val == null) {
- _isParsedDataValid = false;
- Logging.log(Logging.ERROR, this, "init(String, Attributes)", //$NON-NLS-1$
- NLS.bind(MetaTypeMsg.MISSING_ATTRIBUTE, LABEL, name));
- return;
- }
-
- _value_val = atts.getValue(VALUE);
- if (_value_val == null) {
- _isParsedDataValid = false;
- Logging.log(Logging.ERROR, this, "init(String, Attributes)", //$NON-NLS-1$
- NLS.bind(MetaTypeMsg.MISSING_ATTRIBUTE, VALUE, name));
- return;
- }
- }
- }
-
- // /**
- // * Handler for the Simple Value element.
- // */
- // private class SimpleValueHandler extends AbstractHandler {
- //
- // StringBuffer _buffer = new StringBuffer();
- // Vector _parent_value_vector;
- // String _elementName;
- //
- // public SimpleValueHandler(ContentHandler handler) {
- // super(handler);
- // }
- //
- // public void init(String name, Attributes atts, Vector value_vector)
- // throws SAXException {
- //
- // Logging.log(Logging.TRACE,
- // "Here is SimpleValueHandler():init()"); //$NON-NLS-1$
- // _elementName = name;
- // _parent_value_vector = value_vector;
- // }
- //
- // protected void finished() throws SAXException {
- //
- // Logging.log(Logging.TRACE,
- // "Here is SimpleValueHandler():finished()"); //$NON-NLS-1$
- // if (_parent_value_vector != null) {
- // _parent_value_vector.addElement(_buffer.toString());
- // }
- // }
- //
- // public void characters(char buf[], int offset, int len)
- // throws SAXException {
- //
- // Logging.log(Logging.TRACE,
- // "Here is SimpleValueHandler(" //$NON-NLS-1$
- // + _elementName
- // + "):characters():[" //$NON-NLS-1$
- // + new String(buf, offset, len)
- // + "]"); //$NON-NLS-1$
- // _buffer.append(new String(buf, offset, len));
- // }
- // }
-
- /**
- * Handler for the Designate element.
- */
- private class DesignateHandler extends AbstractHandler {
-
- String _pid_val = null;
- String _factory_val = null;
- String _bundle_val = null; // Only used by RFC94
- boolean _optional_val = false; // Only used by RFC94
- boolean _merge_val = false; // Only used by RFC94
-
- // Referenced OCD ID
- String _ocdref;
-
- public DesignateHandler(ContentHandler handler) {
- super(handler);
- }
-
- public void init(String name, Attributes atts) throws SAXException {
-
- Logging.log(Logging.TRACE, "Here is DesignateHandler():init()"); //$NON-NLS-1$
- _pid_val = atts.getValue(PID);
- if (_pid_val == null) {
- _isParsedDataValid = false;
- Logging.log(Logging.ERROR, this, "init(String, Attributes)", //$NON-NLS-1$
- NLS.bind(MetaTypeMsg.MISSING_ATTRIBUTE, PID, name));
- return;
- }
- _factory_val = atts.getValue(FACTORY);
-
- _bundle_val = atts.getValue(BUNDLE);
- if (_bundle_val == null) {
- // Not a problem because BUNDLE is an optional attribute.
- }
-
- String optional_str = atts.getValue(OPTIONAL);
- if (optional_str == null) {
- // Not a problem, because OPTIONAL is an optional attribute.
- // The default value is "false".
- _optional_val = false;
- } else {
- _optional_val = Boolean.valueOf(optional_str).booleanValue();
- }
-
- String merge_str = atts.getValue(MERGE);
- if (merge_str == null) {
- // Not a problem, because MERGE is an optional attribute.
- // The default value is "false".
- _merge_val = false;
- } else {
- _merge_val = Boolean.valueOf(merge_str).booleanValue();
- }
- }
-
- public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
-
- Logging.log(Logging.TRACE, "Here is DesignateHandler:startElement():" //$NON-NLS-1$
- + qName);
- if (!_isParsedDataValid)
- return;
-
- String name = getName(localName, qName);
- if (name.equalsIgnoreCase(OBJECT)) {
- ObjectHandler objectHandler = new ObjectHandler(this);
- objectHandler.init(name, atts);
- if (objectHandler._isParsedDataValid) {
- _ocdref = objectHandler._ocdref;
- }
- } else {
- Logging.log(Logging.WARN, NLS.bind(MetaTypeMsg.UNEXPECTED_ELEMENT, name));
- }
- }
-
- protected void finished() throws SAXException {
-
- Logging.log(Logging.TRACE, "Here is DesignateHandler():finished()"); //$NON-NLS-1$
- if (!_isParsedDataValid)
- return;
-
- if (_ocdref == null) {
- _isParsedDataValid = false;
- // Schema defines at least one OBJECT is required.
- Logging.log(Logging.ERROR, this, "finished()", //$NON-NLS-1$
- NLS.bind(MetaTypeMsg.MISSING_ELEMENT, OBJECT, _pid_val));
- return;
-
- }
- }
- }
-
- /**
- * Handler for the Object element.
- */
- private class ObjectHandler extends AbstractHandler {
-
- String _ocdref;
-
- public ObjectHandler(ContentHandler handler) {
- super(handler);
- }
-
- public void init(String name, Attributes atts) throws SAXException {
-
- Logging.log(Logging.TRACE, "Here is ObjectHandler():init()"); //$NON-NLS-1$
- _ocdref = atts.getValue(OCDREF);
- if (_ocdref == null) {
- _isParsedDataValid = false;
- Logging.log(Logging.ERROR, this, "init(String, Attributes)", //$NON-NLS-1$
- NLS.bind(MetaTypeMsg.MISSING_ATTRIBUTE, OCDREF, name));
- return;
- }
- }
-
- public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
-
- Logging.log(Logging.TRACE, "Here is ObjectHandler:startElement():" //$NON-NLS-1$
- + qName);
- if (!_isParsedDataValid)
- return;
-
- String name = getName(localName, qName);
- if (name.equalsIgnoreCase(ATTRIBUTE)) {
- AttributeHandler attributeHandler = new AttributeHandler(this);
- attributeHandler.init(name, atts);
- // The ATTRIBUTE element is only used by RFC94, do nothing for it here.
- } else {
- Logging.log(Logging.WARN, NLS.bind(MetaTypeMsg.UNEXPECTED_ELEMENT, name));
- }
- }
- }
-
- /**
- * Handler for the Attribute element.
- *
- * This Handler is only used by RFC94.
- */
- private class AttributeHandler extends AbstractHandler {
-
- String _adref_val;
- String _content_val;
-
- public AttributeHandler(ContentHandler handler) {
- super(handler);
- }
-
- public void init(String name, Attributes atts) throws SAXException {
-
- Logging.log(Logging.TRACE, "Here is AttributeHandler():init()"); //$NON-NLS-1$
- _adref_val = atts.getValue(ADREF);
- if (_adref_val == null) {
- _isParsedDataValid = false;
- Logging.log(Logging.ERROR, this, "init(String, Attributes)", //$NON-NLS-1$
- NLS.bind(MetaTypeMsg.MISSING_ATTRIBUTE, ADREF, name));
- return;
- }
-
- _content_val = atts.getValue(CONTENT);
- if (_content_val == null) {
- _isParsedDataValid = false;
- Logging.log(Logging.ERROR, this, "init(String, Attributes)", //$NON-NLS-1$
- NLS.bind(MetaTypeMsg.MISSING_ATTRIBUTE, CONTENT, name));
- return;
- }
- }
- }
-
- /**
- * Error Handler to report errors and warnings
- */
- private static class MyErrorHandler implements ErrorHandler {
-
- /** Error handler output goes here */
- private PrintStream _out;
-
- MyErrorHandler(PrintStream out) {
- this._out = out;
- }
-
- /**
- * Returns a string describing parse exception details
- */
- private String getParseExceptionInfo(SAXParseException spe) {
- String systemId = spe.getSystemId();
- if (systemId == null) {
- systemId = "null"; //$NON-NLS-1$
- }
- String info = "URI=" + systemId + //$NON-NLS-1$
- " Line=" + spe.getLineNumber() + //$NON-NLS-1$
- ": " + spe.getMessage(); //$NON-NLS-1$
-
- return info;
- }
-
- // The following methods are standard SAX ErrorHandler methods.
- // See SAX documentation for more info.
-
- public void warning(SAXParseException spe) throws SAXException {
- _out.println("Warning: " + getParseExceptionInfo(spe)); //$NON-NLS-1$
- }
-
- public void error(SAXParseException spe) throws SAXException {
- String message = "Error: " + getParseExceptionInfo(spe); //$NON-NLS-1$
- throw new SAXException(message);
- }
-
- public void fatalError(SAXParseException spe) throws SAXException {
- String message = "Fatal Error: " + getParseExceptionInfo(spe); //$NON-NLS-1$
- throw new SAXException(message);
- }
- }
-
- public static String getName(String localName, String qName) {
- if (localName != null && localName.length() > 0) {
- return localName;
- }
-
- int nameSpaceIndex = qName.indexOf(":"); //$NON-NLS-1$
- return nameSpaceIndex == -1 ? qName : qName.substring(nameSpaceIndex + 1);
- }
-}
diff --git a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/ExternalMessages.properties b/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/ExternalMessages.properties
deleted file mode 100644
index 9bcf92592..000000000
--- a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/ExternalMessages.properties
+++ /dev/null
@@ -1,33 +0,0 @@
-###############################################################################
-# Copyright (c) 2005 IBM Corporation.
-# 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:
-# IBM Corporation - initial API and implementation
-###############################################################################
-#External Messages for EN locale
-SERVICE_DESCRIPTION=OSGi Metatype Service - IBM Implementation
-
-UNEXPECTED_ELEMENT=Unexpected element {0}.
-UNEXPECTED_TEXT=Unexpected text {0}.
-MISSING_ATTRIBUTE=Missing attribute {0} in tag {1}.
-OCD_ID_NOT_FOUND=Object Class Definition ID not found {0}.
-NULL_DEFAULTS=Default value cannot be null when cardinality is zero.
-MISSING_ELEMENT=Missing element {0} (Reference ID = {1}.
-
-EXCEPTION_MESSAGE=Unexpected exception {0} with message {1}.
-NULL_IS_INVALID=Cannot validate a null.
-VALUE_OUT_OF_RANGE=Value {0} is out of range.
-VALUE_OUT_OF_OPTION=Value {0} is out of Option.
-TOO_MANY_VALUES=Found too many values in {0} when expecting {1} values.
-NULL_OPTIONS=Cannot set Option labels or values as null.
-INCONSISTENT_OPTIONS=Labels and Values of Option have different sizes.
-INVALID_OPTIONS=Option value {0} is invalid because of {1}.
-INVALID_DEFAULTS=Dafaults value {0} is invalid because of {1}.
-
-METADATA_NOT_FOUND=Bundle(ID=\"{0}\", name=\"{1}\") has no MetaData file.
-ASK_INVALID_LOCALE=OCD(ID=\"{0}\") cannot support this locale \"{1}\".
-TOKENIZER_GOT_INVALID_DATA=The Tokenizer got invalid data. \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/FragmentUtils.java b/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/FragmentUtils.java
deleted file mode 100644
index 10c464e53..000000000
--- a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/FragmentUtils.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.metatype;
-
-import java.net.URL;
-import java.util.*;
-import org.osgi.framework.Bundle;
-import org.osgi.service.packageadmin.PackageAdmin;
-
-/*
- * Fragment Utilities
- */
-public class FragmentUtils {
- static PackageAdmin packageAdmin;
-
- /*
- *
- */
- public static boolean isFragment(Bundle bundle) {
-
- if (packageAdmin == null)
- return false;
- return (packageAdmin.getBundleType(bundle) & PackageAdmin.BUNDLE_TYPE_FRAGMENT) != 0;
- }
-
- /*
- * Find all the paths to entries for the bundle and its fragments.
- * Returned data is got by Bundle.getEntryPaths().
- */
- public static Enumeration findEntryPaths(Bundle bundle, String path) {
-
- Bundle[] fragments = packageAdmin == null ? null : packageAdmin.getFragments(bundle);
- Vector result = new Vector();
- addEntryPaths(bundle.getEntryPaths(path), result);
- if (fragments != null) {
- for (int i = 0; i < fragments.length; i++)
- addEntryPaths(fragments[i].getEntryPaths(path), result);
- }
- return result.size() == 0 ? null : result.elements();
- }
-
- /*
- * Internal method - add an path to vector, and check for duplucate.
- */
- private static void addEntryPaths(Enumeration ePaths, Vector pathList) {
-
- if (ePaths == null)
- return;
- while (ePaths.hasMoreElements()) {
- Object path = ePaths.nextElement();
- if (!pathList.contains(path))
- pathList.add(path);
- }
- }
-
- /*
- * Find all the URLs to entries for the bundle and its fragments.
- * Returned data is got by Bundle.getEntry().
- */
- public static URL[] findEntries(Bundle bundle, String path) {
-
- Bundle[] fragments = packageAdmin == null ? null : packageAdmin.getFragments(bundle);
- URL url = bundle.getEntry(path);
- if (fragments == null || fragments.length == 0)
- return url == null ? null : new URL[] {url};
- ArrayList result = new ArrayList();
- if (url != null)
- result.add(url);
-
- for (int i = 0; i < fragments.length; i++) {
- URL fragUrl = fragments[i].getEntry(path);
- if (fragUrl != null)
- result.add(fragUrl);
- }
- return result.size() == 0 ? null : (URL[]) result.toArray(new URL[result.size()]);
- }
-}
diff --git a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/Icon.java b/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/Icon.java
deleted file mode 100644
index 8817f8c1e..000000000
--- a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/Icon.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.metatype;
-
-import org.osgi.framework.Bundle;
-
-/**
- * Represents an Icon with a name and a size
- */
-class Icon implements Cloneable {
-
- private String _fileName;
- private int _size;
- private Bundle _bundle;
-
- /**
- * Constructor of class Icon.
- */
- public Icon(String fileName, int size, Bundle bundle) {
-
- this._fileName = fileName;
- this._size = size;
- this._bundle = bundle;
- }
-
- /**
- * Constructor of class Icon.
- */
- public Icon(String fileName, Bundle bundle) {
-
- // Integer.MIN_VALUE signifies size was not specified
- this(fileName, Integer.MIN_VALUE, bundle);
- }
-
- /*
- *
- */
- public synchronized Object clone() {
- return new Icon(this._fileName, this._size, this._bundle);
- }
-
- /**
- * Method to get the icon's file name.
- */
- String getIconName() {
- return _fileName;
- }
-
- /**
- * returns the size specified when the icon was created
- *
- * @return size or Integer.MIN_VALUE if no size was specified
- */
- int getIconSize() {
- return _size;
- }
-
- /**
- * Method to get the bundle having this Icon.
- */
- Bundle getIconBundle() {
- return _bundle;
- }
-}
diff --git a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/LocalizationElement.java b/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/LocalizationElement.java
deleted file mode 100644
index 8ee9ef0b7..000000000
--- a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/LocalizationElement.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.metatype;
-
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-public class LocalizationElement {
-
- public static final char KEY_SIGN = '%';
- String _localization = null;
- ResourceBundle _rb;
-
- /**
- * Internal method
- */
- void setResourceBundle(ResourceBundle rb) {
- this._rb = rb;
- }
-
- /**
- * Method to get the localized text of inputed String.
- */
- String getLocalized(String key) {
-
- if (key == null) {
- return null;
- }
-
- if ((key.charAt(0) == KEY_SIGN) && (key.length() > 1)) {
- if (_rb != null) {
- try {
- String transfered = _rb.getString(key.substring(1));
- if (transfered != null) {
- return transfered;
- }
- } catch (MissingResourceException mre) {
- // Nothing found for this key.
- }
- }
- // If no localization file available or no localized value found
- // for the key, then return the raw data without the key-sign.
- return key.substring(1);
- }
- return key;
- }
-}
diff --git a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/Logging.java b/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/Logging.java
deleted file mode 100644
index 48d136f4e..000000000
--- a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/Logging.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.metatype;
-
-import java.io.PrintStream;
-
-/**
- * Temporary Logging class
- */
-public class Logging {
-
- public static final int TRACE = 0;
- public static final int DEBUG = 1;
- public static final int WARN = 2;
- public static final int ERROR = 3;
-
- private static int _logging_level = WARN;
- private static PrintStream out = System.out;
-
- /*
- *
- */
- public static void log(int type, String message) {
- log(type, null, null, message);
- }
-
- /*
- * Main method to print log message
- */
- public static void log(int type, Object obj, String method, String message) {
-
- if (type >= _logging_level) {
-
- switch (type) {
- case TRACE :
- out.println("[Trace log]"); //$NON-NLS-1$
- break;
- case DEBUG :
- out.println("[Debug log]"); //$NON-NLS-1$
- break;
- case WARN :
- out.println("[Warning log]"); //$NON-NLS-1$
- break;
- default :
- out.println("[Error log]"); //$NON-NLS-1$
- }
-
- if (obj != null) {
- out.println("\tObject: " + obj.getClass().getName()); //$NON-NLS-1$
- }
- if (method != null) {
- out.println("\tMethod: " + method); //$NON-NLS-1$
- }
- out.println("\tMessage: " + message); //$NON-NLS-1$
- }
- }
-
- /*
- *
- */
- public static void debug(String message) {
-
- log(DEBUG, null, null, message);
- }
-}
diff --git a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/MetaTypeInformationImpl.java b/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/MetaTypeInformationImpl.java
deleted file mode 100644
index aef834ad2..000000000
--- a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/MetaTypeInformationImpl.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.metatype;
-
-import java.util.Enumeration;
-import java.util.Vector;
-import javax.xml.parsers.SAXParserFactory;
-import org.osgi.framework.Bundle;
-import org.osgi.service.metatype.MetaTypeInformation;
-
-/**
- * Implementation of MetaTypeProvider
- * <p>
- * Extension of MetaTypeProvider
- * <p>
- * Provides methods to:
- * <p> - getPids() get the Pids for a given Locale
- * <p> - getFactoryPids() get the Factory Pids for a given Locale
- * <p>
- */
-public class MetaTypeInformationImpl extends MetaTypeProviderImpl implements MetaTypeInformation {
-
- /**
- * Constructor of class MetaTypeInformationImpl.
- */
- MetaTypeInformationImpl(Bundle bundle, SAXParserFactory parserFactory) throws java.io.IOException {
- super(bundle, parserFactory);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.osgi.service.metatype.MetaTypeInformation#getPids()
- */
- public String[] getPids() {
-
- if (_allPidOCDs.size() == 0) {
- return new String[0];
- }
-
- Vector pids = new Vector(7);
- Enumeration e = _allPidOCDs.keys();
- while (e.hasMoreElements()) {
- pids.addElement(e.nextElement());
- }
-
- String[] retvalue = new String[pids.size()];
- pids.toArray(retvalue);
- return retvalue;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.osgi.service.metatype.MetaTypeInformation#getFactoryPids()
- */
- public String[] getFactoryPids() {
- if (_allFPidOCDs.size() == 0) {
- return new String[0];
- }
- Vector fpids = new Vector(7);
- Enumeration e = _allFPidOCDs.keys();
- while (e.hasMoreElements()) {
- fpids.addElement(e.nextElement());
- }
- String[] retvalue = new String[fpids.size()];
- fpids.toArray(retvalue);
- return retvalue;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.osgi.service.metatype.MetaTypeInformation#getBundle()
- */
- public Bundle getBundle() {
- return this._bundle;
- }
-}
diff --git a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/MetaTypeMsg.java b/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/MetaTypeMsg.java
deleted file mode 100644
index b3ffee63a..000000000
--- a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/MetaTypeMsg.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.metatype;
-
-import org.eclipse.osgi.util.NLS;
-
-public class MetaTypeMsg extends NLS {
- private static final String BUNDLE_NAME = "org.eclipse.equinox.metatype.ExternalMessages"; //$NON-NLS-1$
-
- public static String SERVICE_DESCRIPTION;
-
- public static String UNEXPECTED_ELEMENT;
- public static String UNEXPECTED_TEXT;
- public static String MISSING_ATTRIBUTE;
- public static String OCD_ID_NOT_FOUND;
- public static String NULL_DEFAULTS;
- public static String MISSING_ELEMENT;
-
- public static String EXCEPTION_MESSAGE;
- public static String NULL_IS_INVALID;
- public static String VALUE_OUT_OF_RANGE;
- public static String VALUE_OUT_OF_OPTION;
- public static String TOO_MANY_VALUES;
- public static String NULL_OPTIONS;
- public static String INCONSISTENT_OPTIONS;
- public static String INVALID_OPTIONS;
- public static String INVALID_DEFAULTS;
-
- public static String METADATA_NOT_FOUND;
- public static String ASK_INVALID_LOCALE;
- public static String TOKENIZER_GOT_INVALID_DATA;
-
- static {
- // initialize resource bundles
- NLS.initializeMessages(BUNDLE_NAME, MetaTypeMsg.class);
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/MetaTypeProviderImpl.java b/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/MetaTypeProviderImpl.java
deleted file mode 100644
index 16141707d..000000000
--- a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/MetaTypeProviderImpl.java
+++ /dev/null
@@ -1,240 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.metatype;
-
-import java.io.IOException;
-import java.util.*;
-import javax.xml.parsers.SAXParserFactory;
-import org.eclipse.osgi.util.NLS;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.Constants;
-import org.osgi.service.metatype.*;
-
-/**
- * Implementation of MetaTypeProvider
- */
-public class MetaTypeProviderImpl implements MetaTypeProvider {
-
- public static final String METADATA_NOT_FOUND = "METADATA_NOT_FOUND"; //$NON-NLS-1$
- public static final String OCD_ID_NOT_FOUND = "OCD_ID_NOT_FOUND"; //$NON-NLS-1$
- public static final String ASK_INVALID_LOCALE = "ASK_INVALID_LOCALE"; //$NON-NLS-1$
-
- public static final String META_FILE_EXT = ".XML"; //$NON-NLS-1$
- public static final String RESOURCE_FILE_CONN = "_"; //$NON-NLS-1$
- public static final String RESOURCE_FILE_EXT = ".properties"; //$NON-NLS-1$
- public static final char DIRECTORY_SEP = '/';
-
- Bundle _bundle;
-
- Hashtable _allPidOCDs = new Hashtable(7);
- Hashtable _allFPidOCDs = new Hashtable(7);
-
- String[] _locales;
- boolean _isThereMeta = false;
-
- /**
- * Constructor of class MetaTypeProviderImpl.
- */
- MetaTypeProviderImpl(Bundle bundle, SAXParserFactory parserFactory) throws IOException {
-
- this._bundle = bundle;
-
- // read all bundle's metadata files and build internal data structures
- _isThereMeta = readMetaFiles(bundle, parserFactory);
-
- if (!_isThereMeta) {
- Logging.log(Logging.WARN, NLS.bind(MetaTypeMsg.METADATA_NOT_FOUND, new Long(bundle.getBundleId()), bundle.getSymbolicName()));
- }
- }
-
- /**
- * This method should do the following:
- * <p> - Obtain a SAX parser from the XML Parser Service:
- * <p>
- *
- * <pre> </pre>
- *
- * The parser may be SAX 1 (eXML) or SAX 2 (XML4J). It should attempt to use
- * a SAX2 parser by instantiating an XMLReader and extending DefaultHandler
- * BUT if that fails it should fall back to instantiating a SAX1 Parser and
- * extending HandlerBase.
- * <p> - Pass the parser the URL for the bundle's METADATA.XML file
- * <p> - Handle the callbacks from the parser and build the appropriate
- * MetaType objects - ObjectClassDefinitions & AttributeDefinitions
- *
- * @param bundle The bundle object for which the metadata should be read
- * @param parserFactory The bundle object for which the metadata should be
- * read
- * @return void
- * @throws IOException If there are errors accessing the metadata.xml file
- */
- private boolean readMetaFiles(Bundle bundle, SAXParserFactory parserFactory) throws IOException {
-
- boolean isThereMetaHere = false;
-
- Enumeration allFileKeys = FragmentUtils.findEntryPaths(bundle, MetaTypeService.METATYPE_DOCUMENTS_LOCATION);
- if (allFileKeys == null)
- return isThereMetaHere;
-
- while (allFileKeys.hasMoreElements()) {
- boolean _isMetaDataFile;
- String fileName = (String) allFileKeys.nextElement();
-
- Hashtable pidToOCD = null;
- java.net.URL[] urls = FragmentUtils.findEntries(bundle, fileName);
- if (urls != null) {
- for (int i = 0; i < urls.length; i++) {
- try {
- // Assume all XML files are what we want by default.
- _isMetaDataFile = true;
- DataParser parser = new DataParser(bundle, urls[i], parserFactory);
- pidToOCD = parser.doParse();
- if (pidToOCD == null) {
- _isMetaDataFile = false;
- }
- } catch (Exception e) {
- // Ok, looks like it is not what we want.
- _isMetaDataFile = false;
- }
-
- if ((_isMetaDataFile) && (pidToOCD != null)) {
-
- // We got some OCDs now.
- Enumeration pids = pidToOCD.keys();
- while (pids.hasMoreElements()) {
- String pid = (String)pids.nextElement();
- ObjectClassDefinitionImpl ocd = (ObjectClassDefinitionImpl) pidToOCD.get(pid);
-
- if (ocd.getType() == ObjectClassDefinitionImpl.PID) {
- isThereMetaHere = true;
- _allPidOCDs.put(pid, ocd);
- } else {
- isThereMetaHere = true;
- _allFPidOCDs.put(pid, ocd);
- }
- } // End of for
- }
- }
- } // End of if(urls!=null)
- } // End of while
-
- return isThereMetaHere;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.osgi.service.metatype.MetaTypeProvider#getObjectClassDefinition(java.lang.String,
- * java.lang.String)
- */
- public ObjectClassDefinition getObjectClassDefinition(String pid, String locale) {
-
- if (isInvalidLocale(locale)) {
- throw new IllegalArgumentException(NLS.bind(MetaTypeMsg.ASK_INVALID_LOCALE, pid, locale));
- }
-
- ObjectClassDefinitionImpl ocd;
- if (_allPidOCDs.containsKey(pid)) {
- ocd = (ObjectClassDefinitionImpl) ((ObjectClassDefinitionImpl) _allPidOCDs.get(pid)).clone();
- ocd.setResourceBundle(locale, _bundle);
- return ocd;
- } else if (_allFPidOCDs.containsKey(pid)) {
- ocd = (ObjectClassDefinitionImpl) ((ObjectClassDefinitionImpl) _allFPidOCDs.get(pid)).clone();
- ocd.setResourceBundle(locale, _bundle);
- return ocd;
- } else {
- throw new IllegalArgumentException(NLS.bind(MetaTypeMsg.OCD_ID_NOT_FOUND, pid));
- }
- }
-
- /**
- * Internal Method - Check if the locale is invalid.
- */
- public boolean isInvalidLocale(String locale) {
-
- // Just a simple and quick check here.
- if (locale == null || locale.length() == 0)
- return false;
-
- int idx_first = locale.indexOf(ObjectClassDefinitionImpl.LOCALE_SEP);
- int idx_second = locale.lastIndexOf(ObjectClassDefinitionImpl.LOCALE_SEP);
- if (idx_first == -1 && locale.length() == 2)
- // It is format of only language.
- return false;
- if ((idx_first == 2) && (idx_second == 5 || idx_second == 2))
- // It is format of language + "_" + country [ + "_" + variation ].
- return false;
- return true;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.osgi.service.metatype.MetaTypeProvider#getLocales()
- */
- public synchronized String[] getLocales() {
-
- if (_locales != null)
- return checkForDefault(_locales);
-
- Vector localizationFiles = new Vector(7);
- // get all the localization resources for PIDS
- Enumeration ocds = _allPidOCDs.elements();
- while (ocds.hasMoreElements()) {
- ObjectClassDefinitionImpl ocd = (ObjectClassDefinitionImpl) ocds.nextElement();
- if (ocd._localization != null && !localizationFiles.contains(ocd._localization))
- localizationFiles.add(ocd._localization);
- }
- // get all the localization resources for FPIDS
- ocds = _allFPidOCDs.elements();
- while (ocds.hasMoreElements()) {
- ObjectClassDefinitionImpl ocd = (ObjectClassDefinitionImpl) ocds.nextElement();
- if (ocd._localization != null && !localizationFiles.contains(ocd._localization))
- localizationFiles.add(ocd._localization);
- }
- if (localizationFiles.size() == 0)
- localizationFiles.add(Constants.BUNDLE_LOCALIZATION_DEFAULT_BASENAME);
- Vector locales = new Vector(7);
- Enumeration eLocalizationFiles = localizationFiles.elements();
- while (eLocalizationFiles.hasMoreElements()) {
- String localizationFile = (String) eLocalizationFiles.nextElement();
- int iSlash = localizationFile.lastIndexOf(DIRECTORY_SEP);
- String baseDir;
- String baseFileName;
- if (iSlash < 0) {
- baseDir = ""; //$NON-NLS-1$
- } else {
- baseDir = localizationFile.substring(0, iSlash);
- }
- baseFileName = localizationFile + RESOURCE_FILE_CONN;
- Enumeration resources = FragmentUtils.findEntryPaths(this._bundle, baseDir);
- if (resources != null) {
- while (resources.hasMoreElements()) {
- String resource = (String) resources.nextElement();
- if (resource.startsWith(baseFileName) && resource.toLowerCase().endsWith(RESOURCE_FILE_EXT))
- locales.add(resource.substring(baseFileName.length(), resource.length() - RESOURCE_FILE_EXT.length()));
- }
- }
- }
- _locales = (String[]) locales.toArray(new String[locales.size()]);
- return checkForDefault(_locales);
- }
-
- /**
- * Internal Method - checkForDefault
- */
- private String[] checkForDefault(String[] locales) {
-
- if (locales == null || locales.length == 0 || (locales.length == 1 && Locale.getDefault().toString().equals(locales[0])))
- return null;
- return locales;
- }
-}
diff --git a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/MetaTypeProviderTracker.java b/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/MetaTypeProviderTracker.java
deleted file mode 100644
index 8a05d8864..000000000
--- a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/MetaTypeProviderTracker.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.metatype;
-
-import java.util.ArrayList;
-import org.osgi.framework.*;
-import org.osgi.service.cm.ManagedServiceFactory;
-import org.osgi.service.metatype.*;
-import org.osgi.util.tracker.ServiceTracker;
-
-public class MetaTypeProviderTracker implements MetaTypeInformation {
- public static final String MANAGED_SERVICE = "org.osgi.service.cm.ManagedService"; //$NON-NLS-1$
- public static final String MANAGED_SERVICE_FACTORY = "org.osgi.service.cm.ManagedServiceFactory"; //$NON-NLS-1$
- public static final String FILTER_STRING = "(|(" + Constants.OBJECTCLASS + '=' + MANAGED_SERVICE + ")(" + Constants.OBJECTCLASS + '=' + MANAGED_SERVICE_FACTORY + "))"; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
-
- Bundle _bundle;
- BundleContext _context;
- ServiceTracker _tracker;
-
- /**
- * Constructs a MetaTypeProviderTracker which tracks all MetaTypeProviders
- * registered by the specified bundle.
- * @param context The BundleContext of the MetaTypeService implementation
- * @param bundle The bundle to track all MetaTypeProviders for.
- */
- public MetaTypeProviderTracker(BundleContext context, Bundle bundle) {
- this._context = context;
- this._bundle = bundle;
- // create a filter for ManagedService and ManagedServiceFactory services
- try {
- Filter filter = context.createFilter(FILTER_STRING);
- // create a service tracker and open it.
- this._tracker = new ServiceTracker(context, filter, null);
- // we never close this, but it is no big deal because we
- // really want to track the services until we are stopped
- // at that point the framework will remove our listeners.
- this._tracker.open();
- } catch (InvalidSyntaxException e) {
- // This should never happen; it means we have a bug in the filterString
- e.printStackTrace();
- throw new IllegalArgumentException(FILTER_STRING);
- }
- }
-
- private String[] getPids(boolean factory) {
- if (_bundle.getState() != Bundle.ACTIVE)
- return new String[0]; // return none if not active
- MetaTypeProviderWrapper[] wrappers = getMetaTypeProviders();
- ArrayList results = new ArrayList();
- for (int i = 0; i < wrappers.length; i++) {
- // return only the correct type of pids (regular or factory)
- if (factory == wrappers[i].factory)
- results.add(wrappers[i].pid);
- }
- return (String[]) results.toArray(new String[results.size()]);
- }
-
- public String[] getPids() {
- return getPids(false);
- }
-
- public String[] getFactoryPids() {
- return getPids(true);
- }
-
- public Bundle getBundle() {
- return _bundle;
- }
-
- public ObjectClassDefinition getObjectClassDefinition(String id, String locale) {
- if (_bundle.getState() != Bundle.ACTIVE)
- return null; // return none if not active
- MetaTypeProviderWrapper[] wrappers = getMetaTypeProviders();
- for (int i = 0; i < wrappers.length; i++) {
- if (id.equals(wrappers[i].pid))
- // found a matching pid now call the actual provider
- return wrappers[i].provider.getObjectClassDefinition(id, locale);
- }
- return null;
- }
-
- public String[] getLocales() {
- if (_bundle.getState() != Bundle.ACTIVE)
- return new String[0]; // return none if not active
- MetaTypeProviderWrapper[] wrappers = getMetaTypeProviders();
- ArrayList locales = new ArrayList();
- // collect all the unique locales from all providers we found
- for (int i = 0; i < wrappers.length; i++) {
- String[] wrappedLocales = wrappers[i].provider.getLocales();
- if (wrappedLocales == null)
- continue;
- for (int j = 0; j < wrappedLocales.length; j++)
- if (!locales.contains(wrappedLocales[j]))
- locales.add(wrappedLocales[j]);
- }
- return (String[]) locales.toArray(new String[locales.size()]);
- }
-
- private MetaTypeProviderWrapper[] getMetaTypeProviders() {
- ServiceReference[] refs = _tracker.getServiceReferences();
- if (refs == null)
- return new MetaTypeProviderWrapper[0];
- ArrayList results = new ArrayList();
- for (int i = 0; i < refs.length; i++)
- // search for services registered by the bundle
- if (refs[i].getBundle() == _bundle) {
- Object service = _context.getService(refs[i]);
- if (service instanceof MetaTypeProvider) {
- // found one that implements MetaTypeProvider
- // wrap its information in a MetaTypeProviderWrapper
- String pid = (String) refs[i].getProperty(Constants.SERVICE_PID);
- boolean factory = service instanceof ManagedServiceFactory;
- results.add(new MetaTypeProviderWrapper((MetaTypeProvider) service, pid, factory));
- }
- // always unget a service.
- // this leaves us open for the the service going away but who cares.
- // we only use the service for a short period of time.
- _context.ungetService(refs[i]);
- }
- return (MetaTypeProviderWrapper[]) results.toArray(new MetaTypeProviderWrapper[results.size()]);
- }
-
- // this is a simple class just used to temporarily store information about a provider
- public class MetaTypeProviderWrapper {
- MetaTypeProvider provider;
- String pid;
- boolean factory;
-
- MetaTypeProviderWrapper(MetaTypeProvider provider, String pid, boolean factory) {
- this.provider = provider;
- this.pid = pid;
- this.factory = factory;
- }
- }
-}
diff --git a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/MetaTypeServiceImpl.java b/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/MetaTypeServiceImpl.java
deleted file mode 100644
index 619a2204b..000000000
--- a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/MetaTypeServiceImpl.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.metatype;
-
-import java.io.IOException;
-import java.security.*;
-import java.util.Hashtable;
-import javax.xml.parsers.SAXParserFactory;
-import org.osgi.framework.*;
-import org.osgi.service.metatype.MetaTypeInformation;
-import org.osgi.service.metatype.MetaTypeService;
-
-/**
- * Implementation of MetaTypeService
- */
-public class MetaTypeServiceImpl implements MetaTypeService, SynchronousBundleListener {
-
- BundleContext _context;
- SAXParserFactory _parserFactory;
- private Hashtable _mtps = new Hashtable(7);
-
- /**
- * Constructor of class MetaTypeServiceImpl.
- */
- public MetaTypeServiceImpl(BundleContext context, SAXParserFactory parserFactory) {
- this._context = context;
- this._parserFactory = parserFactory;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.osgi.service.metatype.MetaTypeService#getMetaTypeInformation(org.osgi.framework.Bundle)
- */
- public MetaTypeInformation getMetaTypeInformation(Bundle bundle) {
-
- MetaTypeInformation mti;
- try {
- mti = getMetaTypeProvider(bundle);
- } catch (IOException e) {
- Logging.log(Logging.ERROR, "IOException in MetaTypeInformation:getMetaTypeInformation(Bundle bundle)"); //$NON-NLS-1$
- e.printStackTrace();
- mti = null;
- }
- return mti;
- }
-
- /**
- * Internal Method - to get MetaTypeProvider object.
- */
- private MetaTypeInformation getMetaTypeProvider(final Bundle b) throws java.io.IOException {
-
- try {
- Long bID = new Long(b.getBundleId());
- synchronized (_mtps) {
- if (_mtps.containsKey(bID))
- return (MetaTypeInformation) _mtps.get(bID);
-
- MetaTypeInformation mti = (MetaTypeInformation) AccessController.doPrivileged(new PrivilegedExceptionAction() {
- public Object run() throws IOException {
- MetaTypeInformationImpl impl = new MetaTypeInformationImpl(b, _parserFactory);
- if (!impl._isThereMeta)
- return new MetaTypeProviderTracker(_context, b);
- return impl;
- }
- });
- _mtps.put(bID, mti);
- return mti;
- }
- } catch (PrivilegedActionException pae) {
- throw (IOException) pae.getException();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.osgi.framework.BundleListener#bundleChanged(org.osgi.framework.BundleEvent)
- */
- public void bundleChanged(BundleEvent event) {
-
- int type = event.getType();
- Long bID = new Long(event.getBundle().getBundleId());
-
- switch (type) {
- case BundleEvent.UPDATED :
- case BundleEvent.UNINSTALLED :
- _mtps.remove(bID);
- break;
- case BundleEvent.INSTALLED :
- case BundleEvent.RESOLVED :
- case BundleEvent.STARTED :
- case BundleEvent.STOPPED :
- case BundleEvent.UNRESOLVED :
- default :
- break;
- }
- }
-}
diff --git a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/ObjectClassDefinitionImpl.java b/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/ObjectClassDefinitionImpl.java
deleted file mode 100644
index a0d6a1c6f..000000000
--- a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/ObjectClassDefinitionImpl.java
+++ /dev/null
@@ -1,323 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.metatype;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.*;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.Constants;
-import org.osgi.service.metatype.AttributeDefinition;
-import org.osgi.service.metatype.ObjectClassDefinition;
-
-/**
- * Implementation of ObjectClassDefinition
- */
-public class ObjectClassDefinitionImpl extends LocalizationElement implements ObjectClassDefinition, Cloneable {
-
- public static final int PID = 0;
- public static final int FPID = 1;
- public static final char LOCALE_SEP = '_';
-
- String _name;
- String _id;
- String _description;
-
- int _type;
- Vector _required = new Vector(7);
- Vector _optional = new Vector(7);
- Icon _icon;
-
- /*
- * Constructor of class ObjectClassDefinitionImpl.
- */
- public ObjectClassDefinitionImpl(String name, String description, String id, String localization) {
-
- this._name = name;
- this._description = description;
- this._id = id;
- this._localization = localization;
- }
-
- /*
- * Constructor of class ObjectClassDefinitionImpl.
- */
- public ObjectClassDefinitionImpl(String name, String description, String id, int type, String localization) {
-
- this._name = name;
- this._id = id;
- this._description = description;
- this._type = type;
- this._localization = localization;
- }
-
- /*
- *
- */
- public synchronized Object clone() {
-
- ObjectClassDefinitionImpl ocd = new ObjectClassDefinitionImpl(_name, _description, _id, _type, _localization);
- for (int i = 0; i < _required.size(); i++) {
- AttributeDefinitionImpl ad = (AttributeDefinitionImpl) _required.elementAt(i);
- ocd.addAttributeDefinition((AttributeDefinitionImpl) ad.clone(), true);
- }
- for (int i = 0; i < _optional.size(); i++) {
- AttributeDefinitionImpl ad = (AttributeDefinitionImpl) _optional.elementAt(i);
- ocd.addAttributeDefinition((AttributeDefinitionImpl) ad.clone(), false);
- }
- if (_icon != null) {
- ocd.setIcon((Icon) _icon.clone());
- }
- return ocd;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.osgi.service.metatype.ObjectClassDefinition#getName()
- */
- public String getName() {
- return getLocalized(_name);
- }
-
- /**
- * Method to set the name of ObjectClassDefinition.
- */
- void setName(String name) {
- this._name = name;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.osgi.service.metatype.ObjectClassDefinition#getID()
- */
- public String getID() {
- return _id;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.osgi.service.metatype.ObjectClassDefinition#getDescription()
- */
- public String getDescription() {
- return getLocalized(_description);
- }
-
- /*
- * Method to set the description of ObjectClassDefinition.
- */
- void setDescription(String description) {
- this._description = description;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.osgi.service.metatype.ObjectClassDefinition#getAttributeDefinitions(int)
- */
- public AttributeDefinition[] getAttributeDefinitions(int filter) {
-
- AttributeDefinition[] atts;
- switch (filter) {
- case REQUIRED :
- atts = new AttributeDefinition[_required.size()];
- _required.toArray(atts);
- return atts;
- case OPTIONAL :
- atts = new AttributeDefinition[_optional.size()];
- _optional.toArray(atts);
- return atts;
- case ALL :
- default :
- atts = new AttributeDefinition[_required.size() + _optional.size()];
- Enumeration e = _required.elements();
- int i = 0;
- while (e.hasMoreElements()) {
- atts[i] = (AttributeDefinition) e.nextElement();
- i++;
- }
- e = _optional.elements();
- while (e.hasMoreElements()) {
- atts[i] = (AttributeDefinition) e.nextElement();
- i++;
- }
- return atts;
- }
- }
-
- /*
- * Method to add one new AD to ObjectClassDefinition.
- */
- public void addAttributeDefinition(AttributeDefinition ad, boolean isRequired) {
-
- if (isRequired) {
- _required.addElement(ad);
- } else {
- _optional.addElement(ad);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.osgi.service.metatype.ObjectClassDefinition#getIcon(int)
- */
- public InputStream getIcon(int sizeHint) throws IOException {
-
- if ((_icon == null) || (_icon.getIconSize() != sizeHint)) {
- return null;
- }
- Bundle b = _icon.getIconBundle();
- URL[] urls = FragmentUtils.findEntries(b, getLocalized(_icon.getIconName()));
- if (urls != null && urls.length > 0) {
- return urls[0].openStream();
- }
- return null;
- }
-
- /**
- * Method to set the icon of ObjectClassDefinition.
- */
- public void setIcon(Icon icon) {
- this._icon = icon;
- }
-
- /**
- * Method to get the type of ObjectClassDefinition.
- */
- int getType() {
- return _type;
- }
-
- /**
- * Method to set the type of ObjectClassDefinition.
- */
- void setType(int type) {
- this._type = type;
- }
-
- /**
- * Method to set the resource bundle for this OCD and all its ADs.
- */
- void setResourceBundle(String assignedLocale, Bundle bundle) {
-
- _rb = getResourceBundle(assignedLocale, bundle);
-
- Enumeration allADReqs = _required.elements();
- while (allADReqs.hasMoreElements()) {
- AttributeDefinitionImpl ad = (AttributeDefinitionImpl) allADReqs.nextElement();
- ad.setResourceBundle(_rb);
- }
-
- Enumeration allADOpts = _optional.elements();
- while (allADOpts.hasMoreElements()) {
- AttributeDefinitionImpl ad = (AttributeDefinitionImpl) allADOpts.nextElement();
- ad.setResourceBundle(_rb);
- }
- }
-
- /*
- * Internal Method - to get resource bundle.
- */
- private ResourceBundle getResourceBundle(String locale, final Bundle bundle) {
-
- String resourceBase = (_localization == null ? Constants.BUNDLE_LOCALIZATION_DEFAULT_BASENAME : _localization);
-
- // There are seven searching candidates possible:
- // baseName +
- // "_" + language1 + "_" + country1 + "_" + variation1 + ".properties"
- // or "_" + language1 + "_" + country1 + ".properties"
- // or "_" + language1 + ".properties"
- // or "_" + language2 + "_" + country2 + "_" + variation2 + ".properties"
- // or "_" + language2 + "_" + country2 + ".properties"
- // or "_" + language2 + ".properties"
- // or "" + ".properties"
- //
- // Where language1[_country1[_variation1]] is the requested locale,
- // and language2[_country2[_variation2]] is the default locale.
-
- String[] searchCandidates = new String[7];
-
- // Candidates from passed locale:
- if (locale != null && locale.length() > 0) {
- int idx1_first = locale.indexOf(LOCALE_SEP);
- if (idx1_first == -1) {
- // locale has only language.
- searchCandidates[2] = MetaTypeProviderImpl.RESOURCE_FILE_CONN + locale;
- } else {
- // locale has at least language and country.
- searchCandidates[2] = MetaTypeProviderImpl.RESOURCE_FILE_CONN + locale.substring(0, idx1_first);
- int idx1_second = locale.indexOf(LOCALE_SEP, idx1_first + 1);
- if (idx1_second == -1) {
- // locale just has both language and country.
- searchCandidates[1] = MetaTypeProviderImpl.RESOURCE_FILE_CONN + locale;
- } else {
- // locale has language, country, and variation all.
- searchCandidates[1] = MetaTypeProviderImpl.RESOURCE_FILE_CONN + locale.substring(0, idx1_second);
- searchCandidates[0] = MetaTypeProviderImpl.RESOURCE_FILE_CONN + locale;
- }
- }
- }
-
- // Candidates from Locale.getDefault():
- String defaultLocale = Locale.getDefault().toString();
- int idx2_first = defaultLocale.indexOf(LOCALE_SEP);
- int idx2_second = defaultLocale.indexOf(LOCALE_SEP, idx2_first + 1);
- if (idx2_second != -1) {
- // default-locale is format of [language]_[country]_variation.
- searchCandidates[3] = MetaTypeProviderImpl.RESOURCE_FILE_CONN + defaultLocale;
- if (searchCandidates[3].equalsIgnoreCase(searchCandidates[0])) {
- searchCandidates[3] = null;
- }
- }
- if ((idx2_first != -1) && (idx2_second != idx2_first + 1)) {
- // default-locale is format of [language]_country[_variation].
- searchCandidates[4] = MetaTypeProviderImpl.RESOURCE_FILE_CONN + ((idx2_second == -1) ? defaultLocale : defaultLocale.substring(0, idx2_second));
- if (searchCandidates[4].equalsIgnoreCase(searchCandidates[1])) {
- searchCandidates[4] = null;
- }
- }
- if ((idx2_first == -1) && (defaultLocale.length() > 0)) {
- // default-locale has only language.
- searchCandidates[5] = MetaTypeProviderImpl.RESOURCE_FILE_CONN + defaultLocale;
- } else if (idx2_first > 0) {
- // default-locale is format of language_[...].
- searchCandidates[5] = MetaTypeProviderImpl.RESOURCE_FILE_CONN + defaultLocale.substring(0, idx2_first);
- }
- if (searchCandidates[5] != null && searchCandidates[5].equalsIgnoreCase(searchCandidates[2])) {
- searchCandidates[5] = null;
- }
-
- // The final candidate.
- searchCandidates[6] = ""; //$NON-NLS-1$
-
- URL resourceUrl = null;
- URL[] urls = null;
-
- for (int idx = 0; (idx < searchCandidates.length) && (resourceUrl == null); idx++) {
- urls = (searchCandidates[idx] == null ? null : FragmentUtils.findEntries(bundle, resourceBase + searchCandidates[idx] + MetaTypeProviderImpl.RESOURCE_FILE_EXT));
- if (urls != null && urls.length > 0)
- resourceUrl = urls[0];
- }
-
- if (resourceUrl != null) {
- try {
- return new PropertyResourceBundle(resourceUrl.openStream());
- } catch (IOException ioe) {
- // Exception when creating PropertyResourceBundle object.
- }
- }
- return null;
- }
-}
diff --git a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/ValueTokenizer.java b/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/ValueTokenizer.java
deleted file mode 100644
index 4320d3ce4..000000000
--- a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/ValueTokenizer.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.metatype;
-
-import java.util.Vector;
-
-public class ValueTokenizer {
-
- private static final char SEPARATE = ',';
- private static final char CONTROL = '\\';
-
- Vector _value_vector = new Vector(7);
-
- /*
- * Constructor of class ValueTokenizer
- */
- public ValueTokenizer(String values_str) {
-
- if (values_str != null) {
-
- StringBuffer buffer = new StringBuffer(""); //$NON-NLS-1$
- for (int i = 0; i < values_str.length(); i++) {
- if (values_str.charAt(i) == CONTROL) {
- if (i + 1 < values_str.length()) {
- buffer.append(values_str.charAt(++i));
- continue;
- }
- // CONTROL char should not occur in last char.
- Logging.log(Logging.ERROR, this, "ValueTokenizer(String)", //$NON-NLS-1$
- MetaTypeMsg.TOKENIZER_GOT_INVALID_DATA);
- // It's an invalid char, but since it's the last one,
- // just ignore it.
- continue;
- }
- if (values_str.charAt(i) == SEPARATE) {
- _value_vector.addElement(buffer.toString().trim());
- buffer = new StringBuffer(""); //$NON-NLS-1$
- continue;
- }
- buffer.append(values_str.charAt(i));
- }
- // Don't forget the final one.
- _value_vector.addElement(buffer.toString().trim());
- }
- }
-
- /*
- * Method to return values as Vector.
- */
- public Vector getValuesAsVector() {
- return _value_vector;
- }
-
- /*
- * Method to return values as String[] or null.
- */
- public String[] getValuesAsArray() {
-
- String[] value_array = null;
- if ((_value_vector != null) && (_value_vector.size() != 0)) {
-
- value_array = new String[_value_vector.size()];
- _value_vector.toArray(value_array);
- }
-
- return value_array;
- }
-}
diff --git a/bundles/org.eclipse.equinox.preferences/.classpath b/bundles/org.eclipse.equinox.preferences/.classpath
deleted file mode 100644
index 751c8f2e5..000000000
--- a/bundles/org.eclipse.equinox.preferences/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/bundles/org.eclipse.equinox.preferences/.cvsignore b/bundles/org.eclipse.equinox.preferences/.cvsignore
deleted file mode 100644
index ba077a403..000000000
--- a/bundles/org.eclipse.equinox.preferences/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
diff --git a/bundles/org.eclipse.equinox.preferences/.options b/bundles/org.eclipse.equinox.preferences/.options
deleted file mode 100644
index c676c7c7d..000000000
--- a/bundles/org.eclipse.equinox.preferences/.options
+++ /dev/null
@@ -1,6 +0,0 @@
-# Debugging options for the org.eclipse.equinox.preferences plugin
-
-# Turn on debugging for preferences
-org.eclipse.equinox.preferences/general=false
-org.eclipse.equinox.preferences/get=false
-org.eclipse.equinox.preferences/set=false
diff --git a/bundles/org.eclipse.equinox.preferences/.project b/bundles/org.eclipse.equinox.preferences/.project
deleted file mode 100644
index 0ccb37523..000000000
--- a/bundles/org.eclipse.equinox.preferences/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.equinox.preferences</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/bundles/org.eclipse.equinox.preferences/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.preferences/META-INF/MANIFEST.MF
deleted file mode 100644
index d76c44640..000000000
--- a/bundles/org.eclipse.equinox.preferences/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,15 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %pluginName
-Bundle-SymbolicName: org.eclipse.equinox.preferences; singleton:=true
-Bundle-Version: 1.0.0.qualifier
-Bundle-Activator: org.eclipse.core.internal.preferences.Activator
-Bundle-Vendor: %providerName
-Bundle-Localization: plugin
-Require-Bundle: org.eclipse.equinox.common,
- system.bundle,
- org.eclipse.equinox.registry
-Export-Package: org.eclipse.core.internal.preferences;x-friends:="org.eclipse.core.resources,org.eclipse.core.runtime",
- org.eclipse.core.runtime.preferences,
- org.osgi.service.prefs;version="1.1"
-Eclipse-LazyStart: true
diff --git a/bundles/org.eclipse.equinox.preferences/about.html b/bundles/org.eclipse.equinox.preferences/about.html
deleted file mode 100644
index bd87495af..000000000
--- a/bundles/org.eclipse.equinox.preferences/about.html
+++ /dev/null
@@ -1,60 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<html>
-<head>
-<title>About</title>
-<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-</head>
-<body lang="EN-US">
-<h2>About This Content</h2>
-
-<p>September 26, 2005</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" target="_blank">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.</p>
-
-<h3>Third Party Content</h3>
-
-<p>The Content includes items that have been sourced from third parties as follows:</p>
-
-<p><b>OSGi Materials</b></p>
-
-<p>All files in the following sub-directories (and their sub-directories):</p>
-
-<ul>
- <li>org/osgi</li>
-</ul>
-
-<p>shall be defined as the &quot;OSGi Materials.&quot; The OSGi Materials are:</p>
-
-<blockquote>
-Copyright (c) 2000, 2005
-<br /><br />
-OSGi Alliance
-Bishop Ranch 6<br/>
-2400 Camino Ramon, Suite 375<br/>
-San Ramon, CA 94583 USA
-<br /><br />
-All Rights Reserved.
-</blockquote>
-
-<p>The OSGi Materials are provided to you under the terms and conditions of the
-Eclipse Public License Version 1.0 (&quot;EPL&quot;). For purposes of the EPL, &quot;Program&quot; will mean the OSGi Materials.</p>
-
-<p>Implementation of certain elements of the OSGi Materials may be subject to third party intellectual property rights, including without limitation, patent rights (such a third party may
-or may not be a member of the OSGi Alliance). The OSGi Alliance and its members are not responsible and shall not be held responsible in any manner for identifying or failing to identify any or all such third party
-intellectual property rights.</p>
-
-<small>OSGi&trade; is a trademark, registered trademark, or service mark of The OSGi Alliance in the US and other countries. Java is a trademark,
-registered trademark, or service mark of Sun Microsystems, Inc. in the US and other countries. All other trademarks, registered trademarks, or
-service marks used in the Content are the property of their respective owners and are hereby recognized.</small>
-
-<small>Java and all Java-based trademarks and logos are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries.</small>
-
-</body>
-</html>
diff --git a/bundles/org.eclipse.equinox.preferences/build.properties b/bundles/org.eclipse.equinox.preferences/build.properties
deleted file mode 100644
index b3000cca0..000000000
--- a/bundles/org.eclipse.equinox.preferences/build.properties
+++ /dev/null
@@ -1,19 +0,0 @@
-###############################################################################
-# Copyright (c) 2005 IBM Corporation 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:
-# IBM Corporation - initial API and implementation
-###############################################################################
-source.. = src/
-output.. = bin/
-bin.includes = META-INF/,\
- .,\
- plugin.xml,\
- plugin.properties,\
- .options,\
- about.html
-src.includes = about.html
diff --git a/bundles/org.eclipse.equinox.preferences/plugin.properties b/bundles/org.eclipse.equinox.preferences/plugin.properties
deleted file mode 100644
index 85acdaaf3..000000000
--- a/bundles/org.eclipse.equinox.preferences/plugin.properties
+++ /dev/null
@@ -1,14 +0,0 @@
-###############################################################################
-# Copyright (c) 2005 IBM Corporation 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:
-# IBM Corporation - initial API and implementation
-###############################################################################
-pluginName = Eclipse Preferences Mechanism
-providerName = Eclipse.org
-preferencesExtPtName = Platform Preferences
-preferencesName=Preferences
diff --git a/bundles/org.eclipse.equinox.preferences/plugin.xml b/bundles/org.eclipse.equinox.preferences/plugin.xml
deleted file mode 100644
index cfaffa88a..000000000
--- a/bundles/org.eclipse.equinox.preferences/plugin.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.0"?>
-<plugin>
- <extension-point id="preferences" name="%preferencesName" schema="schema/preferences.exsd"/>
-
- <extension id="org.eclipse.core.runtime.platform-preferences" point="org.eclipse.equinox.preferences.preferences" name="%preferencesExtPtName">
- <scope name="configuration" class="org.eclipse.core.internal.preferences.ConfigurationPreferences"/>
- <scope name="instance" class="org.eclipse.core.internal.preferences.InstancePreferences"/>
- <scope name="default" class="org.eclipse.core.internal.preferences.DefaultPreferences"/>
- </extension>
-</plugin>
diff --git a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/AbstractScope.java b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/AbstractScope.java
deleted file mode 100644
index 6ffebd06d..000000000
--- a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/AbstractScope.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.preferences;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.core.runtime.preferences.IScopeContext;
-
-/**
- * Abstract super-class for scope context object contributed
- * by the Platform.
- *
- * @since 3.0
- */
-public abstract class AbstractScope implements IScopeContext {
-
- /*
- * @see org.eclipse.core.runtime.preferences.IScopeContext#getName()
- */
- public abstract String getName();
-
- /*
- * Default path hierarchy for nodes is /<scope>/<qualifier>.
- *
- * @see org.eclipse.core.runtime.preferences.IScopeContext#getNode(java.lang.String)
- */
- public IEclipsePreferences getNode(String qualifier) {
- if (qualifier == null)
- throw new IllegalArgumentException();
- return (IEclipsePreferences) PreferencesService.getDefault().getRootNode().node(getName()).node(qualifier);
- }
-
- /*
- * @see org.eclipse.core.runtime.preferences.IScopeContext#getLocation()
- */
- public abstract IPath getLocation();
-
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (!(obj instanceof IScopeContext))
- return false;
- IScopeContext other = (IScopeContext) obj;
- if (!getName().equals(other.getName()))
- return false;
- IPath location = getLocation();
- return location == null ? other.getLocation() == null : location.equals(other.getLocation());
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- public int hashCode() {
- return getName().hashCode();
- }
-}
diff --git a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/Activator.java b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/Activator.java
deleted file mode 100644
index e18dd154f..000000000
--- a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/Activator.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.preferences;
-
-import java.util.Hashtable;
-
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.preferences.IPreferencesService;
-import org.eclipse.osgi.service.environment.EnvironmentInfo;
-import org.osgi.framework.*;
-import org.osgi.util.tracker.ServiceTracker;
-import org.osgi.util.tracker.ServiceTrackerCustomizer;
-
-/**
- * The Jobs plugin class.
- */
-public class Activator implements BundleActivator, ServiceTrackerCustomizer {
-
- private static final String OSGI_PREFERENCES_SERVICE = "org.osgi.service.prefs.PreferencesService"; //$NON-NLS-1$
-
- /**
- * Track the registry service - only register preference service if the registry is
- * available
- */
- private ServiceTracker registryServiceTracker;
-
- /**
- * The bundle associated this plug-in
- */
- private static BundleContext bundleContext;
-
- /**
- * This plugin provides a Preferences service.
- */
- private ServiceRegistration preferencesService = null;
-
- /**
- * This plugin provides the OSGi Preferences service.
- */
- private ServiceRegistration osgiPreferencesService;
-
- /**
- * This method is called upon plug-in activation
- */
- public void start(BundleContext context) throws Exception {
- bundleContext = context;
- processCommandLine();
- PreferencesOSGiUtils.getDefault().openServices();
- registryServiceTracker = new ServiceTracker(context, IExtensionRegistry.class.getName(), this);
- registryServiceTracker.open();
- }
-
- /**
- * This method is called when the plug-in is stopped
- */
- public void stop(BundleContext context) throws Exception {
- registryServiceTracker.close(); //unregisters services
- registryServiceTracker = null;
- PreferencesOSGiUtils.getDefault().closeServices();
- bundleContext = null;
- }
-
- static BundleContext getContext() {
- return bundleContext;
- }
-
- private void registerServices() {
- preferencesService = bundleContext.registerService(IPreferencesService.class.getName(), PreferencesService.getDefault(), new Hashtable());
- osgiPreferencesService = bundleContext.registerService(OSGI_PREFERENCES_SERVICE, new OSGiPreferencesServiceManager(bundleContext), null);
- }
-
- public synchronized Object addingService(ServiceReference reference) {
- if (preferencesService == null) {
- registerServices();
- //return the registry service so we track it
- return bundleContext.getService(reference);
- }
- return null;
- }
-
- public void modifiedService(ServiceReference reference, Object service) {
- }
-
- public synchronized void removedService(ServiceReference reference, Object service) {
- if (preferencesService != null) {
- preferencesService.unregister();
- preferencesService = null;
- }
- if (osgiPreferencesService != null) {
- osgiPreferencesService.unregister();
- osgiPreferencesService = null;
- }
- }
-
- /**
- * Look for the plug-in customization file.
- * @param args - command line arguments
- */
- private void processCommandLine() {
- ServiceTracker environmentTracker = new ServiceTracker(bundleContext, EnvironmentInfo.class.getName(), null);
- environmentTracker.open();
- EnvironmentInfo environmentInfo = (EnvironmentInfo) environmentTracker.getService();
- environmentTracker.close();
- if (environmentInfo == null)
- return;
- String[] args = environmentInfo.getNonFrameworkArgs();
- if (args == null || args.length == 0)
- return;
-
- for (int i = 0; i < args.length; i++) {
- if (args[i].equalsIgnoreCase(IPreferencesConstants.PLUGIN_CUSTOMIZATION)) {
- if (args.length > i + 1) // make sure the file name is actually there
- DefaultPreferences.pluginCustomizationFile = args[i + 1];
- break; // only interested in this one
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/Base64.java b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/Base64.java
deleted file mode 100644
index de8518445..000000000
--- a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/Base64.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.preferences;
-
-public class Base64 {
-
- private static final byte equalSign = (byte) '=';
-
- static char digits[] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', //
- 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', //
- 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', //
- 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'};
-
- /**
- * This method decodes the byte array in base 64 encoding into a char array
- * Base 64 encoding has to be according to the specification given by the
- * RFC 1521 (5.2).
- *
- * @param data the encoded byte array
- * @return the decoded byte array
- */
- public static byte[] decode(byte[] data) {
- if (data.length == 0)
- return data;
- int lastRealDataIndex = data.length - 1;
- while (data[lastRealDataIndex] == equalSign)
- lastRealDataIndex--;
- // original data digit is 8 bits long, but base64 digit is 6 bits long
- int padBytes = data.length - 1 - lastRealDataIndex;
- int byteLength = data.length * 6 / 8 - padBytes;
- byte[] result = new byte[byteLength];
- // Each 4 bytes of input (encoded) we end up with 3 bytes of output
- int dataIndex = 0;
- int resultIndex = 0;
- int allBits = 0;
- // how many result chunks we can process before getting to pad bytes
- int resultChunks = (lastRealDataIndex + 1) / 4;
- for (int i = 0; i < resultChunks; i++) {
- allBits = 0;
- // Loop 4 times gathering input bits (4 * 6 = 24)
- for (int j = 0; j < 4; j++)
- allBits = (allBits << 6) | decodeDigit(data[dataIndex++]);
- // Loop 3 times generating output bits (3 * 8 = 24)
- for (int j = resultIndex + 2; j >= resultIndex; j--) {
- result[j] = (byte) (allBits & 0xff); // Bottom 8 bits
- allBits = allBits >>> 8;
- }
- resultIndex += 3; // processed 3 result bytes
- }
- // Now we do the extra bytes in case the original (non-encoded) data
- // was not multiple of 3 bytes
- switch (padBytes) {
- case 1 :
- // 1 pad byte means 3 (4-1) extra Base64 bytes of input, 18
- // bits, of which only 16 are meaningful
- // Or: 2 bytes of result data
- allBits = 0;
- // Loop 3 times gathering input bits
- for (int j = 0; j < 3; j++)
- allBits = (allBits << 6) | decodeDigit(data[dataIndex++]);
- // NOTE - The code below ends up being equivalent to allBits =
- // allBits>>>2
- // But we code it in a non-optimized way for clarity
- // The 4th, missing 6 bits are all 0
- allBits = allBits << 6;
- // The 3rd, missing 8 bits are all 0
- allBits = allBits >>> 8;
- // Loop 2 times generating output bits
- for (int j = resultIndex + 1; j >= resultIndex; j--) {
- result[j] = (byte) (allBits & 0xff); // Bottom 8
- // bits
- allBits = allBits >>> 8;
- }
- break;
- case 2 :
- // 2 pad bytes mean 2 (4-2) extra Base64 bytes of input, 12 bits
- // of data, of which only 8 are meaningful
- // Or: 1 byte of result data
- allBits = 0;
- // Loop 2 times gathering input bits
- for (int j = 0; j < 2; j++)
- allBits = (allBits << 6) | decodeDigit(data[dataIndex++]);
- // NOTE - The code below ends up being equivalent to allBits =
- // allBits>>>4
- // But we code it in a non-optimized way for clarity
- // The 3rd and 4th, missing 6 bits are all 0
- allBits = allBits << 6;
- allBits = allBits << 6;
- // The 3rd and 4th, missing 8 bits are all 0
- allBits = allBits >>> 8;
- allBits = allBits >>> 8;
- result[resultIndex] = (byte) (allBits & 0xff); // Bottom
- // 8
- // bits
- break;
- }
- return result;
- }
-
- /**
- * This method converts a Base 64 digit to its numeric value.
- *
- * @param data digit (character) to convert
- * @return value for the digit
- */
- static int decodeDigit(byte data) {
- char charData = (char) data;
- if (charData <= 'Z' && charData >= 'A')
- return charData - 'A';
- if (charData <= 'z' && charData >= 'a')
- return charData - 'a' + 26;
- if (charData <= '9' && charData >= '0')
- return charData - '0' + 52;
- switch (charData) {
- case '+' :
- return 62;
- case '/' :
- return 63;
- default :
- throw new IllegalArgumentException("Invalid char to decode: " + data); //$NON-NLS-1$
- }
- }
-
- /**
- * This method encodes the byte array into a char array in base 64 according
- * to the specification given by the RFC 1521 (5.2).
- *
- * @param data the encoded char array
- * @return the byte array that needs to be encoded
- */
- public static byte[] encode(byte[] data) {
- int sourceChunks = data.length / 3;
- int len = ((data.length + 2) / 3) * 4;
- byte[] result = new byte[len];
- int extraBytes = data.length - (sourceChunks * 3);
- // Each 4 bytes of input (encoded) we end up with 3 bytes of output
- int dataIndex = 0;
- int resultIndex = 0;
- int allBits = 0;
- for (int i = 0; i < sourceChunks; i++) {
- allBits = 0;
- // Loop 3 times gathering input bits (3 * 8 = 24)
- for (int j = 0; j < 3; j++)
- allBits = (allBits << 8) | (data[dataIndex++] & 0xff);
- // Loop 4 times generating output bits (4 * 6 = 24)
- for (int j = resultIndex + 3; j >= resultIndex; j--) {
- result[j] = (byte) digits[(allBits & 0x3f)]; // Bottom
- // 6
- // bits
- allBits = allBits >>> 6;
- }
- resultIndex += 4; // processed 4 result bytes
- }
- // Now we do the extra bytes in case the original (non-encoded) data
- // is not multiple of 4 bytes
- switch (extraBytes) {
- case 1 :
- allBits = data[dataIndex++]; // actual byte
- allBits = allBits << 8; // 8 bits of zeroes
- allBits = allBits << 8; // 8 bits of zeroes
- // Loop 4 times generating output bits (4 * 6 = 24)
- for (int j = resultIndex + 3; j >= resultIndex; j--) {
- result[j] = (byte) digits[(allBits & 0x3f)]; // Bottom
- // 6
- // bits
- allBits = allBits >>> 6;
- }
- // 2 pad tags
- result[result.length - 1] = (byte) '=';
- result[result.length - 2] = (byte) '=';
- break;
- case 2 :
- allBits = data[dataIndex++]; // actual byte
- allBits = (allBits << 8) | (data[dataIndex++] & 0xff); // actual
- // byte
- allBits = allBits << 8; // 8 bits of zeroes
- // Loop 4 times generating output bits (4 * 6 = 24)
- for (int j = resultIndex + 3; j >= resultIndex; j--) {
- result[j] = (byte) digits[(allBits & 0x3f)]; // Bottom
- // 6
- // bits
- allBits = allBits >>> 6;
- }
- // 1 pad tag
- result[result.length - 1] = (byte) '=';
- break;
- }
- return result;
- }
-}
diff --git a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/ConfigurationPreferences.java b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/ConfigurationPreferences.java
deleted file mode 100644
index 72e1426cc..000000000
--- a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/ConfigurationPreferences.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.preferences;
-
-import java.net.URL;
-import java.util.HashSet;
-import java.util.Set;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-
-/**
- * @since 3.0
- */
-public class ConfigurationPreferences extends EclipsePreferences {
-
- // cached values
- private int segmentCount;
- private String qualifier;
- private IPath location;
- private IEclipsePreferences loadLevel;
- // cache which nodes have been loaded from disk
- private static Set loadedNodes = new HashSet();
- private static boolean initialized = false;
- private static IPath baseLocation;
-
- static {
- URL url = PreferencesOSGiUtils.getDefault().getConfigurationLocation().getURL();
- if (url != null)
- baseLocation = new Path(url.getFile());
- }
-
- /**
- * Default constructor. Should only be called by #createExecutableExtension.
- */
- public ConfigurationPreferences() {
- this(null, null);
- }
-
- private ConfigurationPreferences(EclipsePreferences parent, String name) {
- super(parent, name);
-
- initializeChildren();
-
- // cache the segment count
- String path = absolutePath();
- segmentCount = getSegmentCount(path);
- if (segmentCount < 2)
- return;
-
- // cache the qualifier
- qualifier = getSegment(path, 1);
-
- // cache the location
- if (qualifier == null)
- return;
- if (baseLocation != null)
- location = computeLocation(baseLocation, qualifier);
- }
-
- protected IPath getLocation() {
- return location;
- }
-
- protected boolean isAlreadyLoaded(IEclipsePreferences node) {
- return loadedNodes.contains(node.name());
- }
-
- protected void loaded() {
- loadedNodes.add(name());
- }
-
- /*
- * Return the node at which these preferences are loaded/saved.
- */
- protected IEclipsePreferences getLoadLevel() {
- if (loadLevel == null) {
- if (qualifier == null)
- return null;
- // Make it relative to this node rather than navigating to it from the root.
- // Walk backwards up the tree starting at this node.
- // This is important to avoid a chicken/egg thing on startup.
- IEclipsePreferences node = this;
- for (int i = 2; i < segmentCount; i++)
- node = (EclipsePreferences) node.parent();
- loadLevel = node;
- }
- return loadLevel;
- }
-
- protected void initializeChildren() {
- if (initialized || parent == null)
- return;
- try {
- synchronized (this) {
- if (baseLocation == null)
- return;
- String[] names = computeChildren(baseLocation);
- for (int i = 0; i < names.length; i++)
- addChild(names[i], null);
- }
- } finally {
- initialized = true;
- }
- }
-
- protected EclipsePreferences internalCreate(EclipsePreferences nodeParent, String nodeName, Object context) {
- return new ConfigurationPreferences(nodeParent, nodeName);
- }
-}
diff --git a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/DefaultPreferences.java b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/DefaultPreferences.java
deleted file mode 100644
index 4ee794ac0..000000000
--- a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/DefaultPreferences.java
+++ /dev/null
@@ -1,362 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.preferences;
-
-import java.io.*;
-import java.lang.ref.WeakReference;
-import java.net.URL;
-import java.util.*;
-import org.eclipse.core.internal.runtime.RuntimeLog;
-import org.eclipse.core.runtime.*;
-import org.eclipse.core.runtime.preferences.*;
-import org.eclipse.osgi.util.NLS;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.util.tracker.ServiceTracker;
-
-/**
- * @since 3.0
- */
-public class DefaultPreferences extends EclipsePreferences {
- // cache which nodes have been loaded from disk
- private static Set loadedNodes = new HashSet();
- private static final String ELEMENT_INITIALIZER = "initializer"; //$NON-NLS-1$
- private static final String ATTRIBUTE_CLASS = "class"; //$NON-NLS-1$
- private static final String KEY_PREFIX = "%"; //$NON-NLS-1$
- private static final String KEY_DOUBLE_PREFIX = "%%"; //$NON-NLS-1$
- private static final IPath NL_DIR = new Path("$nl$"); //$NON-NLS-1$
-
- private static final String PROPERTIES_FILE_EXTENSION = "properties"; //$NON-NLS-1$
- private static Properties productCustomization;
- private static Properties productTranslation;
- private static Properties commandLineCustomization;
- private EclipsePreferences loadLevel;
-
- // cached values
- private String qualifier;
- private int segmentCount;
- private WeakReference pluginReference;
-
-
- public static String pluginCustomizationFile = null;
-
- /**
- * Default constructor for this class.
- */
- public DefaultPreferences() {
- this(null, null);
- }
-
- private DefaultPreferences(EclipsePreferences parent, String name, Object context) {
- this(parent, name);
- this.pluginReference = new WeakReference(context);
- }
-
- private DefaultPreferences(EclipsePreferences parent, String name) {
- super(parent, name);
-
- if (parent instanceof DefaultPreferences)
- this.pluginReference = ((DefaultPreferences) parent).pluginReference;
-
- // cache the segment count
- String path = absolutePath();
- segmentCount = getSegmentCount(path);
- if (segmentCount < 2)
- return;
-
- // cache the qualifier
- qualifier = getSegment(path, 1);
- }
-
- /*
- * Apply the values set in the bundle's install directory.
- *
- * In Eclipse 2.1 this is equivalent to:
- * /eclipse/plugins/<pluginID>/prefs.ini
- */
- private void applyBundleDefaults() {
- Bundle bundle = PreferencesOSGiUtils.getDefault().getBundle(name());
- if (bundle == null)
- return;
- URL url = FileLocator.find(bundle, new Path(IPreferencesConstants.PREFERENCES_DEFAULT_OVERRIDE_FILE_NAME), null);
- if (url == null) {
- if (EclipsePreferences.DEBUG_PREFERENCE_GENERAL)
- PrefsMessages.message("Preference default override file not found for bundle: " + bundle.getSymbolicName()); //$NON-NLS-1$
- return;
- }
- URL transURL = FileLocator.find(bundle, NL_DIR.append(IPreferencesConstants.PREFERENCES_DEFAULT_OVERRIDE_BASE_NAME).addFileExtension(PROPERTIES_FILE_EXTENSION), null);
- if (transURL == null && EclipsePreferences.DEBUG_PREFERENCE_GENERAL)
- PrefsMessages.message("Preference translation file not found for bundle: " + bundle.getSymbolicName()); //$NON-NLS-1$
- applyDefaults(name(), loadProperties(url), loadProperties(transURL));
- }
-
- /*
- * Apply the default values as specified in the file
- * as an argument on the command-line.
- */
- private void applyCommandLineDefaults() {
- // prime the cache the first time
- if (commandLineCustomization == null) {
- String filename = pluginCustomizationFile;
- if (filename == null) {
- if (EclipsePreferences.DEBUG_PREFERENCE_GENERAL)
- PrefsMessages.message("Command-line preferences customization file not specified."); //$NON-NLS-1$
- return;
- }
- if (EclipsePreferences.DEBUG_PREFERENCE_GENERAL)
- PrefsMessages.message("Using command-line preference customization file: " + filename); //$NON-NLS-1$
- commandLineCustomization = loadProperties(filename);
- }
- applyDefaults(null, commandLineCustomization, null);
- }
-
- /*
- * If the qualifier is null then the file is of the format:
- * pluginID/key=value
- * otherwise the file is of the format:
- * key=value
- */
- private void applyDefaults(String id, Properties defaultValues, Properties translations) {
- for (Enumeration e = defaultValues.keys(); e.hasMoreElements();) {
- String fullKey = (String) e.nextElement();
- String value = defaultValues.getProperty(fullKey);
- if (value == null)
- continue;
- IPath childPath = new Path(fullKey);
- String key = childPath.lastSegment();
- childPath = childPath.removeLastSegments(1);
- String localQualifier = id;
- if (id == null) {
- localQualifier = childPath.segment(0);
- childPath = childPath.removeFirstSegments(1);
- }
- if (name().equals(localQualifier)) {
- value = translatePreference(value, translations);
- if (EclipsePreferences.DEBUG_PREFERENCE_SET)
- PrefsMessages.message("Setting default preference: " + (new Path(absolutePath()).append(childPath).append(key)) + '=' + value); //$NON-NLS-1$
- ((EclipsePreferences) internalNode(childPath.toString(), false, null)).internalPut(key, value);
- }
- }
- }
-
- private void runInitializer(IConfigurationElement element) {
- AbstractPreferenceInitializer initializer = null;
- try {
- initializer = (AbstractPreferenceInitializer) element.createExecutableExtension(ATTRIBUTE_CLASS);
- initializer.initializeDefaultPreferences();
- } catch (ClassCastException e) {
- IStatus status = new Status(IStatus.ERROR, PrefsMessages.OWNER_NAME, IStatus.ERROR, PrefsMessages.preferences_invalidExtensionSuperclass, e);
- log(status);
- } catch (CoreException e) {
- log(e.getStatus());
- }
- }
-
- public IEclipsePreferences node(String childName, Object context) {
- return internalNode(childName, true, context);
- }
-
- /*
- * Runtime defaults are the ones which are specified in code at runtime.
- *
- * In the Eclipse 2.1 world they were the ones which were specified in the
- * over-ridden Plugin#initializeDefaultPluginPreferences() method.
- *
- * In Eclipse 3.0 they are set in the code which is indicated by the
- * extension to the plug-in default customizer extension point.
- */
- private void applyRuntimeDefaults() {
- IExtension[] extensions = PreferencesService.getPrefExtensions();
- if (extensions.length == 0) {
- if (EclipsePreferences.DEBUG_PREFERENCE_GENERAL)
- PrefsMessages.message("Skipping runtime default preference customization."); //$NON-NLS-1$
- return;
- }
- boolean foundInitializer = false;
- for (int i = 0; i < extensions.length; i++) {
- IConfigurationElement[] elements = extensions[i].getConfigurationElements();
- for (int j = 0; j < elements.length; j++)
- if (ELEMENT_INITIALIZER.equals(elements[j].getName())) {
- if (name().equals(elements[j].getContributor().getName())) {
- if (EclipsePreferences.DEBUG_PREFERENCE_GENERAL) {
- IExtension theExtension = elements[j].getDeclaringExtension();
- String extensionNamespace = theExtension.getContributor().getName();
- Bundle underlyingBundle = PreferencesOSGiUtils.getDefault().getBundle(extensionNamespace);
- String ownerName;
- if (underlyingBundle != null)
- ownerName = underlyingBundle.getSymbolicName();
- else
- ownerName = extensionNamespace;
- PrefsMessages.message("Running default preference customization as defined by: " + ownerName); //$NON-NLS-1$
- }
- runInitializer(elements[j]);
- // don't return yet in case we have multiple initializers registered
- foundInitializer = true;
- }
- }
- }
- if (foundInitializer)
- return;
-
- // Do legacy plugin preference initialization
- Object plugin = pluginReference.get();
- ILegacyPreferences initService = PreferencesOSGiUtils.getDefault().getLegacyPreferences();
- if (initService != null)
- plugin = initService.init(plugin, name());
- pluginReference = new WeakReference(plugin);
- }
-
- /*
- * Apply the default values as specified by the file
- * in the product extension.
- *
- * In Eclipse 2.1 this is equivalent to the plugin_customization.ini
- * file in the primary feature's plug-in directory.
- */
- private void applyProductDefaults() {
- // prime the cache the first time
- if (productCustomization == null) {
- BundleContext context = Activator.getContext();
- if (context != null) {
- ServiceTracker productTracker = new ServiceTracker(context, IProductPreferencesService.class.getName(), null);
- productTracker.open();
- IProductPreferencesService productSpecials = (IProductPreferencesService) productTracker.getService();
- if (productSpecials != null) {
- productCustomization = productSpecials.getProductCustomization();
- productTranslation = productSpecials.getProductTranslation();
- }
- productTracker.close();
- } else
- PrefsMessages.message("Product-specified preferences called before plugin is started"); //$NON-NLS-1$
- }
- applyDefaults(null, productCustomization, productTranslation);
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.prefs.Preferences#flush()
- */
- public void flush() {
- // default values are not persisted
- }
-
- protected IEclipsePreferences getLoadLevel() {
- if (loadLevel == null) {
- if (qualifier == null)
- return null;
- // Make it relative to this node rather than navigating to it from the root.
- // Walk backwards up the tree starting at this node.
- // This is important to avoid a chicken/egg thing on startup.
- EclipsePreferences node = this;
- for (int i = 2; i < segmentCount; i++)
- node = (EclipsePreferences) node.parent();
- loadLevel = node;
- }
- return loadLevel;
- }
-
- protected EclipsePreferences internalCreate(EclipsePreferences nodeParent, String nodeName, Object context) {
- return new DefaultPreferences(nodeParent, nodeName, context);
- }
-
- protected boolean isAlreadyLoaded(IEclipsePreferences node) {
- return loadedNodes.contains(node.name());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.internal.preferences.EclipsePreferences#load()
- */
- protected void load() {
- loadDefaults();
- }
-
- private void loadDefaults() {
- applyRuntimeDefaults();
- applyBundleDefaults();
- applyProductDefaults();
- applyCommandLineDefaults();
- }
-
- private Properties loadProperties(URL url) {
- Properties result = new Properties();
- if (url == null)
- return result;
- InputStream input = null;
- try {
- input = url.openStream();
- result.load(input);
- } catch (IOException e) {
- if (EclipsePreferences.DEBUG_PREFERENCE_GENERAL) {
- PrefsMessages.message("Problem opening stream to preference customization file: " + url); //$NON-NLS-1$
- e.printStackTrace();
- }
- } finally {
- if (input != null)
- try {
- input.close();
- } catch (IOException e) {
- // ignore
- }
- }
- return result;
- }
-
- private Properties loadProperties(String filename) {
- Properties result = new Properties();
- InputStream input = null;
- try {
- input = new BufferedInputStream(new FileInputStream(filename));
- result.load(input);
- } catch (FileNotFoundException e) {
- if (EclipsePreferences.DEBUG_PREFERENCE_GENERAL)
- PrefsMessages.message("Preference customization file not found: " + filename); //$NON-NLS-1$
- } catch (IOException e) {
- String message = NLS.bind(PrefsMessages.preferences_loadException, filename);
- IStatus status = new Status(IStatus.ERROR, PrefsMessages.OWNER_NAME, IStatus.ERROR, message, e);
- RuntimeLog.log(status);
- } finally {
- if (input != null)
- try {
- input.close();
- } catch (IOException e) {
- // ignore
- }
- }
- return result;
- }
-
- protected void loaded() {
- loadedNodes.add(name());
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.prefs.Preferences#sync()
- */
- public void sync() {
- // default values are not persisted
- }
-
- /**
- * Takes a preference value and a related resource bundle and
- * returns the translated version of this value (if one exists).
- */
- private String translatePreference(String value, Properties props) {
- value = value.trim();
- if (props == null || value.startsWith(KEY_DOUBLE_PREFIX))
- return value;
- if (value.startsWith(KEY_PREFIX)) {
- int ix = value.indexOf(" "); //$NON-NLS-1$
- String key = ix == -1 ? value.substring(1) : value.substring(1, ix);
- String dflt = ix == -1 ? value : value.substring(ix + 1);
- return props.getProperty(key, dflt);
- }
- return value;
- }
-}
diff --git a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/EclipsePreferences.java b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/EclipsePreferences.java
deleted file mode 100644
index f89fd6060..000000000
--- a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/EclipsePreferences.java
+++ /dev/null
@@ -1,1167 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- * Julian Chen - fix for bug #92572, jclRM
- *******************************************************************************/
-package org.eclipse.core.internal.preferences;
-
-import java.io.*;
-import java.util.*;
-import org.eclipse.core.internal.runtime.RuntimeLog;
-import org.eclipse.core.runtime.*;
-import org.eclipse.core.runtime.preferences.*;
-import org.eclipse.osgi.util.NLS;
-import org.osgi.service.prefs.BackingStoreException;
-import org.osgi.service.prefs.Preferences;
-
-/**
- * Represents a node in the Eclipse preference node hierarchy. This class
- * is used as a default implementation/super class for those nodes which
- * belong to scopes which are contributed by the Platform.
- *
- * Implementation notes:
- *
- * - For thread safety, we always synchronize on the node object when writing
- * the children or properties fields. Must ensure we don't synchronize when calling
- * client code such as listeners.
- *
- * @since 3.0
- */
-public class EclipsePreferences implements IEclipsePreferences, IScope {
-
- public static final String DEFAULT_PREFERENCES_DIRNAME = ".settings"; //$NON-NLS-1$
- public static final String PREFS_FILE_EXTENSION = "prefs"; //$NON-NLS-1$
- protected static final IEclipsePreferences[] EMPTY_NODE_ARRAY = new IEclipsePreferences[0];
- protected static final String[] EMPTY_STRING_ARRAY = new String[0];
- private static final String FALSE = "false"; //$NON-NLS-1$
- private static final String TRUE = "true"; //$NON-NLS-1$
- protected static final String VERSION_KEY = "eclipse.preferences.version"; //$NON-NLS-1$
- protected static final String VERSION_VALUE = "1"; //$NON-NLS-1$
- protected static final String PATH_SEPARATOR = String.valueOf(IPath.SEPARATOR);
- protected static final String DOUBLE_SLASH = "//"; //$NON-NLS-1$
- protected static final String EMPTY_STRING = ""; //$NON-NLS-1$
-
- private String cachedPath;
- protected Map children;
- protected boolean dirty = false;
- protected boolean loading = false;
- protected final String name;
- // the parent of an EclipsePreference node is always an EclipsePreference node. (or null)
- protected final EclipsePreferences parent;
- protected ImmutableMap properties = ImmutableMap.EMPTY;
- protected boolean removed = false;
- private ListenerList nodeChangeListeners;
- private ListenerList preferenceChangeListeners;
-
- public static boolean DEBUG_PREFERENCE_GENERAL = false;
- public static boolean DEBUG_PREFERENCE_SET = false;
- public static boolean DEBUG_PREFERENCE_GET = false;
-
- protected final static String debugPluginName = "org.eclipse.equinox.preferences"; //$NON-NLS-1$
-
- static {
- DEBUG_PREFERENCE_GENERAL = PreferencesOSGiUtils.getDefault().getBooleanDebugOption(debugPluginName + "/general", false); //$NON-NLS-1$
- DEBUG_PREFERENCE_SET = PreferencesOSGiUtils.getDefault().getBooleanDebugOption(debugPluginName + "/set", false); //$NON-NLS-1$
- DEBUG_PREFERENCE_GET = PreferencesOSGiUtils.getDefault().getBooleanDebugOption(debugPluginName + "/get", false); //$NON-NLS-1$
- }
-
- public EclipsePreferences() {
- this(null, null);
- }
-
- protected EclipsePreferences(EclipsePreferences parent, String name) {
- super();
- this.parent = parent;
- this.name = name;
- }
-
- /*
- * @see org.osgi.service.prefs.Preferences#absolutePath()
- */
- public String absolutePath() {
- if (cachedPath == null) {
- if (parent == null)
- cachedPath = PATH_SEPARATOR;
- else {
- String parentPath = parent.absolutePath();
- // if the parent is the root then we don't have to add a separator
- // between the parent path and our path
- if (parentPath.length() == 1)
- cachedPath = parentPath + name();
- else
- cachedPath = parentPath + PATH_SEPARATOR + name();
- }
- }
- return cachedPath;
- }
-
- public void accept(IPreferenceNodeVisitor visitor) throws BackingStoreException {
- if (!visitor.visit(this))
- return;
- IEclipsePreferences[] toVisit = getChildren(true);
- for (int i = 0; i < toVisit.length; i++)
- toVisit[i].accept(visitor);
- }
-
- protected synchronized IEclipsePreferences addChild(String childName, IEclipsePreferences child) {
- //Thread safety: synchronize method to protect modification of children field
- if (children == null)
- children = Collections.synchronizedMap(new HashMap());
- children.put(childName, child == null ? (Object) childName : child);
- return child;
- }
-
- /*
- * @see org.eclipse.core.runtime.IEclipsePreferences#addNodeChangeListener(org.eclipse.core.runtime.IEclipsePreferences.INodeChangeListener)
- */
- public void addNodeChangeListener(INodeChangeListener listener) {
- checkRemoved();
- if (nodeChangeListeners == null)
- nodeChangeListeners = new ListenerList();
- nodeChangeListeners.add(listener);
- if (DEBUG_PREFERENCE_GENERAL)
- PrefsMessages.message("Added preference node change listener: " + listener + " to: " + absolutePath()); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /*
- * @see org.eclipse.core.runtime.IEclipsePreferences#addPreferenceChangeListener(org.eclipse.core.runtime.IEclipsePreferences.IPreferenceChangeListener)
- */
- public void addPreferenceChangeListener(IPreferenceChangeListener listener) {
- checkRemoved();
- if (preferenceChangeListeners == null)
- preferenceChangeListeners = new ListenerList();
- preferenceChangeListeners.add(listener);
- if (DEBUG_PREFERENCE_GENERAL)
- PrefsMessages.message("Added preference property change listener: " + listener + " to: " + absolutePath()); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- private IEclipsePreferences calculateRoot() {
- IEclipsePreferences result = this;
- while (result.parent() != null)
- result = (IEclipsePreferences) result.parent();
- return result;
- }
-
- /*
- * Convenience method for throwing an exception when methods
- * are called on a removed node.
- */
- protected void checkRemoved() {
- if (removed)
- throw new IllegalStateException(NLS.bind(PrefsMessages.preferences_removedNode, name));
- }
-
- /*
- * @see org.osgi.service.prefs.Preferences#childrenNames()
- */
- public String[] childrenNames() {
- // illegal state if this node has been removed
- checkRemoved();
- return internalChildNames();
- }
-
- protected String[] internalChildNames() {
- Map temp = children;
- if (temp == null || temp.size() == 0)
- return EMPTY_STRING_ARRAY;
- return (String[]) temp.keySet().toArray(EMPTY_STRING_ARRAY);
- }
-
- /*
- * @see org.osgi.service.prefs.Preferences#clear()
- */
- public void clear() {
- // illegal state if this node has been removed
- checkRemoved();
- // call each one separately (instead of Properties.clear) so
- // clients get change notification
- String[] keys = properties.keys();
- for (int i = 0; i < keys.length; i++)
- remove(keys[i]);
- makeDirty();
- }
-
- protected String[] computeChildren(IPath root) {
- if (root == null)
- return EMPTY_STRING_ARRAY;
- IPath dir = root.append(DEFAULT_PREFERENCES_DIRNAME);
- final ArrayList result = new ArrayList();
- final String extension = '.' + PREFS_FILE_EXTENSION;
- File file = dir.toFile();
- File[] totalFiles = file.listFiles();
- if (totalFiles != null) {
- for (int i = 0; i < totalFiles.length; i++) {
- if (totalFiles[i].isFile()) {
- String filename = totalFiles[i].getName();
- if (filename.endsWith(extension)) {
- String shortName = filename.substring(0, filename.length() - extension.length());
- result.add(shortName);
- }
- }
- }
- }
- return (String[]) result.toArray(EMPTY_STRING_ARRAY);
- }
-
- protected IPath computeLocation(IPath root, String qualifier) {
- return root == null ? null : root.append(DEFAULT_PREFERENCES_DIRNAME).append(qualifier).addFileExtension(PREFS_FILE_EXTENSION);
- }
-
- /*
- * Version 1 (current version)
- * path/key=value
- */
- protected static void convertFromProperties(EclipsePreferences node, Properties table, boolean notify) {
- String version = table.getProperty(VERSION_KEY);
- if (version == null || !VERSION_VALUE.equals(version)) {
- // ignore for now
- }
- table.remove(VERSION_KEY);
- for (Iterator i = table.keySet().iterator(); i.hasNext();) {
- String fullKey = (String) i.next();
- String value = table.getProperty(fullKey);
- if (value != null) {
- String[] splitPath = decodePath(fullKey);
- String path = splitPath[0];
- path = makeRelative(path);
- String key = splitPath[1];
- if (DEBUG_PREFERENCE_SET)
- PrefsMessages.message("Setting preference: " + path + '/' + key + '=' + value); //$NON-NLS-1$
- //use internal methods to avoid notifying listeners
- EclipsePreferences childNode = (EclipsePreferences) node.internalNode(path, false, null);
- String oldValue = childNode.internalPut(key, value);
- // notify listeners if applicable
- if (notify && !value.equals(oldValue))
- node.firePreferenceEvent(key, oldValue, value);
- }
- }
- PreferencesService.getDefault().shareStrings();
- }
-
- /*
- * Helper method to convert this node to a Properties file suitable
- * for persistence.
- */
- protected Properties convertToProperties(Properties result, String prefix) throws BackingStoreException {
- // add the key/value pairs from this node
- boolean addSeparator = prefix.length() != 0;
- //thread safety: copy reference in case of concurrent change
- ImmutableMap temp = properties;
- String[] keys = temp.keys();
- for (int i = 0, imax = keys.length; i < imax; i++) {
- String value = temp.get(keys[i]);
- if (value != null)
- result.put(encodePath(prefix, keys[i]), value);
- }
- // recursively add the child information
- IEclipsePreferences[] childNodes = getChildren(true);
- for (int i = 0; i < childNodes.length; i++) {
- EclipsePreferences child = (EclipsePreferences) childNodes[i];
- String fullPath = addSeparator ? prefix + PATH_SEPARATOR + child.name() : child.name();
- child.convertToProperties(result, fullPath);
- }
- PreferencesService.getDefault().shareStrings();
- return result;
- }
-
- /*
- * @see org.eclipse.core.runtime.preferences.IScope#create(org.eclipse.core.runtime.preferences.IEclipsePreferences)
- */
- public IEclipsePreferences create(IEclipsePreferences nodeParent, String nodeName) {
- return create((EclipsePreferences) nodeParent, nodeName, null);
- }
-
- protected boolean isLoading() {
- return loading;
- }
-
- protected void setLoading(boolean isLoading) {
- loading = isLoading;
- }
-
- public IEclipsePreferences create(EclipsePreferences nodeParent, String nodeName, Object context) {
- EclipsePreferences result = internalCreate(nodeParent, nodeName, context);
- nodeParent.addChild(nodeName, result);
- IEclipsePreferences loadLevel = result.getLoadLevel();
-
- // if this node or a parent node is not the load level then return
- if (loadLevel == null)
- return result;
-
- // if the result node is not a load level, then a child must be
- if (result != loadLevel)
- return result;
-
- // the result node is a load level
- if (isAlreadyLoaded(result) || result.isLoading())
- return result;
- try {
- result.setLoading(true);
- result.loadLegacy();
- result.load();
- result.loaded();
- result.flush();
- } catch (BackingStoreException e) {
- IPath location = result.getLocation();
- String message = NLS.bind(PrefsMessages.preferences_loadException, location == null ? EMPTY_STRING : location.toString());
- IStatus status = new Status(IStatus.ERROR, PrefsMessages.OWNER_NAME, IStatus.ERROR, message, e);
- RuntimeLog.log(status);
- } finally {
- result.setLoading(false);
- }
- return result;
- }
-
- /*
- * @see org.osgi.service.prefs.Preferences#flush()
- */
- public void flush() throws BackingStoreException {
- // illegal state if this node has been removed
- checkRemoved();
-
- IEclipsePreferences loadLevel = getLoadLevel();
-
- // if this node or a parent is not the load level, then flush the children
- if (loadLevel == null) {
- String[] childrenNames = childrenNames();
- for (int i = 0; i < childrenNames.length; i++)
- node(childrenNames[i]).flush();
- return;
- }
-
- // a parent is the load level for this node
- if (this != loadLevel) {
- loadLevel.flush();
- return;
- }
-
- // this node is a load level
- // any work to do?
- if (!dirty)
- return;
- //remove dirty bit before saving, to ensure that concurrent
- //changes during save mark the store as dirty
- dirty = false;
- try {
- save();
- } catch (BackingStoreException e) {
- //mark it dirty again because the save failed
- dirty = true;
- throw e;
- }
- }
-
- /*
- * @see org.osgi.service.prefs.Preferences#get(java.lang.String, java.lang.String)
- */
- public String get(String key, String defaultValue) {
- String value = internalGet(key);
- return value == null ? defaultValue : value;
- }
-
- /*
- * @see org.osgi.service.prefs.Preferences#getBoolean(java.lang.String, boolean)
- */
- public boolean getBoolean(String key, boolean defaultValue) {
- String value = internalGet(key);
- return value == null ? defaultValue : TRUE.equalsIgnoreCase(value);
- }
-
- /*
- * @see org.osgi.service.prefs.Preferences#getByteArray(java.lang.String, byte[])
- */
- public byte[] getByteArray(String key, byte[] defaultValue) {
- String value = internalGet(key);
- return value == null ? defaultValue : Base64.decode(value.getBytes());
- }
-
- /*
- * Return a boolean value indicating whether or not a child with the given
- * name is known to this node.
- */
- protected synchronized boolean childExists(String childName) {
- if (children == null)
- return false;
- return children.get(childName) != null;
- }
-
- /**
- * Thread safe way to obtain a child for a given key. Returns the child
- * that matches the given key, or null if there is no matching child.
- */
- protected IEclipsePreferences getChild(String key, Object context, boolean create) {
- synchronized (this) {
- if (children == null)
- return null;
- Object value = children.get(key);
- if (value == null)
- return null;
- if (value instanceof IEclipsePreferences)
- return (IEclipsePreferences) value;
- // if we aren't supposed to create this node, then
- // just return null
- if (!create)
- return null;
- }
- return addChild(key, create(this, key, context));
- }
-
- /**
- * Thread safe way to obtain all children of this node. Never returns null.
- */
- protected IEclipsePreferences[] getChildren(boolean create) {
- ArrayList result = new ArrayList();
- String[] names = internalChildNames();
- for (int i = 0; i < names.length; i++) {
- IEclipsePreferences child = getChild(names[i], null, create);
- if (child != null)
- result.add(child);
- }
- return (IEclipsePreferences[]) result.toArray(EMPTY_NODE_ARRAY);
- }
-
- /*
- * @see org.osgi.service.prefs.Preferences#getDouble(java.lang.String, double)
- */
- public double getDouble(String key, double defaultValue) {
- String value = internalGet(key);
- double result = defaultValue;
- if (value != null)
- try {
- result = Double.parseDouble(value);
- } catch (NumberFormatException e) {
- // use default
- }
- return result;
- }
-
- /*
- * @see org.osgi.service.prefs.Preferences#getFloat(java.lang.String, float)
- */
- public float getFloat(String key, float defaultValue) {
- String value = internalGet(key);
- float result = defaultValue;
- if (value != null)
- try {
- result = Float.parseFloat(value);
- } catch (NumberFormatException e) {
- // use default
- }
- return result;
- }
-
- /*
- * @see org.osgi.service.prefs.Preferences#getInt(java.lang.String, int)
- */
- public int getInt(String key, int defaultValue) {
- String value = internalGet(key);
- int result = defaultValue;
- if (value != null)
- try {
- result = Integer.parseInt(value);
- } catch (NumberFormatException e) {
- // use default
- }
- return result;
- }
-
- protected IEclipsePreferences getLoadLevel() {
- return null;
- }
-
- /*
- * Subclasses to over-ride
- */
- protected IPath getLocation() {
- return null;
- }
-
- /*
- * @see org.osgi.service.prefs.Preferences#getLong(java.lang.String, long)
- */
- public long getLong(String key, long defaultValue) {
- String value = internalGet(key);
- long result = defaultValue;
- if (value != null)
- try {
- result = Long.parseLong(value);
- } catch (NumberFormatException e) {
- // use default
- }
- return result;
- }
-
- protected EclipsePreferences internalCreate(EclipsePreferences nodeParent, String nodeName, Object context) {
- return new EclipsePreferences(nodeParent, nodeName);
- }
-
- /**
- * Returns the existing value at the given key, or null if
- * no such value exists.
- */
- protected String internalGet(String key) {
- // throw NPE if key is null
- if (key == null)
- throw new NullPointerException();
- // illegal state if this node has been removed
- checkRemoved();
- String result = properties.get(key);
- if (DEBUG_PREFERENCE_GET)
- PrefsMessages.message("Getting preference value: " + absolutePath() + '/' + key + "->" + result); //$NON-NLS-1$ //$NON-NLS-2$
- return result;
- }
-
- /**
- * Implements the node(String) method, and optionally notifies listeners.
- */
- protected IEclipsePreferences internalNode(String path, boolean notify, Object context) {
-
- // illegal state if this node has been removed
- checkRemoved();
-
- // short circuit this node
- if (path.length() == 0)
- return this;
-
- // if we have an absolute path use the root relative to
- // this node instead of the global root
- // in case we have a different hierarchy. (e.g. export)
- if (path.charAt(0) == IPath.SEPARATOR)
- return (IEclipsePreferences) calculateRoot().node(path.substring(1));
-
- int index = path.indexOf(IPath.SEPARATOR);
- String key = index == -1 ? path : path.substring(0, index);
- boolean added = false;
- IEclipsePreferences child = getChild(key, context, true);
- if (child == null) {
- child = create(this, key, context);
- added = true;
- }
- // notify listeners if a child was added
- if (added && notify)
- fireNodeEvent(new NodeChangeEvent(this, child), true);
- return (IEclipsePreferences) child.node(index == -1 ? EMPTY_STRING : path.substring(index + 1));
- }
-
- /**
- * Stores the given (key,value) pair, performing lazy initialization of the
- * properties field if necessary. Returns the old value for the given key,
- * or null if no value existed.
- */
- protected String internalPut(String key, String newValue) {
- // illegal state if this node has been removed
- checkRemoved();
- String oldValue = properties.get(key);
- if (oldValue != null && oldValue.equals(newValue))
- return oldValue;
- if (DEBUG_PREFERENCE_SET)
- PrefsMessages.message("Setting preference: " + absolutePath() + '/' + key + '=' + newValue); //$NON-NLS-1$
- properties = properties.put(key, newValue);
- return oldValue;
- }
-
- /*
- * Subclasses to over-ride.
- */
- protected boolean isAlreadyLoaded(IEclipsePreferences node) {
- return true;
- }
-
- /*
- * @see org.osgi.service.prefs.Preferences#keys()
- */
- public String[] keys() {
- // illegal state if this node has been removed
- checkRemoved();
- return properties.keys();
- }
-
- protected void load() throws BackingStoreException {
- load(getLocation());
- }
-
- protected static Properties loadProperties(IPath location) throws BackingStoreException {
- if (DEBUG_PREFERENCE_GENERAL)
- PrefsMessages.message("Loading preferences from file: " + location); //$NON-NLS-1$
- InputStream input = null;
- Properties result = new Properties();
- try {
- input = new BufferedInputStream(new FileInputStream(location.toFile()));
- result.load(input);
- } catch (FileNotFoundException e) {
- // file doesn't exist but that's ok.
- if (DEBUG_PREFERENCE_GENERAL)
- PrefsMessages.message("Preference file does not exist: " + location); //$NON-NLS-1$
- return result;
- } catch (IOException e) {
- String message = NLS.bind(PrefsMessages.preferences_loadException, location);
- log(new Status(IStatus.INFO, PrefsMessages.OWNER_NAME, IStatus.INFO, message, e));
- throw new BackingStoreException(message);
- } finally {
- if (input != null)
- try {
- input.close();
- } catch (IOException e) {
- // ignore
- }
- }
- return result;
- }
-
- protected void load(IPath location) throws BackingStoreException {
- if (location == null) {
- if (DEBUG_PREFERENCE_GENERAL)
- PrefsMessages.message("Unable to determine location of preference file for node: " + absolutePath()); //$NON-NLS-1$
- return;
- }
- Properties fromDisk = loadProperties(location);
- convertFromProperties(this, fromDisk, false);
- }
-
- protected void loaded() {
- // do nothing
- }
-
- protected void loadLegacy() {
- // sub-classes to over-ride if necessary
- }
-
- public static void log(IStatus status) {
- RuntimeLog.log(status);
- }
-
- protected void makeDirty() {
- EclipsePreferences node = this;
- while (node != null && !node.removed) {
- node.dirty = true;
- node = (EclipsePreferences) node.parent();
- }
- }
-
- public boolean isDirty() {
- return dirty;
- }
-
- /*
- * @see org.osgi.service.prefs.Preferences#name()
- */
- public String name() {
- return name;
- }
-
- /*
- * @see org.osgi.service.prefs.Preferences#node(java.lang.String)
- */
- public Preferences node(String pathName) {
- return internalNode(pathName, true, null);
- }
-
- protected void fireNodeEvent(final NodeChangeEvent event, final boolean added) {
- if (nodeChangeListeners == null)
- return;
- Object[] listeners = nodeChangeListeners.getListeners();
- for (int i = 0; i < listeners.length; i++) {
- final INodeChangeListener listener = (INodeChangeListener) listeners[i];
- ISafeRunnable job = new ISafeRunnable() {
- public void handleException(Throwable exception) {
- // already logged in Platform#run()
- }
-
- public void run() throws Exception {
- if (added)
- listener.added(event);
- else
- listener.removed(event);
- }
- };
- SafeRunner.run(job);
- }
- }
-
- /*
- * @see org.osgi.service.prefs.Preferences#nodeExists(java.lang.String)
- */
- public boolean nodeExists(String path) throws BackingStoreException {
- // short circuit for checking this node
- if (path.length() == 0)
- return !removed;
-
- // illegal state if this node has been removed.
- // do this AFTER checking for the empty string.
- checkRemoved();
-
- // use the root relative to this node instead of the global root
- // in case we have a different hierarchy. (e.g. export)
- if (path.charAt(0) == IPath.SEPARATOR)
- return calculateRoot().nodeExists(path.substring(1));
-
- int index = path.indexOf(IPath.SEPARATOR);
- boolean noSlash = index == -1;
-
- // if we are looking for a simple child then just look in the table and return
- if (noSlash)
- return childExists(path);
-
- // otherwise load the parent of the child and then recursively ask
- String childName = path.substring(0, index);
- if (!childExists(childName))
- return false;
- IEclipsePreferences child = getChild(childName, null, true);
- if (child == null)
- return false;
- return child.nodeExists(path.substring(index + 1));
- }
-
- /*
- * @see org.osgi.service.prefs.Preferences#parent()
- */
- public Preferences parent() {
- // illegal state if this node has been removed
- checkRemoved();
- return parent;
- }
-
- /*
- * Convenience method for notifying preference change listeners.
- */
- protected void firePreferenceEvent(String key, Object oldValue, Object newValue) {
- if (preferenceChangeListeners == null)
- return;
- Object[] listeners = preferenceChangeListeners.getListeners();
- final PreferenceChangeEvent event = new PreferenceChangeEvent(this, key, oldValue, newValue);
- for (int i = 0; i < listeners.length; i++) {
- final IPreferenceChangeListener listener = (IPreferenceChangeListener) listeners[i];
- ISafeRunnable job = new ISafeRunnable() {
- public void handleException(Throwable exception) {
- // already logged in Platform#run()
- }
-
- public void run() throws Exception {
- listener.preferenceChange(event);
- }
- };
- SafeRunner.run(job);
- }
- }
-
- /*
- * @see org.osgi.service.prefs.Preferences#put(java.lang.String, java.lang.String)
- */
- public void put(String key, String newValue) {
- if (key == null || newValue == null)
- throw new NullPointerException();
- String oldValue = internalPut(key, newValue);
- if (!newValue.equals(oldValue)) {
- makeDirty();
- firePreferenceEvent(key, oldValue, newValue);
- }
- }
-
- /*
- * @see org.osgi.service.prefs.Preferences#putBoolean(java.lang.String, boolean)
- */
- public void putBoolean(String key, boolean value) {
- if (key == null)
- throw new NullPointerException();
- String newValue = value ? TRUE : FALSE;
- String oldValue = internalPut(key, newValue);
- if (!newValue.equals(oldValue)) {
- makeDirty();
- firePreferenceEvent(key, oldValue, newValue);
- }
- }
-
- /*
- * @see org.osgi.service.prefs.Preferences#putByteArray(java.lang.String, byte[])
- */
- public void putByteArray(String key, byte[] value) {
- if (key == null || value == null)
- throw new NullPointerException();
- String newValue = new String(Base64.encode(value));
- String oldValue = internalPut(key, newValue);
- if (!newValue.equals(oldValue)) {
- makeDirty();
- firePreferenceEvent(key, oldValue, newValue);
- }
- }
-
- /*
- * @see org.osgi.service.prefs.Preferences#putDouble(java.lang.String, double)
- */
- public void putDouble(String key, double value) {
- if (key == null)
- throw new NullPointerException();
- String newValue = Double.toString(value);
- String oldValue = internalPut(key, newValue);
- if (!newValue.equals(oldValue)) {
- makeDirty();
- firePreferenceEvent(key, oldValue, newValue);
- }
- }
-
- /*
- * @see org.osgi.service.prefs.Preferences#putFloat(java.lang.String, float)
- */
- public void putFloat(String key, float value) {
- if (key == null)
- throw new NullPointerException();
- String newValue = Float.toString(value);
- String oldValue = internalPut(key, newValue);
- if (!newValue.equals(oldValue)) {
- makeDirty();
- firePreferenceEvent(key, oldValue, newValue);
- }
- }
-
- /*
- * @see org.osgi.service.prefs.Preferences#putInt(java.lang.String, int)
- */
- public void putInt(String key, int value) {
- if (key == null)
- throw new NullPointerException();
- String newValue = Integer.toString(value);
- String oldValue = internalPut(key, newValue);
- if (!newValue.equals(oldValue)) {
- makeDirty();
- firePreferenceEvent(key, oldValue, newValue);
- }
- }
-
- /*
- * @see org.osgi.service.prefs.Preferences#putLong(java.lang.String, long)
- */
- public void putLong(String key, long value) {
- if (key == null)
- throw new NullPointerException();
- String newValue = Long.toString(value);
- String oldValue = internalPut(key, newValue);
- if (!newValue.equals(oldValue)) {
- makeDirty();
- firePreferenceEvent(key, oldValue, newValue);
- }
- }
-
- /*
- * @see org.osgi.service.prefs.Preferences#remove(java.lang.String)
- */
- public void remove(String key) {
- String oldValue = properties.get(key);
- if (oldValue == null)
- return;
- properties = properties.removeKey(key);
- makeDirty();
- firePreferenceEvent(key, oldValue, null);
- }
-
- /*
- * @see org.osgi.service.prefs.Preferences#removeNode()
- */
- public void removeNode() throws BackingStoreException {
- // illegal state if this node has been removed
- checkRemoved();
- // clear all the property values. do it "the long way" so
- // everyone gets notification
- String[] keys = keys();
- for (int i = 0; i < keys.length; i++)
- remove(keys[i]);
- // don't remove the global root or the scope root from the
- // parent but remove all its children
- if (parent != null && !(parent instanceof RootPreferences)) {
- // remove the node from the parent's collection and notify listeners
- removed = true;
- parent.removeNode(this);
- }
- IEclipsePreferences[] childNodes = getChildren(false);
- for (int i = 0; i < childNodes.length; i++)
- try {
- childNodes[i].removeNode();
- } catch (IllegalStateException e) {
- // ignore since we only get this exception if we have already
- // been removed. no work to do.
- }
- }
-
- /*
- * Remove the child from the collection and notify the listeners if something
- * was actually removed.
- */
- protected void removeNode(IEclipsePreferences child) {
- boolean wasRemoved = false;
- synchronized (this) {
- if (children != null) {
- wasRemoved = children.remove(child.name()) != null;
- if (wasRemoved)
- makeDirty();
- if (children.isEmpty())
- children = null;
- }
- }
- if (wasRemoved)
- fireNodeEvent(new NodeChangeEvent(this, child), false);
- }
-
- /*
- * Remove non-initialized node from the collection.
- */
- protected void removeNode(String key) {
- synchronized (this) {
- if (children != null) {
- boolean wasRemoved = children.remove(key) != null;
- if (wasRemoved)
- makeDirty();
- if (children.isEmpty())
- children = null;
- }
- }
- }
-
- /*
- * @see org.eclipse.core.runtime.IEclipsePreferences#removeNodeChangeListener(org.eclipse.core.runtime.IEclipsePreferences.removeNodeChangeListener)
- */
- public void removeNodeChangeListener(INodeChangeListener listener) {
- checkRemoved();
- if (nodeChangeListeners == null)
- return;
- nodeChangeListeners.remove(listener);
- if (nodeChangeListeners.size() == 0)
- nodeChangeListeners = null;
- if (DEBUG_PREFERENCE_GENERAL)
- PrefsMessages.message("Removed preference node change listener: " + listener + " from: " + absolutePath()); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /*
- * @see org.eclipse.core.runtime.IEclipsePreferences#removePreferenceChangeListener(org.eclipse.core.runtime.IEclipsePreferences.IPreferenceChangeListener)
- */
- public void removePreferenceChangeListener(IPreferenceChangeListener listener) {
- checkRemoved();
- if (preferenceChangeListeners == null)
- return;
- preferenceChangeListeners.remove(listener);
- if (preferenceChangeListeners.size() == 0)
- preferenceChangeListeners = null;
- if (DEBUG_PREFERENCE_GENERAL)
- PrefsMessages.message("Removed preference property change listener: " + listener + " from: " + absolutePath()); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- protected void save() throws BackingStoreException {
- save(getLocation());
- }
-
- protected void save(IPath location) throws BackingStoreException {
- if (location == null) {
- if (DEBUG_PREFERENCE_GENERAL)
- PrefsMessages.message("Unable to determine location of preference file for node: " + absolutePath()); //$NON-NLS-1$
- return;
- }
- if (DEBUG_PREFERENCE_GENERAL)
- PrefsMessages.message("Saving preferences to file: " + location); //$NON-NLS-1$
- Properties table = convertToProperties(new Properties(), EMPTY_STRING);
- if (table.isEmpty()) {
- // nothing to save. delete existing file if one exists.
- if (location.toFile().exists() && !location.toFile().delete()) {
- String message = NLS.bind(PrefsMessages.preferences_failedDelete, location);
- log(new Status(IStatus.WARNING, PrefsMessages.OWNER_NAME, IStatus.WARNING, message, null));
- }
- return;
- }
- table.put(VERSION_KEY, VERSION_VALUE);
- OutputStream output = null;
- FileOutputStream fos = null;
- try {
- // create the parent dirs if they don't exist
- File parentFile = location.toFile().getParentFile();
- if (parentFile == null)
- return;
- parentFile.mkdirs();
- // set append to be false so we overwrite current settings.
- fos = new FileOutputStream(location.toOSString(), false);
- output = new BufferedOutputStream(fos);
- table.store(output, null);
- output.flush();
- fos.getFD().sync();
- } catch (IOException e) {
- String message = NLS.bind(PrefsMessages.preferences_saveException, location);
- log(new Status(IStatus.ERROR, PrefsMessages.OWNER_NAME, IStatus.ERROR, message, e));
- throw new BackingStoreException(message);
- } finally {
- if (output != null)
- try {
- output.close();
- } catch (IOException e) {
- // ignore
- }
- }
- }
-
- /**
- * Traverses the preference hierarchy rooted at this node, and adds
- * all preference key and value strings to the provided pool. If an added
- * string was already in the pool, all references will be replaced with the
- * canonical copy of the string.
- *
- * @param pool The pool to share strings in
- */
- public void shareStrings(StringPool pool) {
- properties.shareStrings(pool);
- IEclipsePreferences[] myChildren = getChildren(false);
- for (int i = 0; i < myChildren.length; i++)
- if (myChildren[i] instanceof EclipsePreferences)
- ((EclipsePreferences) myChildren[i]).shareStrings(pool);
- }
-
- /*
- * Encode the given path and key combo to a form which is suitable for
- * persisting or using when searching. If the key contains a slash character
- * then we must use a double-slash to indicate the end of the
- * path/the beginning of the key.
- */
- public static String encodePath(String path, String key) {
- String result;
- int pathLength = path == null ? 0 : path.length();
- if (key.indexOf(IPath.SEPARATOR) == -1) {
- if (pathLength == 0)
- result = key;
- else
- result = path + IPath.SEPARATOR + key;
- } else {
- if (pathLength == 0)
- result = DOUBLE_SLASH + key;
- else
- result = path + DOUBLE_SLASH + key;
- }
- return result;
- }
-
- /*
- * Return the segment from the given path or null.
- * "segment" parameter is 0-based.
- */
- public static String getSegment(String path, int segment) {
- int start = path.indexOf(IPath.SEPARATOR) == 0 ? 1 : 0;
- int end = path.indexOf(IPath.SEPARATOR, start);
- if (end == path.length() - 1)
- end = -1;
- for (int i = 0; i < segment; i++) {
- if (end == -1)
- return null;
- start = end + 1;
- end = path.indexOf(IPath.SEPARATOR, start);
- }
- if (end == -1)
- end = path.length();
- return path.substring(start, end);
- }
-
- public static int getSegmentCount(String path) {
- StringTokenizer tokenizer = new StringTokenizer(path, String.valueOf(IPath.SEPARATOR));
- return tokenizer.countTokens();
- }
-
- /*
- * Return a relative path
- */
- public static String makeRelative(String path) {
- String result = path;
- if (path == null)
- return EMPTY_STRING;
- if (path.length() > 0 && path.charAt(0) == IPath.SEPARATOR)
- result = path.length() == 0 ? EMPTY_STRING : path.substring(1);
- return result;
- }
-
- /*
- * Return a 2 element String array.
- * element 0 - the path
- * element 1 - the key
- * The path may be null.
- * The key is never null.
- */
- public static String[] decodePath(String fullPath) {
- String key = null;
- String path = null;
-
- // check to see if we have an indicator which tells us where the path ends
- int index = fullPath.indexOf(DOUBLE_SLASH);
- if (index == -1) {
- // we don't have a double-slash telling us where the path ends
- // so the path is up to the last slash character
- int lastIndex = fullPath.lastIndexOf(IPath.SEPARATOR);
- if (lastIndex == -1) {
- key = fullPath;
- } else {
- path = fullPath.substring(0, lastIndex);
- key = fullPath.substring(lastIndex + 1);
- }
- } else {
- // the child path is up to the double-slash and the key
- // is the string after it
- path = fullPath.substring(0, index);
- key = fullPath.substring(index + 2);
- }
-
- // adjust if we have an absolute path
- if (path != null)
- if (path.length() == 0)
- path = null;
- else if (path.charAt(0) == IPath.SEPARATOR)
- path = path.substring(1);
-
- return new String[] {path, key};
- }
-
- /*
- * @see org.osgi.service.prefs.Preferences#sync()
- */
-
- public void sync() throws BackingStoreException {
- // illegal state if this node has been removed
- checkRemoved();
- IEclipsePreferences node = getLoadLevel();
- if (node == null) {
- if (DEBUG_PREFERENCE_GENERAL)
- PrefsMessages.message("Preference node is not a load root: " + absolutePath()); //$NON-NLS-1$
- return;
- }
- if (node instanceof EclipsePreferences) {
- ((EclipsePreferences) node).load();
- node.flush();
- }
- }
-
- public String toDeepDebugString() {
- final StringBuffer buffer = new StringBuffer();
- IPreferenceNodeVisitor visitor = new IPreferenceNodeVisitor() {
- public boolean visit(IEclipsePreferences node) throws BackingStoreException {
- buffer.append(node);
- buffer.append('\n');
- String[] keys = node.keys();
- for (int i = 0; i < keys.length; i++) {
- buffer.append(node.absolutePath());
- buffer.append(PATH_SEPARATOR);
- buffer.append(keys[i]);
- buffer.append('=');
- buffer.append(node.get(keys[i], "*default*")); //$NON-NLS-1$
- buffer.append('\n');
- }
- return true;
- }
- };
- try {
- accept(visitor);
- } catch (BackingStoreException e) {
- System.out.println("Exception while calling #toDeepDebugString()"); //$NON-NLS-1$
- e.printStackTrace();
- }
- return buffer.toString();
- }
-
- public String toString() {
- return absolutePath();
- }
-}
diff --git a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/ExportedPreferences.java b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/ExportedPreferences.java
deleted file mode 100644
index 38d6f26b5..000000000
--- a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/ExportedPreferences.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.preferences;
-
-import org.eclipse.core.runtime.preferences.IExportedPreferences;
-
-/**
- * @since 3.0
- */
-public class ExportedPreferences extends EclipsePreferences implements IExportedPreferences {
-
- private boolean isExportRoot = false;
- private String version;
-
- public static IExportedPreferences newRoot() {
- return new ExportedPreferences(null, ""); //$NON-NLS-1$
- }
-
- protected ExportedPreferences(EclipsePreferences parent, String name) {
- super(parent, name);
- }
-
- /*
- * @see org.eclipse.core.runtime.preferences.IExportedPreferences#isExportRoot()
- */
- public boolean isExportRoot() {
- return isExportRoot;
- }
-
- /*
- * Internal method called only by the import/export mechanism.
- */
- public void setExportRoot() {
- isExportRoot = true;
- }
-
- /*
- * Internal method called only by the import/export mechanism to
- * validate bundle versions.
- */
- public String getVersion() {
- return version;
- }
-
- /*
- * Internal method called only by the import/export mechanism to
- * validate bundle versions.
- */
- public void setVersion(String version) {
- this.version = version;
- }
-
- protected EclipsePreferences internalCreate(EclipsePreferences nodeParent, String nodeName, Object context) {
- return new ExportedPreferences(nodeParent, nodeName);
- }
-
- /*
- * Return a string representation of this object. To be used for
- * debugging purposes only.
- */
- public String toString() {
- StringBuffer buffer = new StringBuffer();
- if (isExportRoot)
- buffer.append("* "); //$NON-NLS-1$
- buffer.append(absolutePath());
- if (version != null)
- buffer.append(" (" + version + ')'); //$NON-NLS-1$
- return buffer.toString();
- }
-}
diff --git a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/ILegacyPreferences.java b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/ILegacyPreferences.java
deleted file mode 100644
index 9c4ce658a..000000000
--- a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/ILegacyPreferences.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.preferences;
-
-/**
- * Provides initialization of the legacy preferences as described in
- * the Plugin class.
- *
- * @depreceated
- */
-public interface ILegacyPreferences {
- /**
- * The method tries to initialize the preferences using the legacy Plugin method.
- *
- * @param object - plugin to initialize
- * @param name - ID of the plugin to be initialized
- *
- * @see Plugin#initializeDefaultPluginPreferences
- */
- public Object init(Object object, String name);
-}
diff --git a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/IPreferencesConstants.java b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/IPreferencesConstants.java
deleted file mode 100644
index dfd4868eb..000000000
--- a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/IPreferencesConstants.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.preferences;
-
-/**
- * Container for the constants used by this plugin.
- * @since org.eclipse.equinox.preferences 1.0
- */
-public interface IPreferencesConstants {
- /**
- * Backward compatibilty: name of the original runtime plugin
- */
- public static final String RUNTIME_NAME = "org.eclipse.core.runtime"; //$NON-NLS-1$
-
- /**
- * Name of this plugin
- */
- public static final String PREFERS_NAME = "org.eclipse.equinox.preferences"; //$NON-NLS-1$
-
- /**
- * Command line options
- */
- public static final String PLUGIN_CUSTOMIZATION = "-plugincustomization"; //$NON-NLS-1$
-
- /**
- * This is the base filename used to construct the name of the preference
- * file and the name of the preference translation file.
- */
- public static final String PREFERENCES_DEFAULT_OVERRIDE_BASE_NAME = "preferences"; //$NON-NLS-1$
-
- /**
- * The name of the file (value <code>"preferences.ini"</code>) in a
- * plug-in's (read-only) directory that, when present, contains values that
- * override the normal default values for this plug-in's preferences.
- * <p>
- * The format of the file is as per <code>java.io.Properties</code> where
- * the keys are property names and values are strings.
- * </p>
- */
- public static final String PREFERENCES_DEFAULT_OVERRIDE_FILE_NAME = PREFERENCES_DEFAULT_OVERRIDE_BASE_NAME + ".ini"; //$NON-NLS-1$
-
- /**
- * The simple identifier constant (value "<code>preferences</code>") of
- * the extension point of the Core Runtime plug-in where plug-ins declare
- * extensions to the preference facility. A plug-in may define any number
- * of preference extensions.
- */
- public static final String PT_PREFERENCES = "preferences"; //$NON-NLS-1$
-
-}
diff --git a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/ImmutableMap.java b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/ImmutableMap.java
deleted file mode 100644
index 183c6951b..000000000
--- a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/ImmutableMap.java
+++ /dev/null
@@ -1,279 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.preferences;
-
-import org.eclipse.core.internal.preferences.StringPool;
-
-/**
- * Hash table of {String --> String}.
- *
- * This map handles collisions using linear probing. When elements are
- * removed, the entire table is rehashed. Thus this map has good space
- * characteristics, good insertion and iteration performance, but slower
- * removal performance than a HashMap.
- * <p>
- * This map is thread safe because it is immutable. All methods that modify
- * the map create and return a new map, rather than modifying the receiver.
- */
-public abstract class ImmutableMap implements Cloneable {
- static class ArrayMap extends ImmutableMap {
- private static final float LOAD_FACTOR = 0.45f;
- /**
- * number of elements in the table
- */
- private int elementSize;
-
- /**
- * The table keys
- */
- private String[] keyTable;
-
- private int threshold;
- private String[] valueTable;
-
- private ArrayMap() {
- this(16);
- }
-
- ArrayMap(int size) {
- this.elementSize = 0;
- //table size must always be a power of two
- int tableLen = 1;
- while (tableLen < size)
- tableLen *= 2;
- this.keyTable = new String[tableLen];
- this.valueTable = new String[tableLen];
- this.threshold = (int) (tableLen * LOAD_FACTOR);
- }
-
- public String get(String key) {
- int lengthMask = keyTable.length - 1;
- int index = key.hashCode() & lengthMask;
- String currentKey;
- while ((currentKey = keyTable[index]) != null) {
- if (currentKey.equals(key))
- return valueTable[index];
- index = (index + 1) & lengthMask;
- }
- return null;
- }
-
- /**
- * This method destructively adds the key/value pair to the table.
- * The caller must ensure the table has an empty slot before calling
- * this method.
- * @param key
- * @param value
- */
- protected void internalPut(String key, String value) {
- int lengthMask = keyTable.length - 1;
- int index = key.hashCode() & lengthMask;
- String currentKey;
- while ((currentKey = keyTable[index]) != null) {
- if (currentKey.equals(key)) {
- valueTable[index] = value;
- return;
- }
- index = (index + 1) & lengthMask;
- }
- keyTable[index] = key;
- valueTable[index] = value;
- ++elementSize;
- }
-
- /**
- * Returns an array of all keys in this map.
- */
- public String[] keys() {
- if (elementSize == 0)
- return EMPTY_STRING_ARRAY;
- String[] result = new String[elementSize];
- int next = 0;
- for (int i = 0; i < keyTable.length; i++)
- if (keyTable[i] != null)
- result[next++] = keyTable[i];
- return result;
- }
-
- public ImmutableMap put(String key, String value) {
- ArrayMap result;
- final int oldLen = keyTable.length;
- if (elementSize + 1 > threshold) {
- //rehash case
- String currentKey;
- result = new ArrayMap(oldLen * 2);
- for (int i = oldLen; --i >= 0;)
- if ((currentKey = keyTable[i]) != null)
- result.internalPut(currentKey, valueTable[i]);
- } else {
- result = new ArrayMap(oldLen);
- System.arraycopy(this.keyTable, 0, result.keyTable, 0, this.keyTable.length);
- System.arraycopy(this.valueTable, 0, result.valueTable, 0, this.valueTable.length);
- result.elementSize = this.elementSize;
- }
- result.internalPut(key, value);
- return result;
- }
-
- public ImmutableMap removeKey(String key) {
- final int lengthMask = keyTable.length - 1;
- int index = key.hashCode() & lengthMask;
- String currentKey;
- while ((currentKey = keyTable[index]) != null) {
- if (currentKey.equals(key)) {
- if (elementSize <= 1)
- return EMPTY;
- //return a new map that includes all keys except the current one
- ImmutableMap result = createMap((int) (elementSize / LOAD_FACTOR));
- for (int i = 0; i < index; i++)
- if ((currentKey = keyTable[i]) != null)
- result.internalPut(currentKey, valueTable[i]);
- for (int i = index + 1; i <= lengthMask; i++)
- if ((currentKey = keyTable[i]) != null)
- result.internalPut(currentKey, valueTable[i]);
- return result;
- }
- index = (index + 1) & lengthMask;
- }
- return this;
- }
-
- /* (non-Javadoc
- * Method declared on IStringPoolParticipant
- */
- public void shareStrings(StringPool set) {
- //copy elements for thread safety
- String[] array = keyTable;
- if (array == null)
- return;
- for (int i = 0; i < array.length; i++) {
- String o = array[i];
- if (o != null)
- array[i] = set.add(o);
- }
- array = valueTable;
- if (array == null)
- return;
- for (int i = 0; i < array.length; i++) {
- String o = array[i];
- if (o != null)
- array[i] = set.add(o);
- }
- }
-
- public int size() {
- return elementSize;
- }
-
- }
-
- static class EmptyMap extends ImmutableMap {
- public String get(String value) {
- return null;
- }
-
- public ImmutableMap removeKey(String key) {
- return this;
- }
-
- protected void internalPut(String key, String value) {
- throw new IllegalStateException();//cannot put elements in the empty map
- }
-
- public String[] keys() {
- return EMPTY_STRING_ARRAY;
- }
-
- public ImmutableMap put(String key, String value) {
- ImmutableMap result = createMap(4);
- result.internalPut(key, value);
- return result;
- }
-
- public int size() {
- return 0;
- }
- }
-
- /**
- * The empty hash map. Since instances are immutable, the empty map
- * can be a singleton, with accessor methods optimized for the empty map case.
- */
- public static final ImmutableMap EMPTY = new EmptyMap();
-
- protected static final String[] EMPTY_STRING_ARRAY = new String[0];
-
- /**
- * Returns the value associated with this key in the map, or
- * <code>null</code> if the key is not present in the map.
- * @param key
- * @return The value associated with this key, or <code>null</code>
- */
- public abstract String get(String key);
-
- protected static ImmutableMap createMap(int i) {
- if (i <= 0)
- return EMPTY;
- return new ArrayMap(i);
- }
-
- /**
- * Destructively adds a key/value pair to this map. The caller must ensure
- * there is enough room in this map to proceed.
- *
- * @param key
- * @param value
- */
- protected abstract void internalPut(String key, String value);
-
- /**
- * Returns an array of all keys in this map.
- */
- public abstract String[] keys();
-
- /**
- * Returns a new map that is equal to this one, except with the given
- * key/value pair added.
- *
- * @param key
- * @param value
- * @return The map containing the given key/value pair
- */
- public abstract ImmutableMap put(String key, String value);
-
- /**
- * Returns a map that is equal to this one, except without the given
- * key.
- * @param key
- * @return A map with the given key removed
- */
- public abstract ImmutableMap removeKey(String key);
-
- /* (non-Javadoc
- * Method declared on IStringPoolParticipant
- */
- public void shareStrings(StringPool set) {
- }
-
- /**
- * Returns the number of keys in this map.
- * @return the number of keys in this map.
- */
- public abstract int size();
-
- public String toString() {
- StringBuffer s = new StringBuffer();
- String[] keys = keys();
- for (int i = 0, length = keys.length; i < length; i++)
- s.append(keys[i]).append(" -> ").append(get(keys[i])).append("\n"); //$NON-NLS-2$ //$NON-NLS-1$
- return s.toString();
- }
-}
diff --git a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/InstancePreferences.java b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/InstancePreferences.java
deleted file mode 100644
index 333f83ff5..000000000
--- a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/InstancePreferences.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.preferences;
-
-import java.io.*;
-import java.util.*;
-import org.eclipse.core.internal.runtime.MetaDataKeeper;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.osgi.service.datalocation.Location;
-
-/**
- * @since 3.0
- */
-public class InstancePreferences extends EclipsePreferences {
-
- // cached values
- private String qualifier;
- private int segmentCount;
- private IEclipsePreferences loadLevel;
- private IPath location;
- // cache which nodes have been loaded from disk
- private static Set loadedNodes = new HashSet();
- private static boolean initialized = false;
- private static IPath baseLocation;
-
- private static IPath getBaseLocation() {
- // If we are running with -data=@none we won't have an instance location.
- // By leaving the value of baseLocation as null we still allow the users
- // to set preferences in this scope but the values will not be persisted
- // to disk when #flush() is called.
- if (baseLocation == null) {
- Location instanceLocation = PreferencesOSGiUtils.getDefault().getInstanceLocation();
- if (instanceLocation != null && (instanceLocation.isSet() || instanceLocation.allowsDefault()))
- baseLocation = MetaDataKeeper.getMetaArea().getStateLocation(IPreferencesConstants.RUNTIME_NAME);
- }
- return baseLocation;
- }
-
- /**
- * Default constructor. Should only be called by #createExecutableExtension.
- */
- public InstancePreferences() {
- this(null, null);
- }
-
- private InstancePreferences(EclipsePreferences parent, String name) {
- super(parent, name);
-
- initializeChildren();
-
- // cache the segment count
- String path = absolutePath();
- segmentCount = getSegmentCount(path);
- if (segmentCount < 2)
- return;
-
- // cache the qualifier
- qualifier = getSegment(path, 1);
-
- // don't cache the location until later in case instance prefs are
- // accessed before the instance location is set.
- }
-
- protected boolean isAlreadyLoaded(IEclipsePreferences node) {
- return loadedNodes.contains(node.name());
- }
-
- protected void loaded() {
- loadedNodes.add(name());
- }
-
- /**
- * Load the Eclipse 2.1 preferences for the given bundle. If a file
- * doesn't exist then assume that conversion has already occurred
- * and do nothing.
- */
- protected void loadLegacy() {
- IPath path = new Path(absolutePath());
- if (path.segmentCount() != 2)
- return;
- // If we are running with -data=@none we won't have an instance location.
- if (PreferencesOSGiUtils.getDefault().getInstanceLocation() == null) {
- if (EclipsePreferences.DEBUG_PREFERENCE_GENERAL)
- PrefsMessages.message("Cannot load Legacy plug-in preferences since instance location is not set."); //$NON-NLS-1$
- return;
- }
- String bundleName = path.segment(1);
- // the preferences file is located in the plug-in's state area at a well-known name
- // don't need to create the directory if there are no preferences to load
- File prefFile = null;
- Location instanceLocation = PreferencesOSGiUtils.getDefault().getInstanceLocation();
- if (instanceLocation != null && instanceLocation.isSet())
- prefFile = MetaDataKeeper.getMetaArea().getPreferenceLocation(bundleName, false).toFile();
- if (prefFile == null) {
- if (EclipsePreferences.DEBUG_PREFERENCE_GENERAL)
- PrefsMessages.message("Cannot load legacy values because instance location is not set."); //$NON-NLS-1$
- return;
- }
- if (!prefFile.exists()) {
- // no preference file - that's fine
- if (EclipsePreferences.DEBUG_PREFERENCE_GENERAL)
- PrefsMessages.message("Legacy plug-in preference file not found: " + prefFile); //$NON-NLS-1$
- return;
- }
-
- if (EclipsePreferences.DEBUG_PREFERENCE_GENERAL)
- PrefsMessages.message("Loading legacy preferences from " + prefFile); //$NON-NLS-1$
-
- // load preferences from file
- InputStream input = null;
- Properties values = new Properties();
- try {
- input = new BufferedInputStream(new FileInputStream(prefFile));
- values.load(input);
- } catch (IOException e) {
- // problems loading preference store - quietly ignore
- if (EclipsePreferences.DEBUG_PREFERENCE_GENERAL)
- PrefsMessages.message("IOException encountered loading legacy preference file " + prefFile); //$NON-NLS-1$
- return;
- } finally {
- if (input != null) {
- try {
- input.close();
- } catch (IOException e) {
- // ignore problems with close
- if (EclipsePreferences.DEBUG_PREFERENCE_GENERAL) {
- PrefsMessages.message("IOException encountered closing legacy preference file " + prefFile); //$NON-NLS-1$
- e.printStackTrace();
- }
- }
- }
- }
-
- // Store values in the preferences object
- for (Iterator i = values.keySet().iterator(); i.hasNext();) {
- String key = (String) i.next();
- String value = values.getProperty(key);
- // value shouldn't be null but check just in case...
- if (value != null) {
- if (EclipsePreferences.DEBUG_PREFERENCE_GENERAL)
- PrefsMessages.message("Loaded legacy preference: " + key + " -> " + value); //$NON-NLS-1$ //$NON-NLS-2$
- // call these 2 methods rather than #put() so we don't send out unnecessary notification
- Object oldValue = internalPut(key, value);
- if (!value.equals(oldValue))
- makeDirty();
- }
- }
-
- // Delete the old file so we don't try and load it next time.
- if (!prefFile.delete())
- //Only print out message in failure case if we are debugging.
- if (EclipsePreferences.DEBUG_PREFERENCE_GENERAL)
- PrefsMessages.message("Unable to delete legacy preferences file: " + prefFile); //$NON-NLS-1$
- }
-
- protected IPath getLocation() {
- if (location == null)
- location = computeLocation(getBaseLocation(), qualifier);
- return location;
- }
-
- /*
- * Return the node at which these preferences are loaded/saved.
- */
- protected IEclipsePreferences getLoadLevel() {
- if (loadLevel == null) {
- if (qualifier == null)
- return null;
- // Make it relative to this node rather than navigating to it from the root.
- // Walk backwards up the tree starting at this node.
- // This is important to avoid a chicken/egg thing on startup.
- IEclipsePreferences node = this;
- for (int i = 2; i < segmentCount; i++)
- node = (IEclipsePreferences) node.parent();
- loadLevel = node;
- }
- return loadLevel;
- }
-
- /*
- * Initialize the children for the root of this node. Store the names as
- * keys in the children table so we can lazily load them later.
- */
- protected void initializeChildren() {
- if (initialized || parent == null)
- return;
- try {
- synchronized (this) {
- String[] names = computeChildren(getBaseLocation());
- for (int i = 0; i < names.length; i++)
- addChild(names[i], null);
- }
- } finally {
- initialized = true;
- }
- }
-
- protected EclipsePreferences internalCreate(EclipsePreferences nodeParent, String nodeName, Object context) {
- return new InstancePreferences(nodeParent, nodeName);
- }
-}
diff --git a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/ListenerRegistry.java b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/ListenerRegistry.java
deleted file mode 100644
index 73570e935..000000000
--- a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/ListenerRegistry.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.preferences;
-
-import org.eclipse.core.runtime.ListenerList;
-
-/**
- * A class which holds onto a listener list object for a given path.
- * Typically the path is the absolute path of a preference node.
- *
- * @since 3.1
- */
-public class ListenerRegistry {
-
- /**
- * Specialized map-like data structure for storing change listeners.
- */
- private static class ListenerMap {
- private static final int GROW_SIZE = 10;
- String[] keys;
- ListenerList[] values;
-
- /**
- * Create a map of exactly the specified size.
- */
- ListenerMap(int size) {
- super();
- this.keys = new String[size];
- this.values = new ListenerList[size];
- }
-
- /**
- * Return the listener list associated with the given key,
- * or <code>null</code> if it doesn't exist.
- */
- ListenerList get(String key) {
- if (key == null)
- throw new NullPointerException();
- for (int i = 0; i < keys.length; i++)
- if (key.equals(keys[i]))
- return values[i];
- return null;
- }
-
- /**
- * Associate the given listener list with the specified key. Overwrite
- * an existing association, if applicable.
- */
- void put(String key, ListenerList value) {
- if (key == null)
- throw new NullPointerException();
- if (value == null) {
- remove(key);
- return;
- }
- // replace if exists, keeping track of an empty position
- int emptyIndex = -1;
- for (int i = 0; i < keys.length; i++) {
- String existing = keys[i];
- if (existing == null) {
- emptyIndex = i;
- continue;
- }
- if (existing.equals(key)) {
- values[i] = value;
- return;
- }
- }
- if (emptyIndex == -1)
- emptyIndex = grow();
- keys[emptyIndex] = key;
- values[emptyIndex] = value;
- }
-
- /*
- * Make the backing arrays larger
- */
- private int grow() {
- int size = keys.length;
- String[] tempKeys = new String[size + GROW_SIZE];
- System.arraycopy(keys, 0, tempKeys, 0, size);
- keys = tempKeys;
- ListenerList[] tempValues = new ListenerList[size + GROW_SIZE];
- System.arraycopy(values, 0, tempValues, 0, size);
- values = tempValues;
- return size;
- }
-
- /**
- * Remove the association specified by the given key.
- * Do nothing if none exists.
- *
- * Note: Should consider shrinking the array. Hold off for now
- * as we don't expect #remove to be a common code path.
- */
- void remove(String key) {
- if (key == null)
- throw new NullPointerException();
- for (int i = 0; i < keys.length; i++)
- if (key.equals(keys[i])) {
- keys[i] = null;
- values[i] = null;
- return;
- }
- }
- }
-
- static final Object[] EMPTY_LIST = new Object[0];
- ListenerMap registry = new ListenerMap(25);
-
- /**
- * Return the listeners for this path or an empty list if none.
- */
- public synchronized Object[] getListeners(String path) {
- ListenerList list = registry.get(path);
- return list == null ? EMPTY_LIST : list.getListeners();
- }
-
- /**
- * Add the given listener to the listeners registered for this path.
- * If the listener already exists, then do nothing.
- */
- public synchronized void add(String path, Object listener) {
- ListenerList list = registry.get(path);
- if (list == null)
- list = new ListenerList(ListenerList.IDENTITY);
- list.add(listener);
- registry.put(path, list);
- }
-
- /**
- * Remove the given listener from this path's collection of
- * listeners. If it is not associated with this path, then do nothing.
- */
- public synchronized void remove(String path, Object listener) {
- ListenerList list = registry.get(path);
- if (list == null)
- return;
- list.remove(listener);
- if (list.isEmpty())
- registry.remove(path);
- }
-
- /**
- * Remove all of the listeners registered under the given path.
- */
- public synchronized void clear(String path) {
- registry.remove(path);
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/LookupOrder.java b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/LookupOrder.java
deleted file mode 100644
index 96284d865..000000000
--- a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/LookupOrder.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.preferences;
-
-/**
- * Object used to store the look-up order for preference
- * scope searching.
- *
- * @since 3.0
- */
-public class LookupOrder {
-
- private String[] order;
-
- LookupOrder(String[] order) {
- for (int i = 0; i < order.length; i++)
- if (order[i] == null)
- throw new IllegalArgumentException();
- this.order = order;
- }
-
- public String[] getOrder() {
- return order;
- }
-}
diff --git a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/OSGiPreferencesServiceImpl.java b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/OSGiPreferencesServiceImpl.java
deleted file mode 100644
index 8a13cc0d4..000000000
--- a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/OSGiPreferencesServiceImpl.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.preferences;
-
-import java.io.File;
-import java.util.*;
-
-import org.eclipse.core.runtime.*;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.osgi.service.prefs.*;
-import org.osgi.service.prefs.Preferences;
-import org.osgi.service.prefs.PreferencesService;
-
-/**
- * <p>
- * Implements OSGi PreferencesService using the Eclipse preference system.
- * </p>
- *
- * <p>
- * Note: Eclipse preferences are not accessible through the OSGi Preferences API and vice
- * versa.
- * </p>
- */
-public class OSGiPreferencesServiceImpl implements PreferencesService {
-
- /**
- * Adaptor that implements OSGi Preferences interface on top of EclipsePreferences.
- *
- */
- private static final class OSGiPreferences extends EclipsePreferences implements Preferences {
-
- private IPath location;
- private IEclipsePreferences loadLevel;
- private OSGiPreferencesServiceImpl prefsServiceImpl;
-
- private OSGiPreferences(File prefsDir, OSGiPreferencesServiceImpl prefsServiceImpl) {
- super(null, ""); //$NON-NLS-1$
- this.prefsServiceImpl = prefsServiceImpl;
- this.location = new Path(prefsDir.getPath());
- this.loadLevel = this;
- }
-
- private OSGiPreferences(EclipsePreferences nodeParent, String nodeName, OSGiPreferencesServiceImpl prefsServiceImpl) {
- super(nodeParent, nodeName);
- this.loadLevel = nodeParent.getLoadLevel();
- this.prefsServiceImpl = prefsServiceImpl;
- }
-
- protected EclipsePreferences internalCreate(EclipsePreferences nodeParent, String nodeName, Object context) {
- return new OSGiPreferences(nodeParent, nodeName, prefsServiceImpl);
- }
-
- protected IPath getLocation() {
- return location;
- }
-
- protected IEclipsePreferences getLoadLevel() {
- return loadLevel;
- }
-
- /**
- * Override node(String pathName) to be more strict about forbidden names -
- * EclipsePreferences implementation does a best-effort instead of throwing
- * {@link IllegalArgumentException}.
- */
- public Preferences node(String pathName) {
- if ((pathName.length() > 1 && pathName.endsWith("/")) //$NON-NLS-1$
- || pathName.indexOf("//") != -1) { //$NON-NLS-1$
- throw new IllegalArgumentException();
- }
- return super.node(pathName);
- }
-
- /**
- * Override removeNode() to allow removal of root nodes. EclipsePreferences ignores
- * attempts to remove the root node, but in OSGi Preferences there are many root nodes
- * and removal is permitted.
- */
- public void removeNode() throws BackingStoreException {
- if (parent() == null) {
- flush();
- if (this == prefsServiceImpl.systemPreferences) {
- prefsServiceImpl.systemPreferences = null;
- } else {
- prefsServiceImpl.userPreferences.values().remove(this);
- }
- }
-
- super.removeNode();
- removed = true;
- }
-
- /**
- * <p>
- * Override getByteArray(String key, byte [] defaultValue) to be more strict when
- * decoding byte values. EclipsePreferences implementation pads bytes if they are not 4
- * bytes long, but the OSGi TCK expects this function to return null if the length of
- * the byte array is not an even multiple of 4.
- * </p>
- * <p>
- * Also catches any decoding exceptions and returns the default value instead of
- * propagating the exception.
- * </p>
- */
- public byte[] getByteArray(String key, byte[] defaultValue) {
- String value = internalGet(key);
- byte[] byteArray = null;
- if (value != null) {
- byte[] encodedBytes = value.getBytes();
- if (encodedBytes.length % 4 == 0) {
- try {
- byteArray = Base64.decode(encodedBytes);
- } catch (Exception e) {
- //do not raise exception - return defaultValue
- }
- }
- }
- return byteArray == null ? defaultValue : byteArray;
- }
-
- }
-
- private File systemPrefsDir;
- private File userPrefsDir;
-
- Preferences systemPreferences;
-
- //Map of String user name -> Preferences
- Map userPreferences;
-
- OSGiPreferencesServiceImpl(File prefsLocation) {
- systemPrefsDir = new File(prefsLocation, "system"); //$NON-NLS-1$
- userPrefsDir = new File(prefsLocation, "user"); //$NON-NLS-1$
- userPreferences = new TreeMap(); //use TreeMap since keys are strings
- }
-
- public Preferences getSystemPreferences() {
- if (systemPreferences == null) {
- systemPreferences = new OSGiPreferences(systemPrefsDir, this);
- try {
- systemPreferences.sync();
- } catch (BackingStoreException e) {
- //nothing
- }
- }
- return systemPreferences;
- }
-
- public Preferences getUserPreferences(String name) {
- Preferences userPref = (Preferences) userPreferences.get(name);
- if (userPref == null) {
- userPref = new OSGiPreferences(new File(userPrefsDir, name), this);
- try {
- userPref.sync();
- } catch (BackingStoreException e) {
- //nothing
- }
- userPreferences.put(name, userPref);
- }
- return userPref;
- }
-
- public String[] getUsers() {
- return userPrefsDir.list();
- }
-
- /**
- * Called when Bundle ungets Preferences Service - flushes all preferences to disk.
- */
- void destroy() {
- try {
- if (systemPreferences != null && systemPreferences.nodeExists("")) { //$NON-NLS-1$
- systemPreferences.flush();
- }
- } catch (BackingStoreException e) {
- //nothing
- }
- Iterator it = userPreferences.values().iterator();
- while (it.hasNext()) {
- Preferences userPreference = (Preferences) it.next();
- try {
- if (userPreference.nodeExists("")) { //$NON-NLS-1$
- userPreference.flush();
- }
- } catch (BackingStoreException e) {
- //nothing
- }
- }
-
- }
-}
diff --git a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/OSGiPreferencesServiceManager.java b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/OSGiPreferencesServiceManager.java
deleted file mode 100644
index 770e86c39..000000000
--- a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/OSGiPreferencesServiceManager.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.preferences;
-
-import java.io.File;
-import java.util.Set;
-import java.util.TreeSet;
-
-import org.osgi.framework.*;
-
-/**
- * <p>
- * Class used to manage OSGi Preferences Service. Creates a new OSGiPreferencesServiceImpl
- * object for every bundle that gets the Preferences Service. When a bundle ungets the
- * Preference Service, it's preferences are flushed to disk.
- * </p>
- * <p>
- * Also deletes saved preferences for bundles which are uninstalled.
- * </p>
- * <p>
- * Preferences are saved in the Bundle Data area under the directory "OSGiPreferences".
- * </p>
- */
-public class OSGiPreferencesServiceManager implements ServiceFactory, BundleListener {
-
- private static final String OSGI_PREFS_DIR = "OSGiPreferences"; //$NON-NLS-1$
-
- private File prefsDir;
-
- public OSGiPreferencesServiceManager(BundleContext context) {
-
- prefsDir = context.getDataFile(OSGI_PREFS_DIR);
-
- context.addBundleListener(this);
-
- //clean up prefs for bundles that have been uninstalled
- Bundle[] allBundles = context.getBundles();
- Set bundleDirNames = new TreeSet();
- for (int i = 0; i < allBundles.length; i++) {
- bundleDirNames.add(getBundleDirName(allBundles[i]));
- }
- File[] prefsNodeDirs = prefsDir.listFiles();
- prefsNodeDirs = prefsNodeDirs == null ? new File[0] : prefsNodeDirs;
-
- for (int i = 0; i < prefsNodeDirs.length; i++) {
- if (!bundleDirNames.contains(prefsNodeDirs[i].getName())) {
- rmdir(prefsNodeDirs[i]);
- }
-
- }
- }
-
- /**
- * Recursively remove a file or a directory and all of it's children.
- */
- private void rmdir(File file) {
- if (!file.exists()) {
- return;
- }
- if (file.isDirectory()) {
- File[] children = file.listFiles();
-
- for (int i = 0; i < children.length; i++) {
- rmdir(children[i]);
- }
- }
- file.delete();
- }
-
- /**
- * Bundle Preferences are saves in a directory with the same name as the bundle's
- * symbolic id. For backwards compatibility, preferences for bundles that do not
- * have a symbolic id are saved in a directory named
- * 'org.eclipse.core.internal.preferences.OSGiPreferences.bundleid.&lt;bundle id&gt;'.
- */
- private String getBundleDirName(Bundle bundle) {
- String bundleDirName = bundle.getSymbolicName();
-
- //backwards compatibility - if bundle does not have symbolic name
- if (bundleDirName == null) {
- bundleDirName = "org.eclipse.core.internal.preferences.OSGiPreferences.bundleid." + bundle.getBundleId(); //$NON-NLS-1$
- }
- return bundleDirName;
- }
-
- /**
- * Creates a new OSGiPreferencesServiceImpl for each bundle.
- */
- public Object getService(Bundle bundle, ServiceRegistration registration) {
- return new OSGiPreferencesServiceImpl(new File(prefsDir, getBundleDirName(bundle)));
- }
-
- /**
- * Flush the bundle's preferences to disk.
- */
- public void ungetService(Bundle bundle, ServiceRegistration registration, Object service) {
- ((OSGiPreferencesServiceImpl) service).destroy();
- }
-
- /**
- * If a bundle is uninstalled, delete all of it's preferences from the disk.
- */
- public void bundleChanged(BundleEvent event) {
- if (event.getType() == BundleEvent.UNINSTALLED) {
- File bundlePrefs = new File(prefsDir, getBundleDirName(event.getBundle()));
- rmdir(bundlePrefs);
- }
-
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/PreferencesOSGiUtils.java b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/PreferencesOSGiUtils.java
deleted file mode 100644
index fcc8d5262..000000000
--- a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/PreferencesOSGiUtils.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.preferences;
-
-import org.eclipse.osgi.framework.log.FrameworkLog;
-import org.eclipse.osgi.service.datalocation.Location;
-import org.eclipse.osgi.service.debug.DebugOptions;
-import org.osgi.framework.*;
-import org.osgi.service.packageadmin.PackageAdmin;
-import org.osgi.util.tracker.ServiceTracker;
-
-/**
- * This class contains a set of helper OSGI methods for the Preferences plugin.
- * The closeServices() method should be called before the plugin is stopped.
- *
- * @since org.eclipse.equinox.preferences 1.0
- */
-public class PreferencesOSGiUtils {
- private ServiceTracker logTracker = null;
- private ServiceTracker initTracker = null;
- private ServiceTracker debugTracker = null;
- private ServiceTracker bundleTracker = null;
- private ServiceTracker configurationLocationTracker = null;
- private ServiceTracker instanceLocationTracker = null;
-
- // OSGI system properties. Copied from EclipseStarter
- public static final String PROP_CONFIG_AREA = "osgi.configuration.area"; //$NON-NLS-1$
- public static final String PROP_INSTANCE_AREA = "osgi.instance.area"; //$NON-NLS-1$
-
- private static final PreferencesOSGiUtils singleton = new PreferencesOSGiUtils();
-
- public static PreferencesOSGiUtils getDefault() {
- return singleton;
- }
-
- /**
- * Private constructor to block instance creation.
- */
- private PreferencesOSGiUtils() {
- super();
- }
-
- void openServices() {
- BundleContext context = Activator.getContext();
- if (context == null) {
- PrefsMessages.message("PreferencesOSGiUtils called before plugin started"); //$NON-NLS-1$
- return;
- }
-
- initTracker = new ServiceTracker(context, ILegacyPreferences.class.getName(), null);
- initTracker.open(true);
-
- logTracker = new ServiceTracker(context, FrameworkLog.class.getName(), null);
- logTracker.open();
-
- debugTracker = new ServiceTracker(context, DebugOptions.class.getName(), null);
- debugTracker.open();
-
- bundleTracker = new ServiceTracker(context, PackageAdmin.class.getName(), null);
- bundleTracker.open();
-
- // locations
-
- Filter filter = null;
- try {
- filter = context.createFilter(Location.CONFIGURATION_FILTER);
- } catch (InvalidSyntaxException e) {
- // ignore this. It should never happen as we have tested the above format.
- }
- configurationLocationTracker = new ServiceTracker(context, filter, null);
- configurationLocationTracker.open();
-
- try {
- filter = context.createFilter(Location.INSTANCE_FILTER);
- } catch (InvalidSyntaxException e) {
- // ignore this. It should never happen as we have tested the above format.
- }
- instanceLocationTracker = new ServiceTracker(context, filter, null);
- instanceLocationTracker.open();
- }
-
- void closeServices() {
- if (initTracker != null) {
- initTracker.close();
- initTracker = null;
- }
- if (logTracker != null) {
- logTracker.close();
- logTracker = null;
- }
- if (debugTracker != null) {
- debugTracker.close();
- debugTracker = null;
- }
- if (bundleTracker != null) {
- bundleTracker.close();
- bundleTracker = null;
- }
- if (configurationLocationTracker != null) {
- configurationLocationTracker.close();
- configurationLocationTracker = null;
- }
- if (instanceLocationTracker != null) {
- instanceLocationTracker.close();
- instanceLocationTracker = null;
- }
- }
-
- public ILegacyPreferences getLegacyPreferences() {
- if (initTracker != null)
- return (ILegacyPreferences) initTracker.getService();
- PrefsMessages.message("Legacy preference tracker is not set"); //$NON-NLS-1$
- return null;
- }
-
- public FrameworkLog getFrameworkLog() {
- if (logTracker != null)
- return (FrameworkLog) logTracker.getService();
- PrefsMessages.message("Log tracker is not set"); //$NON-NLS-1$
- return null;
- }
-
- public boolean getBooleanDebugOption(String option, boolean defaultValue) {
- if (debugTracker == null) {
- PrefsMessages.message("Debug tracker is not set"); //$NON-NLS-1$
- return defaultValue;
- }
- DebugOptions options = (DebugOptions) debugTracker.getService();
- if (options != null) {
- String value = options.getOption(option);
- if (value != null)
- return value.equalsIgnoreCase("true"); //$NON-NLS-1$
- }
- return defaultValue;
- }
-
- public Bundle getBundle(String bundleName) {
- if (bundleTracker == null) {
- PrefsMessages.message("Bundle tracker is not set"); //$NON-NLS-1$
- return null;
- }
- PackageAdmin packageAdmin = (PackageAdmin) bundleTracker.getService();
- if (packageAdmin == null)
- return null;
- Bundle[] bundles = packageAdmin.getBundles(bundleName, null);
- if (bundles == null)
- return null;
- //Return the first bundle that is not installed or uninstalled
- for (int i = 0; i < bundles.length; i++) {
- if ((bundles[i].getState() & (Bundle.INSTALLED | Bundle.UNINSTALLED)) == 0) {
- return bundles[i];
- }
- }
- return null;
- }
-
- public Location getConfigurationLocation() {
- if (configurationLocationTracker != null)
- return (Location) configurationLocationTracker.getService();
- else
- return null;
- }
-
- public Location getInstanceLocation() {
- if (instanceLocationTracker != null)
- return (Location) instanceLocationTracker.getService();
- else
- return null;
- }
-}
diff --git a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/PreferencesService.java b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/PreferencesService.java
deleted file mode 100644
index 544871ce8..000000000
--- a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/PreferencesService.java
+++ /dev/null
@@ -1,1153 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.preferences;
-
-import java.io.*;
-import java.util.*;
-import org.eclipse.core.internal.runtime.RuntimeLog;
-import org.eclipse.core.runtime.*;
-import org.eclipse.core.runtime.preferences.*;
-import org.eclipse.osgi.util.NLS;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.Constants;
-import org.osgi.service.prefs.BackingStoreException;
-import org.osgi.service.prefs.Preferences;
-
-/**
- * @since 3.0
- */
-public class PreferencesService implements IPreferencesService, IRegistryChangeListener {
-
- /**
- * The interval between passes over the preference tree to canonicalize
- * strings.
- */
- private static final long STRING_SHARING_INTERVAL = 300000;
-
- // cheat here and add "project" even though we really shouldn't know about it
- // because of plug-in dependancies and it being defined in the resources plug-in
- private static final String[] DEFAULT_DEFAULT_LOOKUP_ORDER = new String[] {"project", //$NON-NLS-1$
- InstanceScope.SCOPE, //
- ConfigurationScope.SCOPE, //
- DefaultScope.SCOPE};
- private static final char EXPORT_ROOT_PREFIX = '!';
- private static final char BUNDLE_VERSION_PREFIX = '@';
- private static final float EXPORT_VERSION = 3;
- private static final String VERSION_KEY = "file_export_version"; //$NON-NLS-1$
- private static final String ATTRIBUTE_NAME = "name"; //$NON-NLS-1$
- private static final String ATTRIBUTE_CLASS = "class"; //$NON-NLS-1$
- private static final String ELEMENT_SCOPE = "scope"; //$NON-NLS-1$
- private static final String ELEMENT_MODIFIER = "modifier"; //$NON-NLS-1$
- private static final String EMPTY_STRING = ""; //$NON-NLS-1$
-
- private static PreferencesService instance;
- static final RootPreferences root = new RootPreferences();
- private static final Map defaultsRegistry = Collections.synchronizedMap(new HashMap());
- private static final Map scopeRegistry = Collections.synchronizedMap(new HashMap());
- private ListenerList modifyListeners;
- /**
- * The last time analysis was done to remove duplicate strings
- */
- private long lastStringSharing = 0;
-
- /*
- * Create and return an IStatus object with ERROR severity and the
- * given message and exception.
- */
- private static IStatus createStatusError(String message, Exception e) {
- return new Status(IStatus.ERROR, PrefsMessages.OWNER_NAME, IStatus.ERROR, message, e);
- }
-
- /*
- * Create and return an IStatus object with WARNING severity and the
- * given message and exception.
- */
- private static IStatus createStatusWarning(String message, Exception e) {
- return new Status(IStatus.WARNING, PrefsMessages.OWNER_NAME, IStatus.WARNING, message, e);
- }
-
- /*
- * Return the instance.
- */
- public static PreferencesService getDefault() {
- if (instance == null)
- instance = new PreferencesService();
- return instance;
- }
-
- /**
- * See who is plugged into the extension point.
- */
- private void initializeScopes() {
- IExtension[] extensions = getPrefExtensions();
- for (int i = 0; i < extensions.length; i++) {
- IConfigurationElement[] elements = extensions[i].getConfigurationElements();
- for (int j = 0; j < elements.length; j++)
- if (ELEMENT_SCOPE.equalsIgnoreCase(elements[j].getName()))
- scopeAdded(elements[j]);
- }
- RegistryFactory.getRegistry().addRegistryChangeListener(this, IPreferencesConstants.RUNTIME_NAME);
- RegistryFactory.getRegistry().addRegistryChangeListener(this, IPreferencesConstants.PREFERS_NAME);
- }
-
- private void initializeModifyListeners() {
- modifyListeners = new ListenerList();
- IExtension[] extensions = getPrefExtensions();
- for (int i = 0; i < extensions.length; i++) {
- IConfigurationElement[] elements = extensions[i].getConfigurationElements();
- for (int j = 0; j < elements.length; j++)
- if (ELEMENT_MODIFIER.equalsIgnoreCase(elements[j].getName()))
- addModifyListener(elements[j]);
- }
- RegistryFactory.getRegistry().addRegistryChangeListener(this, IPreferencesConstants.RUNTIME_NAME);
- RegistryFactory.getRegistry().addRegistryChangeListener(this, IPreferencesConstants.PREFERS_NAME);
- }
-
- static void log(IStatus status) {
- RuntimeLog.log(status);
- }
-
- /*
- * Abstracted into a separate method to prepare for dynamic awareness.
- */
- static void scopeAdded(IConfigurationElement element) {
- String key = element.getAttribute(ATTRIBUTE_NAME);
- if (key == null) {
- String message = NLS.bind(PrefsMessages.preferences_missingScopeAttribute, element.getDeclaringExtension().getUniqueIdentifier());
- log(createStatusWarning(message, null));
- return;
- }
- scopeRegistry.put(key, element);
- root.addChild(key, null);
- }
-
- /*
- * Abstracted into a separate method to prepare for dynamic awareness.
- */
- private void addModifyListener(IConfigurationElement element) {
- String key = element.getAttribute(ATTRIBUTE_CLASS);
- if (key == null) {
- String message = NLS.bind(PrefsMessages.preferences_missingClassAttribute, element.getDeclaringExtension().getUniqueIdentifier());
- log(new Status(IStatus.ERROR, PrefsMessages.OWNER_NAME, IStatus.ERROR, message, null));
- return;
- }
- try {
- Object listener = element.createExecutableExtension(ATTRIBUTE_CLASS);
- if (!(listener instanceof PreferenceModifyListener)) {
- log(new Status(IStatus.ERROR, PrefsMessages.OWNER_NAME, IStatus.ERROR, PrefsMessages.preferences_classCastListener, null));
- return;
- }
- modifyListeners.add(listener);
- } catch (CoreException e) {
- log(e.getStatus());
- return;
- }
- }
-
- /*
- * Abstracted into a separate method to prepare for dynamic awareness.
- */
- static void scopeRemoved(String key) {
- IEclipsePreferences node = (IEclipsePreferences) root.getNode(key, false);
- if (node != null)
- root.removeNode(node);
- else
- root.removeNode(key);
- scopeRegistry.remove(key);
- }
-
- private PreferencesService() {
- super();
- initializeScopes();
- }
-
- /*
- * @see org.eclipse.core.runtime.preferences.IPreferencesService#applyPreferences(org.eclipse.core.runtime.preferences.IExportedPreferences)
- */
- public IStatus applyPreferences(IExportedPreferences preferences) throws CoreException {
- // TODO investigate refactoring to merge with new #apply(IEclipsePreferences, IPreferenceFilter[]) APIs
- if (preferences == null)
- throw new IllegalArgumentException();
-
- if (EclipsePreferences.DEBUG_PREFERENCE_GENERAL)
- PrefsMessages.message("Applying exported preferences: " + ((ExportedPreferences) preferences).toDeepDebugString()); //$NON-NLS-1$
-
- final MultiStatus result = new MultiStatus(PrefsMessages.OWNER_NAME, IStatus.OK, PrefsMessages.preferences_applyProblems, null);
-
- IEclipsePreferences modifiedNode = firePreApplyEvent(preferences);
-
- // create a visitor to apply the given set of preferences
- IPreferenceNodeVisitor visitor = new IPreferenceNodeVisitor() {
- public boolean visit(IEclipsePreferences node) throws BackingStoreException {
- IEclipsePreferences globalNode;
- if (node.parent() == null)
- globalNode = root;
- else
- globalNode = (IEclipsePreferences) root.node(node.absolutePath());
- ExportedPreferences epNode = (ExportedPreferences) node;
-
- // if this node is an export root then we need to remove
- // it from the global preferences before continuing.
- boolean removed = false;
- if (epNode.isExportRoot()) {
- if (EclipsePreferences.DEBUG_PREFERENCE_GENERAL)
- PrefsMessages.message("Found export root: " + epNode.absolutePath()); //$NON-NLS-1$
- // TODO should only have to do this if any of my children have properties to set
- globalNode.removeNode();
- removed = true;
- }
-
- // iterate over the preferences in this node and set them
- // in the global space.
- String[] keys = epNode.properties.keys();
- if (keys.length > 0) {
- // if this node was removed then we need to create a new one
- if (removed)
- globalNode = (IEclipsePreferences) root.node(node.absolutePath());
- for (int i = 0; i < keys.length; i++) {
- String key = keys[i];
- // intern strings we import because some people
- // in their property change listeners use identity
- // instead of equals. See bug 20193 and 20534.
- key = key.intern();
- String value = node.get(key, null);
- if (value != null) {
- if (EclipsePreferences.DEBUG_PREFERENCE_SET)
- PrefsMessages.message("Setting: " + globalNode.absolutePath() + '/' + key + '=' + value); //$NON-NLS-1$
- globalNode.put(key, value);
- }
- }
- }
-
- // keep visiting children
- return true;
- }
- };
-
- try {
- // start by visiting the root
- modifiedNode.accept(visitor);
- } catch (BackingStoreException e) {
- throw new CoreException(createStatusError(PrefsMessages.preferences_applyProblems, e));
- }
-
- // save the prefs
- try {
- getRootNode().node(modifiedNode.absolutePath()).flush();
- } catch (BackingStoreException e) {
- throw new CoreException(createStatusError(PrefsMessages.preferences_saveProblems, e));
- }
-
- if (EclipsePreferences.DEBUG_PREFERENCE_GENERAL)
- PrefsMessages.message("Current list of all settings: " + ((EclipsePreferences) getRootNode()).toDeepDebugString()); //$NON-NLS-1$
- //this typically causes a major change to the preference tree, so force string sharing
- lastStringSharing = 0;
- shareStrings();
- return result;
- }
-
- /*
- * Convert the given properties file from legacy format to
- * one which is Eclipse 3.0 compliant.
- *
- * Convert the plug-in version indicator entries to export roots.
- */
- private Properties convertFromLegacy(Properties properties) {
- Properties result = new Properties();
- String prefix = IPath.SEPARATOR + InstanceScope.SCOPE + IPath.SEPARATOR;
- for (Iterator i = properties.keySet().iterator(); i.hasNext();) {
- String key = (String) i.next();
- String value = properties.getProperty(key);
- if (value != null) {
- int index = key.indexOf(IPath.SEPARATOR);
- if (index == -1) {
- result.put(BUNDLE_VERSION_PREFIX + key, value);
- result.put(EXPORT_ROOT_PREFIX + prefix + key, EMPTY_STRING);
- } else {
- String path = key.substring(0, index);
- key = key.substring(index + 1);
- result.put(EclipsePreferences.encodePath(prefix + path, key), value);
- }
- }
- }
- return result;
- }
-
- /*
- * Convert the given properties file into a node hierarchy suitable for
- * importing.
- */
- private IExportedPreferences convertFromProperties(Properties properties) {
- IExportedPreferences result = ExportedPreferences.newRoot();
- for (Iterator i = properties.keySet().iterator(); i.hasNext();) {
- String path = (String) i.next();
- String value = properties.getProperty(path);
- if (path.charAt(0) == EXPORT_ROOT_PREFIX) {
- ExportedPreferences current = (ExportedPreferences) result.node(path.substring(1));
- current.setExportRoot();
- } else if (path.charAt(0) == BUNDLE_VERSION_PREFIX) {
- ExportedPreferences current = (ExportedPreferences) result.node(InstanceScope.SCOPE).node(path.substring(1));
- current.setVersion(value);
- } else {
- String[] decoded = EclipsePreferences.decodePath(path);
- path = decoded[0] == null ? EMPTY_STRING : decoded[0];
- ExportedPreferences current = (ExportedPreferences) result.node(path);
- String key = decoded[1];
- current.put(key, value);
- }
- }
- if (EclipsePreferences.DEBUG_PREFERENCE_GENERAL)
- PrefsMessages.message("Converted preferences file to IExportedPreferences tree: " + ((ExportedPreferences) result).toDeepDebugString()); //$NON-NLS-1$
- return result;
- }
-
- /*
- * Return the string which is the scope for the given path.
- * Return the empty string if it cannot be determined.
- */
- String getScope(String path) {
- if (path == null || path.length() == 0)
- return EMPTY_STRING;
- int startIndex = path.indexOf(IPath.SEPARATOR);
- if (startIndex == -1)
- return path;
- if (path.length() == 1)
- return EMPTY_STRING;
- int endIndex = path.indexOf(IPath.SEPARATOR, startIndex + 1);
- if (endIndex == -1)
- endIndex = path.length();
- return path.substring(startIndex + 1, endIndex);
- }
-
- /*
- * excludesList is guarenteed not to be null
- */
- private Properties convertToProperties(IEclipsePreferences preferences, final String[] excludesList) throws BackingStoreException {
- final Properties result = new Properties();
- final int baseLength = preferences.absolutePath().length();
-
- // create a visitor to do the export
- IPreferenceNodeVisitor visitor = new IPreferenceNodeVisitor() {
- public boolean visit(IEclipsePreferences node) throws BackingStoreException {
- // don't store defaults
- String absolutePath = node.absolutePath();
- String scope = getScope(absolutePath);
- if (DefaultScope.SCOPE.equals(scope))
- return false;
- String path = absolutePath.length() <= baseLength ? EMPTY_STRING : EclipsePreferences.makeRelative(absolutePath.substring(baseLength));
- // check the excludes list to see if this node should be considered
- for (int i = 0; i < excludesList.length; i++) {
- String exclusion = EclipsePreferences.makeRelative(excludesList[i]);
- if (path.startsWith(exclusion))
- return false;
- }
- boolean needToAddVersion = InstanceScope.SCOPE.equals(scope);
- // check the excludes list for each preference
- String[] keys = node.keys();
- for (int i = 0; i < keys.length; i++) {
- String key = keys[i];
- boolean ignore = false;
- for (int j = 0; !ignore && j < excludesList.length; j++)
- if (EclipsePreferences.encodePath(path, key).startsWith(EclipsePreferences.makeRelative(excludesList[j])))
- ignore = true;
- if (!ignore) {
- String value = node.get(key, null);
- if (value != null) {
- if (needToAddVersion) {
- String bundle = getBundleName(absolutePath);
- if (bundle != null) {
- String version = getBundleVersion(bundle);
- if (version != null)
- result.put(BUNDLE_VERSION_PREFIX + bundle, version);
- }
- needToAddVersion = false;
- }
- result.put(EclipsePreferences.encodePath(absolutePath, key), value);
- }
- }
- }
- return true;
- }
- };
-
- // start by visiting the root that we were passed in
- preferences.accept(visitor);
-
- // return the properties object
- return result;
- }
-
- protected IEclipsePreferences createNode(String name) {
- IScope scope = null;
- Object value = scopeRegistry.get(name);
- if (value instanceof IConfigurationElement) {
- try {
- scope = (IScope) ((IConfigurationElement) value).createExecutableExtension(ATTRIBUTE_CLASS);
- scopeRegistry.put(name, scope);
- } catch (ClassCastException e) {
- log(createStatusError(PrefsMessages.preferences_classCastScope, e));
- return new EclipsePreferences(root, name);
- } catch (CoreException e) {
- log(e.getStatus());
- return new EclipsePreferences(root, name);
- }
- } else
- scope = (IScope) value;
- return scope.create(root, name);
- }
-
- /*
- * @see org.eclipse.core.runtime.preferences.IPreferencesService#exportPreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences, java.io.OutputStream, java.lang.String[])
- */
- public IStatus exportPreferences(IEclipsePreferences node, OutputStream output, String[] excludesList) throws CoreException {
- // TODO investigate refactoring to merge with new #export(IEclipsePreferences, IPreferenceFilter[]) APIs
- if (node == null || output == null)
- throw new IllegalArgumentException();
- Properties properties = null;
- if (excludesList == null)
- excludesList = new String[0];
- try {
- properties = convertToProperties(node, excludesList);
- if (properties.isEmpty())
- return Status.OK_STATUS;
- properties.put(VERSION_KEY, Float.toString(EXPORT_VERSION));
- properties.put(EXPORT_ROOT_PREFIX + node.absolutePath(), EMPTY_STRING);
- } catch (BackingStoreException e) {
- throw new CoreException(createStatusError(e.getMessage(), e));
- }
- try {
- properties.store(output, null);
- } catch (IOException e) {
- throw new CoreException(createStatusError(PrefsMessages.preferences_exportProblems, e));
- }
- return Status.OK_STATUS;
- }
-
- /*
- * @see org.eclipse.core.runtime.preferences.IPreferencesService#get(java.lang.String, java.lang.String, org.osgi.service.prefs.Preferences[])
- */
- public String get(String key, String defaultValue, Preferences[] nodes) {
- if (nodes == null)
- return defaultValue;
- for (int i = 0; i < nodes.length; i++) {
- Preferences node = nodes[i];
- if (node != null) {
- String result = node.get(key, null);
- if (result != null)
- return result;
- }
- }
- return defaultValue;
- }
-
- /*
- * @see org.eclipse.core.runtime.preferences.IPreferencesService#getBoolean(java.lang.String, java.lang.String, boolean, org.eclipse.core.runtime.preferences.IScope[])
- */
- public boolean getBoolean(String qualifier, String key, boolean defaultValue, IScopeContext[] scopes) {
- String result = get(EclipsePreferences.decodePath(key)[1], null, getNodes(qualifier, key, scopes));
- return result == null ? defaultValue : Boolean.valueOf(result).booleanValue();
- }
-
- /*
- * Return the version for the bundle with the given name. Return null if it
- * is not known or there is a problem.
- */
- String getBundleVersion(String bundleName) {
- Bundle bundle = PreferencesOSGiUtils.getDefault().getBundle(bundleName);
- if (bundle != null) {
- Object version = bundle.getHeaders(EMPTY_STRING).get(Constants.BUNDLE_VERSION);
- if (version != null && version instanceof String)
- return (String) version;
- }
- return null;
- }
-
- /*
- * Return the name of the bundle from the given path.
- * It is assumed that that path is:
- * - absolute
- * - in the instance scope
- */
- String getBundleName(String path) {
- if (path.length() == 0 || path.charAt(0) != IPath.SEPARATOR)
- return null;
- int first = path.indexOf(IPath.SEPARATOR, 1);
- if (first == -1)
- return null;
- int second = path.indexOf(IPath.SEPARATOR, first + 1);
- return second == -1 ? path.substring(first + 1) : path.substring(first + 1, second);
- }
-
- /*
- * @see org.eclipse.core.runtime.preferences.IPreferencesService#getByteArray(java.lang.String, java.lang.String, byte[], org.eclipse.core.runtime.preferences.IScope[])
- */
- public byte[] getByteArray(String qualifier, String key, byte[] defaultValue, IScopeContext[] scopes) {
- String result = get(EclipsePreferences.decodePath(key)[1], null, getNodes(qualifier, key, scopes));
- return result == null ? defaultValue : result.getBytes();
- }
-
- /*
- * @see org.eclipse.core.runtime.preferences.IPreferencesService#getDefaultLookupOrder(java.lang.String, java.lang.String)
- */
- public String[] getDefaultLookupOrder(String qualifier, String key) {
- LookupOrder order = (LookupOrder) defaultsRegistry.get(getRegistryKey(qualifier, key));
- return order == null ? null : order.getOrder();
- }
-
- /*
- * @see org.eclipse.core.runtime.preferences.IPreferencesService#getDouble(java.lang.String, java.lang.String, double, org.eclipse.core.runtime.preferences.IScope[])
- */
- public double getDouble(String qualifier, String key, double defaultValue, IScopeContext[] scopes) {
- String value = get(EclipsePreferences.decodePath(key)[1], null, getNodes(qualifier, key, scopes));
- if (value == null)
- return defaultValue;
- try {
- return Double.parseDouble(value);
- } catch (NumberFormatException e) {
- return defaultValue;
- }
- }
-
- /*
- * @see org.eclipse.core.runtime.preferences.IPreferencesService#getFloat(java.lang.String, java.lang.String, float, org.eclipse.core.runtime.preferences.IScope[])
- */
- public float getFloat(String qualifier, String key, float defaultValue, IScopeContext[] scopes) {
- String value = get(EclipsePreferences.decodePath(key)[1], null, getNodes(qualifier, key, scopes));
- if (value == null)
- return defaultValue;
- try {
- return Float.parseFloat(value);
- } catch (NumberFormatException e) {
- return defaultValue;
- }
- }
-
- /*
- * @see org.eclipse.core.runtime.preferences.IPreferencesService#getInt(java.lang.String, java.lang.String, int, org.eclipse.core.runtime.preferences.IScope[])
- */
- public int getInt(String qualifier, String key, int defaultValue, IScopeContext[] scopes) {
- String value = get(EclipsePreferences.decodePath(key)[1], null, getNodes(qualifier, key, scopes));
- if (value == null)
- return defaultValue;
- try {
- return Integer.parseInt(value);
- } catch (NumberFormatException e) {
- return defaultValue;
- }
- }
-
- /*
- * @see org.eclipse.core.runtime.preferences.IPreferencesService#getLong(java.lang.String, java.lang.String, long, org.eclipse.core.runtime.preferences.IScope[])
- */
- public long getLong(String qualifier, String key, long defaultValue, IScopeContext[] scopes) {
- String value = get(EclipsePreferences.decodePath(key)[1], null, getNodes(qualifier, key, scopes));
- if (value == null)
- return defaultValue;
- try {
- return Long.parseLong(value);
- } catch (NumberFormatException e) {
- return defaultValue;
- }
- }
-
- /*
- * @see org.eclipse.core.runtime.preferences.IPreferencesService#getLookupOrder(java.lang.String, java.lang.String)
- */
- public String[] getLookupOrder(String qualifier, String key) {
- String[] order = getDefaultLookupOrder(qualifier, key);
- // if there wasn't an exact match based on both qualifier and simple name
- // then do a lookup based only on the qualifier
- if (order == null && key != null)
- order = getDefaultLookupOrder(qualifier, null);
- if (order == null)
- order = DEFAULT_DEFAULT_LOOKUP_ORDER;
- return order;
- }
-
- private Preferences[] getNodes(String qualifier, String key, IScopeContext[] contexts) {
- String[] order = getLookupOrder(qualifier, key);
- String childPath = EclipsePreferences.makeRelative(EclipsePreferences.decodePath(key)[0]);
- ArrayList result = new ArrayList();
- for (int i = 0; i < order.length; i++) {
- String scopeString = order[i];
- boolean found = false;
- for (int j = 0; contexts != null && j < contexts.length; j++) {
- IScopeContext context = contexts[j];
- if (context != null && context.getName().equals(scopeString)) {
- Preferences node = context.getNode(qualifier);
- if (node != null) {
- found = true;
- if (childPath != null)
- node = node.node(childPath);
- result.add(node);
- }
- }
- }
- if (!found) {
- Preferences node = getRootNode().node(scopeString).node(qualifier);
- if (childPath != null)
- node = node.node(childPath);
- result.add(node);
- }
- found = false;
- }
- return (Preferences[]) result.toArray(new Preferences[result.size()]);
- }
-
- /*
- * Convert the given qualifier and key into a key to use in the look-up registry.
- */
- private String getRegistryKey(String qualifier, String key) {
- if (qualifier == null)
- throw new IllegalArgumentException();
- if (key == null)
- return qualifier;
- return qualifier + '/' + key;
- }
-
- /*
- * @see org.eclipse.core.runtime.preferences.IPreferencesService#getRootNode()
- */
-
- public IEclipsePreferences getRootNode() {
- return root;
- }
-
- /*
- * @see org.eclipse.core.runtime.preferences.IPreferencesService#getString(java.lang.String, java.lang.String, java.lang.String, org.eclipse.core.runtime.preferences.IScope[])
- */
- public String getString(String qualifier, String key, String defaultValue, IScopeContext[] scopes) {
- return get(EclipsePreferences.decodePath(key)[1], defaultValue, getNodes(qualifier, key, scopes));
- }
-
- /*
- * @see org.eclipse.core.runtime.preferences.IPreferencesService#importPreferences(java.io.InputStream)
- */
- public IStatus importPreferences(InputStream input) throws CoreException {
- if (EclipsePreferences.DEBUG_PREFERENCE_GENERAL)
- PrefsMessages.message("Importing preferences..."); //$NON-NLS-1$
- return applyPreferences(readPreferences(input));
- }
-
- /*
- * Returns a boolean value indicating whether or not the given Properties
- * object is the result of a preference export previous to Eclipse 3.0.
- *
- * Check the contents of the file. In Eclipse 3.0 we printed out a file
- * version key.
- */
- private boolean isLegacy(Properties properties) {
- return properties.getProperty(VERSION_KEY) == null;
- }
-
- /*
- * @see org.eclipse.core.runtime.preferences.IPreferencesService#readPreferences(java.io.InputStream)
- */
- public IExportedPreferences readPreferences(InputStream input) throws CoreException {
- if (input == null)
- throw new IllegalArgumentException();
-
- if (EclipsePreferences.DEBUG_PREFERENCE_GENERAL)
- PrefsMessages.message("Reading preferences from stream..."); //$NON-NLS-1$
-
- // read the file into a properties object
- Properties properties = new Properties();
- try {
- properties.load(input);
- } catch (IOException e) {
- throw new CoreException(createStatusError(PrefsMessages.preferences_importProblems, e));
- } finally {
- try {
- input.close();
- } catch (IOException e) {
- // ignore
- }
- }
-
- // an empty file is an invalid file format
- if (properties.isEmpty())
- throw new CoreException(createStatusError(PrefsMessages.preferences_invalidFileFormat, null));
-
- // manipulate the file if it from a legacy preference export
- if (isLegacy(properties)) {
- if (EclipsePreferences.DEBUG_PREFERENCE_GENERAL)
- PrefsMessages.message("Read legacy preferences file, converting to 3.0 format..."); //$NON-NLS-1$
- properties = convertFromLegacy(properties);
- } else {
- if (EclipsePreferences.DEBUG_PREFERENCE_GENERAL)
- PrefsMessages.message("Read preferences file."); //$NON-NLS-1$
- properties.remove(VERSION_KEY);
- }
-
- // convert the Properties object into an object to return
- return convertFromProperties(properties);
- }
-
- public void registryChanged(IRegistryChangeEvent event) {
- IExtensionDelta[] deltasOld = event.getExtensionDeltas(IPreferencesConstants.RUNTIME_NAME, IPreferencesConstants.PT_PREFERENCES);
- IExtensionDelta[] deltasNew = event.getExtensionDeltas(IPreferencesConstants.PREFERS_NAME, IPreferencesConstants.PT_PREFERENCES);
- IExtensionDelta[] deltas = new IExtensionDelta[deltasOld.length + deltasNew.length];
- System.arraycopy(deltasOld, 0, deltas, 0, deltasOld.length);
- System.arraycopy(deltasNew, 0, deltas, deltasOld.length, deltasNew.length);
-
- if (deltas.length == 0)
- return;
- // dynamically adjust the registered scopes
- for (int i = 0; i < deltas.length; i++) {
- IConfigurationElement[] elements = deltas[i].getExtension().getConfigurationElements();
- for (int j = 0; j < elements.length; j++) {
- switch (deltas[i].getKind()) {
- case IExtensionDelta.ADDED :
- if (ELEMENT_SCOPE.equalsIgnoreCase(elements[j].getName()))
- scopeAdded(elements[j]);
- break;
- case IExtensionDelta.REMOVED :
- String scope = elements[j].getAttribute(ATTRIBUTE_NAME);
- if (scope != null)
- scopeRemoved(scope);
- break;
- }
- }
- }
- // initialize the preference modify listeners
- modifyListeners = null;
- }
-
- /*
- * @see org.eclipse.core.runtime.preferences.IPreferencesService#setDefaultLookupOrder(java.lang.String, java.lang.String, java.lang.String[])
- */
- public void setDefaultLookupOrder(String qualifier, String key, String[] order) {
- String registryKey = getRegistryKey(qualifier, key);
- if (order == null)
- defaultsRegistry.remove(registryKey);
- else {
- LookupOrder obj = new LookupOrder(order);
- defaultsRegistry.put(registryKey, obj);
- }
- }
-
- /**
- * Shares all duplicate equal strings referenced by the preference service.
- */
- void shareStrings() {
- long now = System.currentTimeMillis();
- if (now - lastStringSharing < STRING_SHARING_INTERVAL)
- return;
- StringPool pool = new StringPool();
- root.shareStrings(pool);
- if (EclipsePreferences.DEBUG_PREFERENCE_GENERAL)
- System.out.println("Preference string sharing saved: " + pool.getSavedStringCount()); //$NON-NLS-1$
- lastStringSharing = now;
- }
-
- public IStatus validateVersions(IPath path) {
- final MultiStatus result = new MultiStatus(PrefsMessages.OWNER_NAME, IStatus.INFO, PrefsMessages.preferences_validate, null);
- IPreferenceNodeVisitor visitor = new IPreferenceNodeVisitor() {
- public boolean visit(IEclipsePreferences node) {
- if (!(node instanceof ExportedPreferences))
- return false;
-
- // calculate the version in the file
- ExportedPreferences realNode = (ExportedPreferences) node;
- String version = realNode.getVersion();
- if (version == null || !PluginVersionIdentifier.validateVersion(version).isOK())
- return true;
- PluginVersionIdentifier versionInFile = new PluginVersionIdentifier(version);
-
- // calculate the version of the installed bundle
- String bundleName = getBundleName(node.absolutePath());
- if (bundleName == null)
- return true;
- String stringVersion = getBundleVersion(bundleName);
- if (stringVersion == null || !PluginVersionIdentifier.validateVersion(stringVersion).isOK())
- return true;
- PluginVersionIdentifier versionInMemory = new PluginVersionIdentifier(stringVersion);
-
- // verify the versions based on the matching rules
- IStatus verification = validatePluginVersions(bundleName, versionInFile, versionInMemory);
- if (verification != null)
- result.add(verification);
-
- return true;
- }
- };
-
- InputStream input = null;
- try {
- input = new BufferedInputStream(new FileInputStream(path.toFile()));
- IExportedPreferences prefs = readPreferences(input);
- prefs.accept(visitor);
- } catch (FileNotFoundException e) {
- // ignore...if the file does not exist then all is OK
- } catch (CoreException e) {
- result.add(createStatusError(PrefsMessages.preferences_validationException, e));
- } catch (BackingStoreException e) {
- result.add(createStatusError(PrefsMessages.preferences_validationException, e));
- }
- return result;
- }
-
- /**
- * Compares two plugin version identifiers to see if their preferences
- * are compatible. If they are not compatible, a warning message is
- * added to the given multistatus, according to the following rules:
- *
- * - plugins that differ in service number: no status
- * - plugins that differ in minor version: WARNING status
- * - plugins that differ in major version:
- * - where installed plugin is newer: WARNING status
- * - where installed plugin is older: ERROR status
- * @param bundle the name of the bundle
- * @param pref The version identifer of the preferences to be loaded
- * @param installed The version identifier of the installed plugin
- */
- IStatus validatePluginVersions(String bundle, PluginVersionIdentifier pref, PluginVersionIdentifier installed) {
- if (installed.getMajorComponent() == pref.getMajorComponent() && installed.getMinorComponent() == pref.getMinorComponent())
- return null;
- int severity;
- if (installed.getMajorComponent() < pref.getMajorComponent())
- severity = IStatus.ERROR;
- else
- severity = IStatus.WARNING;
- String msg = NLS.bind(PrefsMessages.preferences_incompatible, (new Object[] {pref, bundle, installed}));
- return new Status(severity, PrefsMessages.OWNER_NAME, 1, msg, null);
- }
-
- private IEclipsePreferences mergeTrees(IEclipsePreferences[] trees) throws BackingStoreException {
- if (trees.length == 1)
- return trees[0];
- final IEclipsePreferences result = ExportedPreferences.newRoot();
- if (trees.length == 0)
- return result;
- IPreferenceNodeVisitor visitor = new IPreferenceNodeVisitor() {
- public boolean visit(IEclipsePreferences node) throws BackingStoreException {
- Preferences destination = result.node(node.absolutePath());
- copyFromTo(node, destination, null, 0);
- return true;
- }
- };
- for (int i = 0; i < trees.length; i++)
- trees[i].accept(visitor);
- return result;
- }
-
- /*
- * Return a tree which contains only nodes and keys which are applicable to the given filter.
- */
- private IEclipsePreferences trimTree(IEclipsePreferences tree, IPreferenceFilter filter) throws BackingStoreException {
- IEclipsePreferences result = (IEclipsePreferences) ExportedPreferences.newRoot().node(tree.absolutePath());
- String[] scopes = filter.getScopes();
- if (scopes == null)
- throw new IllegalArgumentException();
- String treePath = tree.absolutePath();
- // see if this node is applicable by going over all our scopes
- for (int i = 0; i < scopes.length; i++) {
- String scope = scopes[i];
- Map mapping = filter.getMapping(scope);
- // if the mapping is null then copy everything if the scope matches
- if (mapping == null) {
- // if we are the root node then check our children
- if (tree.parent() == null && tree.nodeExists(scope))
- copyFromTo(tree.node(scope), result.node(scope), null, -1);
- // ensure we are in the correct scope
- else if (scopeMatches(scope, tree))
- copyFromTo(tree, result, null, -1);
- continue;
- }
- // iterate over the list of declared nodes
- for (Iterator iter = mapping.keySet().iterator(); iter.hasNext();) {
- String nodePath = (String) iter.next();
- String nodeFullPath = '/' + scope + '/' + nodePath;
- // if this subtree isn't in a hierarchy we are interested in, then go to the next one
- if (!nodeFullPath.startsWith(treePath))
- continue;
- // get the child node
- String childPath = nodeFullPath.substring(treePath.length());
- childPath = EclipsePreferences.makeRelative(childPath);
- if (tree.nodeExists(childPath)) {
- PreferenceFilterEntry[] entries;
- // protect against wrong classes since this is passed in by the user
- try {
- entries = (PreferenceFilterEntry[]) mapping.get(nodePath);
- } catch (ClassCastException e) {
- log(createStatusError(PrefsMessages.preferences_classCastFilterEntry, e));
- continue;
- }
- String[] keys = null;
- if (entries != null) {
- ArrayList list = new ArrayList();
- for (int j = 0; j < entries.length; j++) {
- if (entries[j] != null)
- list.add(entries[j].getKey());
- }
- keys = (String[]) list.toArray(new String[list.size()]);
- }
- // do infinite depth if there are no keys specified since the parent matched.
- copyFromTo(tree.node(childPath), result.node(childPath), keys, keys == null ? -1 : 0);
- }
- }
- }
- return result;
- }
-
- /**
- * Return true if the given node is in the specified scope and false othewise.
- */
- private boolean scopeMatches(String scope, IEclipsePreferences tree) {
- // the root isn't in any scope
- if (tree.parent() == null)
- return false;
- // fancy math to get the first segment of the path
- String path = tree.absolutePath();
- int index = path.indexOf('/', 1);
- String sub = path.substring(1, index == -1 ? path.length() : index);
- return scope.equals(sub);
- }
-
- /**
- * Copy key/value pairs from the source to the destination. If the key list is null
- * then copy all associations.
- *
- * If the depth is 0, then this operation is performed only on the source node. Otherwise
- * it is performed on the source node's subtree.
- *
- * @param depth one of 0 or -1
- */
- void copyFromTo(Preferences source, Preferences destination, String[] keys, int depth) throws BackingStoreException {
- String[] keysToCopy = keys == null ? source.keys() : keys;
- for (int i = 0; i < keysToCopy.length; i++) {
- String value = source.get(keysToCopy[i], null);
- if (value != null)
- destination.put(keysToCopy[i], value);
- }
- if (depth == 0)
- return;
- String[] children = source.childrenNames();
- for (int i = 0; i < children.length; i++)
- copyFromTo(source.node(children[i]), destination.node(children[i]), keys, depth);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.preferences.IPreferencesService#exportPreferences(IEclipsePreferences, IPreferenceFilter[], OutputStream)
- */
- public void exportPreferences(IEclipsePreferences node, IPreferenceFilter[] filters, OutputStream stream) throws CoreException {
- if (filters == null || filters.length == 0)
- return;
- try {
- internalExport(node, filters, stream);
- } catch (BackingStoreException e) {
- throw new CoreException(createStatusError(PrefsMessages.preferences_exportProblems, e));
- }
- }
-
- /**
- * Take the preference tree and trim it so it only holds values applying to the given filters.
- * Then export the resulting tree to the given output stream.
- */
- private void internalExport(IEclipsePreferences node, IPreferenceFilter filters[], OutputStream output) throws BackingStoreException, CoreException {
- ArrayList trees = new ArrayList();
- for (int i = 0; i < filters.length; i++)
- trees.add(trimTree(node, filters[i]));
- IEclipsePreferences toExport = mergeTrees((IEclipsePreferences[]) trees.toArray(new IEclipsePreferences[trees.size()]));
- exportPreferences(toExport, output, (String[]) null);
- }
-
- /* (non-Javadoc)
- * @see IPreferencesService#matches(IEclipsePreferences, IPreferenceFilter[])
- */
- public IPreferenceFilter[] matches(IEclipsePreferences tree, IPreferenceFilter[] filters) throws CoreException {
- if (filters == null || filters.length == 0)
- return new IPreferenceFilter[0];
- try {
- return internalMatches(tree, filters);
- } catch (BackingStoreException e) {
- throw new CoreException(createStatusError(PrefsMessages.preferences_matching, e));
- }
- }
-
- /*
- * Internal method that collects the matching filters for the given tree and returns them.
- */
- private IPreferenceFilter[] internalMatches(IEclipsePreferences tree, IPreferenceFilter[] filters) throws BackingStoreException {
- ArrayList result = new ArrayList();
- for (int i = 0; i < filters.length; i++)
- if (internalMatches(tree, filters[i]))
- result.add(filters[i]);
- return (IPreferenceFilter[]) result.toArray(new IPreferenceFilter[result.size()]);
- }
-
- private boolean containsKeys(IEclipsePreferences aRoot) throws BackingStoreException {
- final boolean result[] = new boolean[] {false};
- IPreferenceNodeVisitor visitor = new IPreferenceNodeVisitor() {
- public boolean visit(IEclipsePreferences node) throws BackingStoreException {
- if (node.keys().length != 0)
- result[0] = true;
- return !result[0];
- }
- };
- aRoot.accept(visitor);
- return result[0];
- }
-
- /*
- * Return true if the given tree contains information that the specified filter is interested
- * in, and false otherwise.
- */
- private boolean internalMatches(IEclipsePreferences tree, IPreferenceFilter filter) throws BackingStoreException {
- String[] scopes = filter.getScopes();
- if (scopes == null)
- throw new IllegalArgumentException();
- String treePath = tree.absolutePath();
- // see if this node is applicable by going over all our scopes
- for (int i = 0; i < scopes.length; i++) {
- String scope = scopes[i];
- Map mapping = filter.getMapping(scope);
- // if the mapping is null then we match everything
- if (mapping == null) {
- // if we are the root check to see if the scope exists
- if (tree.parent() == null && tree.nodeExists(scope))
- return containsKeys((IEclipsePreferences) tree.node(scope));
- // otherwise check to see if we are in the right scope
- if (scopeMatches(scope, tree) && containsKeys(tree))
- return true;
- continue;
- }
- // iterate over the list of declared nodes
- for (Iterator iter = mapping.keySet().iterator(); iter.hasNext();) {
- String nodePath = (String) iter.next();
- String nodeFullPath = '/' + scope + '/' + nodePath;
- // if this subtree isn't in a hierarchy we are interested in, then go to the next one
- if (!nodeFullPath.startsWith(treePath))
- continue;
- // get the child node
- String childPath = nodeFullPath.substring(treePath.length());
- childPath = EclipsePreferences.makeRelative(childPath);
- if (tree.nodeExists(childPath)) {
- PreferenceFilterEntry[] entries;
- // protect against wrong classes since this is user-code
- try {
- entries = (PreferenceFilterEntry[]) mapping.get(nodePath);
- } catch (ClassCastException e) {
- log(createStatusError(PrefsMessages.preferences_classCastFilterEntry, e));
- continue;
- }
- // if there are no entries defined then we return false even if we
- // are supposed to match on the existance of the node as a whole (bug 88820)
- Preferences child = tree.node(childPath);
- if (entries == null)
- return child.keys().length != 0 || child.childrenNames().length != 0;
- // otherwise check to see if we have any applicable keys
- for (int j = 0; j < entries.length; j++) {
- if (entries[j] != null && child.get(entries[j].getKey(), null) != null)
- return true;
- }
- }
- }
- }
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.preferences.IPreferencesService#applyPreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences, org.eclipse.core.runtime.preferences.IPreferenceFilter[])
- */
- public void applyPreferences(IEclipsePreferences tree, IPreferenceFilter[] filters) throws CoreException {
- if (filters == null || filters.length == 0)
- return;
- try {
- internalApply(tree, filters);
- //this typically causes a major change to the preference tree, so force string sharing
- lastStringSharing = 0;
- shareStrings();
- } catch (BackingStoreException e) {
- throw new CoreException(createStatusError(PrefsMessages.preferences_applyProblems, e));
- }
- }
-
- /**
- * Filter the given tree so it only contains values which apply to the specified filters
- * then apply the resulting tree to the main preference tree.
- */
- private void internalApply(IEclipsePreferences tree, IPreferenceFilter[] filters) throws BackingStoreException {
- ArrayList trees = new ArrayList();
- for (int i = 0; i < filters.length; i++)
- trees.add(trimTree(tree, filters[i]));
- // merge the union of the matching filters
- IEclipsePreferences toApply = mergeTrees((IEclipsePreferences[]) trees.toArray(new IEclipsePreferences[trees.size()]));
-
- // fire an event to give people a chance to modify the tree
- toApply = firePreApplyEvent(toApply);
-
- // actually apply the settings
- IPreferenceNodeVisitor visitor = new IPreferenceNodeVisitor() {
- public boolean visit(IEclipsePreferences node) throws BackingStoreException {
- String[] keys = node.keys();
- if (keys.length == 0)
- return true;
- copyFromTo(node, getRootNode().node(node.absolutePath()), keys, 0);
- return true;
- }
- };
- toApply.accept(visitor);
- }
-
- /*
- * Give clients a chance to modify the tree before it is applied globally
- */
- private IEclipsePreferences firePreApplyEvent(IEclipsePreferences tree) {
- final IEclipsePreferences[] result = new IEclipsePreferences[] {tree};
- if (modifyListeners == null)
- initializeModifyListeners();
- Object[] listeners = modifyListeners.getListeners();
- for (int i = 0; i < listeners.length; i++) {
- final PreferenceModifyListener listener = (PreferenceModifyListener) listeners[i];
- ISafeRunnable job = new ISafeRunnable() {
- public void handleException(Throwable exception) {
- // already logged in Platform#run()
- }
-
- public void run() throws Exception {
- result[0] = listener.preApply(result[0]);
- }
- };
- SafeRunner.run(job);
- }
- return result[0];
- }
-
- // Store this around for performance
- private final static IExtension[] emptyExtensionArray = new IExtension[0];
-
- public static IExtension[] getPrefExtensions() {
- IExtensionRegistry registry = RegistryFactory.getRegistry();
- IExtension[] extensionsOld = emptyExtensionArray;
- IExtension[] extensionsNew = emptyExtensionArray;
- // "old"
- IExtensionPoint pointOld = registry.getExtensionPoint(IPreferencesConstants.RUNTIME_NAME, IPreferencesConstants.PT_PREFERENCES);
- if (pointOld != null)
- extensionsOld = pointOld.getExtensions();
- // "new"
- IExtensionPoint pointNew = registry.getExtensionPoint(IPreferencesConstants.PREFERS_NAME, IPreferencesConstants.PT_PREFERENCES);
- if (pointNew != null)
- extensionsNew = pointNew.getExtensions();
- // combine
- IExtension[] extensions = new IExtension[extensionsOld.length + extensionsNew.length];
- System.arraycopy(extensionsOld, 0, extensions, 0, extensionsOld.length);
- System.arraycopy(extensionsNew, 0, extensions, extensionsOld.length, extensionsNew.length);
-
- if (extensions.length == 0) {
- if (EclipsePreferences.DEBUG_PREFERENCE_GENERAL)
- PrefsMessages.message("No extensions for org.eclipse.core.contenttype."); //$NON-NLS-1$
- }
-
- return extensions;
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/PrefsMessages.java b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/PrefsMessages.java
deleted file mode 100644
index 87f34ddd0..000000000
--- a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/PrefsMessages.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2005 IBM Corporation 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:
- * IBM - Initial API and implementation
- **********************************************************************/
-package org.eclipse.core.internal.preferences;
-
-import java.util.Date;
-import org.eclipse.osgi.util.NLS;
-
-// Runtime plugin message catalog
-public class PrefsMessages extends NLS {
- /**
- * The unique identifier constant of this plug-in.
- */
- public static final String OWNER_NAME = "org.eclipse.equinox.preferences"; //$NON-NLS-1$
-
- private static final String BUNDLE_NAME = "org.eclipse.core.internal.preferences.messages"; //$NON-NLS-1$
-
- // Preferences
- public static String preferences_applyProblems;
- public static String preferences_classCastScope;
- public static String preferences_classCastListener;
- public static String preferences_classCastFilterEntry;
- public static String preferences_errorWriting;
- public static String preferences_exportProblems;
- public static String preferences_failedDelete;
- public static String preferences_fileNotFound;
- public static String preferences_importProblems;
- public static String preferences_incompatible;
- public static String preferences_invalidExtensionSuperclass;
- public static String preferences_invalidFileFormat;
- public static String preferences_loadException;
- public static String preferences_matching;
- public static String preferences_missingClassAttribute;
- public static String preferences_missingScopeAttribute;
- public static String preferences_removedNode;
- public static String preferences_saveException;
- public static String preferences_saveProblems;
- public static String preferences_validate;
- public static String preferences_validationException;
-
- static {
- // load message values from bundle file
- reloadMessages();
- }
-
- public static void reloadMessages() {
- NLS.initializeMessages(BUNDLE_NAME, PrefsMessages.class);
- }
-
- /**
- * Print a debug message to the console.
- * Pre-pend the message with the current date and the name of the current thread.
- */
- public static void message(String message) {
- StringBuffer buffer = new StringBuffer();
- buffer.append(new Date(System.currentTimeMillis()));
- buffer.append(" - ["); //$NON-NLS-1$
- buffer.append(Thread.currentThread().getName());
- buffer.append("] "); //$NON-NLS-1$
- buffer.append(message);
- System.out.println(buffer.toString());
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/RootPreferences.java b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/RootPreferences.java
deleted file mode 100644
index d660842e8..000000000
--- a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/RootPreferences.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.preferences;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.osgi.service.prefs.BackingStoreException;
-import org.osgi.service.prefs.Preferences;
-
-/**
- * @since 3.0
- */
-public class RootPreferences extends EclipsePreferences {
-
- /**
- * Default constructor.
- */
- public RootPreferences() {
- super(null, ""); //$NON-NLS-1$
- }
-
- /*
- * @see org.osgi.service.prefs.Preferences#flush()
- */
- public void flush() throws BackingStoreException {
- // flush all children
- BackingStoreException exception = null;
- String[] names = childrenNames();
- for (int i = 0; i < names.length; i++) {
- try {
- node(names[i]).flush();
- } catch (BackingStoreException e) {
- // store the first exception we get and still try and flush
- // the rest of the children.
- if (exception != null)
- exception = e;
- }
- }
- if (exception != null)
- throw exception;
- }
-
- /*
- * @see EclipsePreferences#getChild(String, Plugin)
- */
- protected synchronized IEclipsePreferences getChild(String key, Object context) {
- Object value = null;
- IEclipsePreferences child = null;
- if (children != null)
- value = children.get(key);
- if (value != null) {
- if (value instanceof IEclipsePreferences)
- return (IEclipsePreferences) value;
- //lazy initialization
- child = PreferencesService.getDefault().createNode(key);
- addChild(key, child);
- }
- return child;
- }
-
- /*
- * @see EclipsePreferences#getChildren()
- */
- protected synchronized IEclipsePreferences[] getChildren() {
- //must perform lazy initialization of child nodes
- String[] childNames = childrenNames();
- IEclipsePreferences[] childNodes = new IEclipsePreferences[childNames.length];
- for (int i = 0; i < childNames.length; i++)
- childNodes[i] = getChild(childNames[i], null);
- return childNodes;
- }
-
- /*
- * @see Preferences#node(String)
- */
- public Preferences node(String path) {
- return getNode(path, true); // create if not found
- }
-
- public Preferences getNode(String path, boolean create) {
- if (path.length() == 0 || (path.length() == 1 && path.charAt(0) == IPath.SEPARATOR))
- return this;
- int startIndex = path.charAt(0) == IPath.SEPARATOR ? 1 : 0;
- int endIndex = path.indexOf(IPath.SEPARATOR, startIndex + 1);
- String scope = path.substring(startIndex, endIndex == -1 ? path.length() : endIndex);
- IEclipsePreferences child;
- if (create) {
- child = getChild(scope, null);
- if (child == null) {
- child = new EclipsePreferences(this, scope);
- addChild(scope, child);
- }
- } else {
- child = getChild(scope, null, false);
- if (child == null)
- return null;
- }
- return child.node(endIndex == -1 ? "" : path.substring(endIndex + 1)); //$NON-NLS-1$
- }
-
- /*
- * @see org.osgi.service.prefs.Preferences#sync()
- */
- public void sync() throws BackingStoreException {
- // sync all children
- BackingStoreException exception = null;
- String[] names = childrenNames();
- for (int i = 0; i < names.length; i++) {
- try {
- node(names[i]).sync();
- } catch (BackingStoreException e) {
- // store the first exception we get and still try and sync
- // the rest of the children.
- if (exception != null)
- exception = e;
- }
- }
- if (exception != null)
- throw exception;
- }
-}
diff --git a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/StringPool.java b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/StringPool.java
deleted file mode 100644
index 5d361aa9f..000000000
--- a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/StringPool.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation 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:
- * IBM - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.preferences;
-
-import java.util.HashMap;
-
-/**
- * A string pool is used for sharing strings in a way that eliminates duplicate
- * equal strings. A string pool instance can be maintained over a long period
- * of time, or used as a temporary structure during a string sharing pass over
- * a data structure.
- * <p>
- * This class is not intended to be subclassed by clients.
- * </p>
- *
- * Note: This class is copied from org.eclipse.core.resources
- *
- * @since 3.1
- */
-public final class StringPool {
- private int savings;
- private final HashMap map = new HashMap();
-
- /**
- * Adds a <code>String</code> to the pool. Returns a <code>String</code>
- * that is equal to the argument but that is unique within this pool.
- * @param string The string to add to the pool
- * @return A string that is equal to the argument.
- */
- public String add(String string) {
- if (string == null)
- return string;
- Object result = map.get(string);
- if (result != null) {
- if (result != string)
- savings += 44 + 2 * string.length();
- return (String) result;
- }
- map.put(string, string);
- return string;
- }
-
- /**
- * Returns an estimate of the size in bytes that was saved by sharing strings in
- * the pool. In particular, this returns the size of all strings that were added to the
- * pool after an equal string had already been added. This value can be used
- * to estimate the effectiveness of a string sharing operation, in order to
- * determine if or when it should be performed again.
- *
- * In some cases this does not precisely represent the number of bytes that
- * were saved. For example, say the pool already contains string S1. Now
- * string S2, which is equal to S1 but not identical, is added to the pool five
- * times. This method will return the size of string S2 multiplied by the
- * number of times it was added, even though the actual savings in this case
- * is only the size of a single copy of S2.
- */
- public int getSavedStringCount() {
- return savings;
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/messages.properties b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/messages.properties
deleted file mode 100644
index abfb6464e..000000000
--- a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/messages.properties
+++ /dev/null
@@ -1,34 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2005 IBM Corporation 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:
-# IBM Corporation - initial API and implementation
-###############################################################################
-### Runtime preferences plugin messages
-
-### Preferences
-preferences_applyProblems=Problems applying preference changes.
-preferences_classCastScope=Extensions to org.eclipse.core.runtime.preferences extension point must implement the IScope interface.
-preferences_classCastListener=Preference modify listeners must subclass the PreferenceModifyListener class.
-preferences_classCastFilterEntry=Preference filter mappings must be instances of the class PreferenceFilterEntry.
-preferences_errorWriting=Error writing preference file {0}. {1}
-preferences_exportProblems=Problems exporting preferences.
-preferences_failedDelete=Failed to delete preferences file: {0}.
-preferences_fileNotFound=Preference export file not found: {0}.
-preferences_importProblems=Problems importing preferences.
-preferences_incompatible=The preference file contains preferences for version \"{0}\" of plug-in \"{1}\", but version \"{2}\" is currently installed.
-preferences_invalidExtensionSuperclass=Extension does not extend class AbstractPreferenceInitializer.
-preferences_invalidFileFormat=Invalid preference file format.
-preferences_loadException=Exception loading preferences from: {0}.
-preferences_matching=Exception while matching preference filters.
-preferences_missingClassAttribute= Missing \"class\" attribute in \"preference\" element in extension declaration for: {0}.
-preferences_missingScopeAttribute= Missing \"scope\" attribute in \"preference\" element in extension declaration for: {0}.
-preferences_removedNode=Preference node \"{0}\" has been removed.
-preferences_saveException=Exception saving preferences to: {0}.
-preferences_saveProblems=Problems saving preferences.
-preferences_validate=Some preferences may not be compatible with the currently installed plug-ins.
-preferences_validationException=Exception while validating bundle versions.
diff --git a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/AbstractPreferenceInitializer.java b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/AbstractPreferenceInitializer.java
deleted file mode 100644
index 5387407a5..000000000
--- a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/AbstractPreferenceInitializer.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime.preferences;
-
-/**
- * Abstract class used to aid in default preference value initialization.
- * Clients who extend the <code>org.eclipse.core.runtime.preferences</code>
- * extension point are able to specify a class within an <code>initializer</code>
- * element.
- *
- * @since 3.0
- */
-public abstract class AbstractPreferenceInitializer {
-
- /**
- * Default constructor for the class.
- */
- public AbstractPreferenceInitializer() {
- super();
- }
-
- /**
- * This method is called by the preference initializer to initialize default
- * preference values. Clients should get the correct node for their
- * bundle and then set the default values on it. For example:
- * <pre>
- * public void initializeDefaultPreferences() {
- * Preferences node = new DefaultScope().getNode("my.bundle.id");
- * node.put(key, value);
- * }
- * </pre>
- * <p>
- * <em>Note: Clients should only set default preference values for their
- * own bundle.</em>
- * </p>
- * <p>
- * <em>Note:</em> Clients should not call this method. It will be called
- * automatically by the preference initializer when the appropriate default
- * preference node is accessed.
- * </p>
- */
- public abstract void initializeDefaultPreferences();
-
-}
diff --git a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/ConfigurationScope.java b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/ConfigurationScope.java
deleted file mode 100644
index e4824c5d4..000000000
--- a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/ConfigurationScope.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime.preferences;
-
-import java.net.URL;
-import org.eclipse.core.internal.preferences.AbstractScope;
-import org.eclipse.core.internal.preferences.PreferencesOSGiUtils;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.osgi.service.datalocation.Location;
-
-/**
- * Object representing the configuration scope in the Eclipse preferences
- * hierarchy. Can be used as a context for searching for preference
- * values (in the IPreferencesService APIs) or for determining the
- * correct preference node to set values in the store.
- * <p>
- * Configuration preferences are stored on a per configuration basis in the
- * platform's configuration area. (The configuration area typically
- * contains the list of plug-ins available for use, various settings
- * (those shared across different instances of the same configuration)
- * and any other such data needed by plug-ins.)
- * </p>
- * <p>
- * The path for preferences defined in the configuration scope hierarchy
- * is as follows: <code>/configuration/&lt;qualifier&gt;</code>
- * </p>
- * <p>
- * This class is not intended to be subclassed. This class may be instantiated.
- * </p>
- * @since 3.0
- */
-public final class ConfigurationScope extends AbstractScope implements IScopeContext {
-
- /**
- * String constant (value of <code>"configuration"</code>) used for the
- * scope name for the configuration preference scope.
- */
- public static final String SCOPE = "configuration"; //$NON-NLS-1$
-
- /**
- * Create and return a new configuration scope instance.
- */
- public ConfigurationScope() {
- super();
- }
-
- /*
- * @see org.eclipse.core.runtime.preferences.IScopeContext#getName()
- */
- public String getName() {
- return SCOPE;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.preferences.IScopeContext#getNode(java.lang.String)
- */
- public IEclipsePreferences getNode(String qualifier) {
- return super.getNode(qualifier);
- }
-
- /*
- * @see org.eclipse.core.runtime.preferences.IScopeContext#getLocation()
- */
- public IPath getLocation() {
- IPath result = null;
- Location location = PreferencesOSGiUtils.getDefault().getConfigurationLocation();
- if (!location.isReadOnly()) {
- URL url = location.getURL();
- if (url != null) {
- result = new Path(url.getFile());
- if (result.isEmpty())
- result = null;
- }
- }
- return result;
- }
-}
diff --git a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/DefaultScope.java b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/DefaultScope.java
deleted file mode 100644
index a42de40c8..000000000
--- a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/DefaultScope.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime.preferences;
-
-import org.eclipse.core.internal.preferences.AbstractScope;
-import org.eclipse.core.runtime.IPath;
-
-/**
- * Object representing the default scope in the Eclipse preferences
- * hierarchy. Can be used as a context for searching for preference
- * values (in the IPreferencesService APIs) or for determining the
- * correct preference node to set values in the store.
- * <p>
- * Default preferences are not persisted to disk.
- * </p>
- * <p>
- * The path for preferences defined in the default scope hierarchy
- * is as follows: <code>/default/&lt;qualifier&gt;</code>
- * </p>
- * <p>
- * Note about product preference customization:
- * Clients who define their own {@link org.eclipse.core.runtime.IProduct}
- * are able to specify a product key of "<code>preferenceCustomization</code>".
- * (defined as a constant in {@link org.eclipse.ui.branding.IProductConstants})
- * Its value is either a {@link java.net.URL} or a file-system path to a
- * file whose contents are used to customize default preferences.
- * </p>
- * <p>
- * This class is not intended to be subclassed. This class may be instantiated.
- * </p>
- * @since 3.0
- */
-public final class DefaultScope extends AbstractScope implements IScopeContext {
-
- /**
- * String constant (value of <code>"default"</code>) used for the
- * scope name for the default preference scope.
- */
- public static final String SCOPE = "default"; //$NON-NLS-1$
-
- /**
- * Create and return a new default scope instance.
- */
- public DefaultScope() {
- super();
- }
-
- /*
- * @see org.eclipse.core.runtime.preferences.IScopeContext#getName()
- */
- public String getName() {
- return SCOPE;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.preferences.IScopeContext#getNode(java.lang.String)
- */
- public IEclipsePreferences getNode(String qualifier) {
- return super.getNode(qualifier);
- }
-
- /*
- * @see org.eclipse.core.runtime.preferences.IScopeContext#getLocation()
- */
- public IPath getLocation() {
- // We don't persist defaults so return null.
- return null;
- }
-}
diff --git a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/IEclipsePreferences.java b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/IEclipsePreferences.java
deleted file mode 100644
index a5d49caa4..000000000
--- a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/IEclipsePreferences.java
+++ /dev/null
@@ -1,316 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime.preferences;
-
-import java.util.EventObject;
-import org.osgi.service.prefs.BackingStoreException;
-import org.osgi.service.prefs.Preferences;
-
-/**
- * This interface describes Eclipse extensions to the preference
- * story. It provides means for both preference and node change
- * listeners.
- * <p>
- * Clients may implement this interface.
- * </p>
- *
- * @see org.osgi.service.prefs.Preferences
- * @since 3.0
- */
-public interface IEclipsePreferences extends Preferences {
-
- /**
- * An event object which describes the details of a change in the
- * preference node hierarchy. The child node is the one which
- * was added or removed.
- *
- * @see IEclipsePreferences.INodeChangeListener
- * @since 3.0
- */
- public final class NodeChangeEvent extends EventObject {
- /**
- * All serializable objects should have a stable serialVersionUID
- */
- private static final long serialVersionUID = 1L;
-
- private Preferences child;
-
- /**
- * Constructor for a new node change event object.
- *
- * @param parent the parent node
- * @param child the child node
- */
- public NodeChangeEvent(Preferences parent, Preferences child) {
- super(parent);
- this.child = child;
- }
-
- /**
- * Return the parent node for this event. This is the parent
- * of the node which was added or removed.
- *
- * @return the parent node
- */
- public Preferences getParent() {
- return (Preferences) getSource();
- }
-
- /**
- * Return the child node for this event. This is the node
- * which was added or removed.
- * <p>
- * Note: The child node may have been removed as a result of
- * the bundle supplying its implementation being un-installed. In this case
- * the only method which can safely be called on the child is #name().
- * </p>
- * @return the child node
- */
- public Preferences getChild() {
- return child;
- }
- }
-
- /**
- * A listener to be used to receive preference node change events.
- * <p>
- * Clients may implement this interface.
- * </p>
- *
- * @since 3.0
- */
- public interface INodeChangeListener {
-
- /**
- * Notification that a child node was added to the preference hierarchy.
- * The given event must not be <code>null</code>.
- *
- * @param event an event specifying the details about the new node
- * @see IEclipsePreferences.NodeChangeEvent
- * @see IEclipsePreferences#addNodeChangeListener(IEclipsePreferences.INodeChangeListener)
- * @see IEclipsePreferences#removeNodeChangeListener(IEclipsePreferences.INodeChangeListener)
- */
- public void added(NodeChangeEvent event);
-
- /**
- * Notification that a child node was removed from the preference hierarchy.
- * The given event must not be <code>null</code>.
- *
- * @param event an event specifying the details about the removed node
- * @see IEclipsePreferences.NodeChangeEvent
- * @see IEclipsePreferences#addNodeChangeListener(IEclipsePreferences.INodeChangeListener)
- * @see IEclipsePreferences#removeNodeChangeListener(IEclipsePreferences.INodeChangeListener)
- */
- public void removed(NodeChangeEvent event);
- }
-
- /**
- * An event object describing the details of a change to a preference
- * in the preference store.
- *
- * @see IEclipsePreferences.IPreferenceChangeListener
- * @since 3.0
- */
- public final class PreferenceChangeEvent extends EventObject {
- /**
- * All serializable objects should have a stable serialVersionUID
- */
- private static final long serialVersionUID = 1L;
-
- private String key;
- private Object newValue;
- private Object oldValue;
-
- /**
- * Constructor for a new preference change event. The node and the
- * key must not be <code>null</code>. The old and new preference
- * values must be either a <code>String</code> or <code>null</code>.
- *
- * @param node the node on which the change occurred
- * @param key the preference key
- * @param oldValue the old preference value, as a <code>String</code>
- * or <code>null</code>
- * @param newValue the new preference value, as a <code>String</code>
- * or <code>null</code>
- */
- public PreferenceChangeEvent(Object node, String key, Object oldValue, Object newValue) {
- super(node);
- if (key == null || !(node instanceof Preferences))
- throw new IllegalArgumentException();
- this.key = key;
- this.newValue = newValue;
- this.oldValue = oldValue;
- }
-
- /**
- * Return the preference node on which the change occurred.
- * Must not be <code>null</code>.
- *
- * @return the node
- */
- public Preferences getNode() {
- return (Preferences) source;
- }
-
- /**
- * Return the key of the preference which was changed.
- * Must not be <code>null</code>.
- *
- * @return the preference key
- */
- public String getKey() {
- return key;
- }
-
- /**
- * Return the new value for the preference encoded as a
- * <code>String</code>, or <code>null</code> if the
- * preference was removed.
- *
- * @return the new value or <code>null</code>
- */
- public Object getNewValue() {
- return newValue;
- }
-
- /**
- * Return the old value for the preference encoded as a
- * <code>String</code>, or <code>null</code> if the
- * preference was removed or if it cannot be determined.
- *
- * @return the old value or <code>null</code>
- */
- public Object getOldValue() {
- return oldValue;
- }
- }
-
- /**
- * A listener used to receive changes to preference values in the preference store.
- * <p>
- * Clients may implement this interface.
- * </p>
- *
- * @since 3.0
- */
- public interface IPreferenceChangeListener {
-
- /**
- * Notification that a preference value has changed in the preference store.
- * The given event object describes the change details and must not
- * be <code>null</code>.
- *
- * @param event the event details
- * @see IEclipsePreferences.PreferenceChangeEvent
- * @see IEclipsePreferences#addPreferenceChangeListener(IEclipsePreferences.IPreferenceChangeListener)
- * @see IEclipsePreferences#removePreferenceChangeListener(IEclipsePreferences.IPreferenceChangeListener)
- */
- public void preferenceChange(PreferenceChangeEvent event);
- }
-
- /**
- * Register the given listener for changes to this node. Duplicate calls
- * to this method with the same listener will have no effect. The given
- * listener argument must not be <code>null</code>.
- *
- * @param listener the node change listener to add
- * @throws IllegalStateException if this node or an ancestor has been removed
- * @see #removeNodeChangeListener(IEclipsePreferences.INodeChangeListener)
- * @see IEclipsePreferences.INodeChangeListener
- */
- public void addNodeChangeListener(INodeChangeListener listener);
-
- /**
- * De-register the given listener from receiving event change notifications
- * for this node. Calling this method with a listener which is not registered
- * has no effect. The given listener argument must not be <code>null</code>.
- *
- * @param listener the node change listener to remove
- * @throws IllegalStateException if this node or an ancestor has been removed
- * @see #addNodeChangeListener(IEclipsePreferences.INodeChangeListener)
- * @see IEclipsePreferences.INodeChangeListener
- */
- public void removeNodeChangeListener(INodeChangeListener listener);
-
- /**
- * Register the given listener for notification of preference changes to this node.
- * Calling this method multiple times with the same listener has no effect. The
- * given listener argument must not be <code>null</code>.
- *
- * @param listener the preference change listener to register
- * @throws IllegalStateException if this node or an ancestor has been removed
- * @see #removePreferenceChangeListener(IEclipsePreferences.IPreferenceChangeListener)
- * @see IEclipsePreferences.IPreferenceChangeListener
- */
- public void addPreferenceChangeListener(IPreferenceChangeListener listener);
-
- /**
- * De-register the given listener from receiving notification of preference changes
- * to this node. Calling this method multiple times with the same listener has no
- * effect. The given listener argument must not be <code>null</code>.
- *
- * @param listener the preference change listener to remove
- * @throws IllegalStateException if this node or an ancestor has been removed
- * @see #addPreferenceChangeListener(IEclipsePreferences.IPreferenceChangeListener)
- * @see IEclipsePreferences.IPreferenceChangeListener
- */
- public void removePreferenceChangeListener(IPreferenceChangeListener listener);
-
- /**
- * Remove this node from the preference hierarchy. If this node is the scope
- * root, then do not remove this node, only remove this node's children.
- * <p>
- * Functionally equivalent to calling {@link Preferences#removeNode()}.
- * See the spec of {@link Preferences#removeNode()} for more details.
- * </p>
- * <p>
- * Implementors must send the appropriate {@link NodeChangeEvent}
- * to listeners who are registered on this node's parent.
- * </p>
- * <p>
- * When this node is removed, its associated preference and node change
- * listeners should be removed as well.
- * </p>
- * @throws BackingStoreException if there was a problem removing this node
- * @see org.osgi.service.prefs.Preferences#removeNode()
- * @see NodeChangeEvent
- */
- public void removeNode() throws BackingStoreException;
-
- /**
- * Return the preferences node with the given path. The given path must
- * not be <code>null</code>.
- * <p>
- * See the spec of {@link Preferences#node(String)} for more details.
- * </p>
- * <p>
- * Note that if the node does not yet exist and is created, then the appropriate
- * {@link NodeChangeEvent} must be sent to listeners who are
- * registered at this node.
- * </p>
- * @param path the path of the node
- * @return the node
- * @see org.osgi.service.prefs.Preferences#node(String)
- * @see NodeChangeEvent
- */
- public Preferences node(String path);
-
- /**
- * Accepts the given visitor. The visitor's <code>visit</code> method
- * is called with this node. If the visitor returns <code>true</code>,
- * this method visits this node's children.
- *
- * @param visitor the visitor
- * @see IPreferenceNodeVisitor#visit(IEclipsePreferences)
- * @throws BackingStoreException
- */
- public void accept(IPreferenceNodeVisitor visitor) throws BackingStoreException;
-}
diff --git a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/IExportedPreferences.java b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/IExportedPreferences.java
deleted file mode 100644
index 70ad2de98..000000000
--- a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/IExportedPreferences.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime.preferences;
-
-/**
- * Represents a node in the preference hierarchy which is used in
- * the import/export mechanism.
- * <p>
- * This interface is not intended to be implemented by clients.
- * </p>
- * @since 3.0
- */
-public interface IExportedPreferences extends IEclipsePreferences {
-
- /**
- * Return <code>true</code> if this node was an export root
- * when the preferences were exported, and <code>false</code>
- * otherwise. This information is used during the import to clear
- * nodes when importing a node's (and its children's) preferences.
- *
- * @return <code>true</code> if this node is an export root
- * and <code>false</code> otherwise
- */
- public boolean isExportRoot();
-
-}
diff --git a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/IPreferenceFilter.java b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/IPreferenceFilter.java
deleted file mode 100644
index ff44b1c31..000000000
--- a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/IPreferenceFilter.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime.preferences;
-
-import java.util.Map;
-
-/**
- * Preference filters are used to describe the relationship between the
- * preference tree and a data set when importing/exporting preferences.
- * <p>
- * For instance, a client is able to create a preference filter describing
- * which preference nodes/keys should be used when exporting the
- * "Key Bindings" preferences. When the export happens, the tree is
- * trimmed and only the applicable preferences will be exported.
- * </p>
- * <p>
- * Clients may implement this interface.
- * </p>
- *
- * @since 3.1
- */
-public interface IPreferenceFilter {
-
- /**
- * Return an array of scopes that this preference filter is applicable for. The list
- * of scopes must not be <code>null</code>.
- * <p>
- * For example:
- * <code>new String[] {InstanceScope.SCOPE, ConfigurationScope.SCOPE};</code>
- * </p>
- *
- * @return the array of scopes
- */
- public String[] getScopes();
-
- /**
- * Return a mapping which defines the nodes and keys that this filter
- * applies to.
- * <p>
- * If the map is <code>null</code> then this filter is applicable for all
- * nodes within the scope. The map can also be <code>null</code> if
- * the given scope is not known to this filter.
- * </p>
- * <p>
- * The keys in the table are Strings and describe the node path. The values are
- * an optional array of {@link PreferenceFilterEntry} objects describing the list of
- * applicable keys in that node. If the value is null then the whole node is
- * considered applicable.
- * </p>
- * <p>
- * key: <code>String</code> (node)<br>
- * value: <code>PreferenceFilterEntry[]</code> or <code>null</code> (preference keys)<br>
- * </p>
- * <p>
- * For example:
- * <pre>
- * "org.eclipse.core.resources" -> null
- * "org.eclipse.ui" -> new PreferenceFilterEntry[] {
- * new PreferenceFilterEntry("DEFAULT_PERSPECTIVE_LOCATION"),
- * new PreferenceFilterEntry("SHOW_INTRO_ON_STARTUP")}
- * </pre>
- * </p>
- *
- * @return the mapping table
- * @see PreferenceFilterEntry
- */
- public Map getMapping(String scope);
-
-}
diff --git a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/IPreferenceNodeVisitor.java b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/IPreferenceNodeVisitor.java
deleted file mode 100644
index 7d2a61f12..000000000
--- a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/IPreferenceNodeVisitor.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime.preferences;
-
-import org.osgi.service.prefs.BackingStoreException;
-
-/**
- * This interface is implemented by objects that visit preference nodes.
- * <p>
- * Usage:
- * <pre>
- * class Visitor implements IPreferenceNodeVisitor {
- * public boolean visit(IEclipsePreferences node) {
- * // your code here
- * return true;
- * }
- * }
- * IEclipsePreferences root = ...;
- * root.accept(new Visitor());
- * </pre>
- * </p><p>
- * Clients may implement this interface.
- * </p>
- *
- * @see IEclipsePreferences#accept(IPreferenceNodeVisitor)
- * @since 3.0
- */
-public interface IPreferenceNodeVisitor {
-
- /**
- * Visits the given preference node.
- *
- * @param node the node to visit
- * @return <code>true</code> if the node's children should
- * be visited; <code>false</code> if they should be skipped
- * @throws BackingStoreException
- */
- public boolean visit(IEclipsePreferences node) throws BackingStoreException;
-}
diff --git a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/IPreferencesService.java b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/IPreferencesService.java
deleted file mode 100644
index 142870098..000000000
--- a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/IPreferencesService.java
+++ /dev/null
@@ -1,618 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime.preferences;
-
-import java.io.InputStream;
-import java.io.OutputStream;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.osgi.service.prefs.Preferences;
-
-/**
- * The preference service provides facilities for dealing with the default scope
- * precedence lookup order, querying the preference store for values using this order,
- * accessing the root of the preference store node hierarchy, and importing/exporting
- * preferences.
- * <p>
- * The default-default preference search look-up order as defined by the platform
- * is: project, instance, configuration, default.
- * </p><p>
- * This interface is not intended to be implemented by clients.
- * </p>
- * @since 3.0
- */
-public interface IPreferencesService {
-
- /**
- * Lookup the given key in the specified preference nodes in the given order.
- * Return the value from the first node the key is found in. If the key is not
- * defined in any of the given nodes, then return the specified default value.
- * <p>
- * Immediately returns the default value if the node list is <code>null</code>.
- * If any of the individual entries in the node list are <code>null</code> then
- * skip over them and move on to the next node in the list.
- * </p>
- * @param key the preference key
- * @param defaultValue the default value
- * @param nodes the list of nodes to search, or <code>null</code>
- * @return the stored preference value or the specified default value
- * @see org.osgi.service.prefs.Preferences
- */
- public String get(String key, String defaultValue, Preferences[] nodes);
-
- /**
- * Return the value stored in the preference store for the given key.
- * If the key is not defined then return the specified default value.
- * Use the canonical scope lookup order for finding the preference value.
- * <p>
- * The semantics of this method are to calculate the appropriate
- * {@link Preferences} nodes in the preference hierarchy to use
- * and then call the {@link #get(String, String, Preferences[])}
- * method. The order of the nodes is calculated by consulting the default
- * scope lookup order as set by {@link #setDefaultLookupOrder(String, String, String[])}.
- * </p><p>
- * The specified key may either refer to a simple key or be the concatenation of the
- * path of a child node and key. If the key contains a slash ("/") character, then a
- * double-slash must be used to denote the end of they child path and the beginning
- * of the key. Otherwise it is assumed that the key is the last segment of the path.
- * The following are some examples of keys and their meanings:
- * <ul>
- * <li>"a" - look for a value for the property "a"
- * <li>"//a" - look for a value for the property "a"
- * <li>"///a" - look for a value for the property "/a"
- * <li>"//a//b" - look for a value for the property "a//b"
- * <li>"a/b/c" - look in the child node "a/b" for property "c"
- * <li>"/a/b/c" - look in the child node "a/b" for property "c"
- * <li>"/a/b//c" - look in the child node "a/b" for the property "c"
- * <li>"a/b//c/d" - look in the child node "a/b" for the property "c/d"
- * <li>"/a/b//c/d" - look in the child node "a/b" for the property "c/d"
- * <li>"/a/b//c//d" - look in the child node "a/b" for the property "c//d"
- * </ul>
- * </p><p>
- * Callers may specify an array of scope context objects to aid in the
- * determination of the correct nodes. For each entry in the lookup
- * order, the array of contexts is consulted and if one matching the
- * scope exists, then it is used to calculate the node. Otherwise a
- * default calculation algorithm is used.
- * </p><p>
- * An example of a qualifier for an Eclipse 2.1 preference is the
- * plug-in identifier. (e.g. "org.eclipse.core.resources" for "description.autobuild")
- * </p>
- * @param qualifier a namespace qualifier for the preference
- * @param key the name of the preference (optionally including its path)
- * @param defaultValue the value to use if the preference is not defined
- * @param contexts optional context objects to help scopes determine which nodes to search, or <code>null</code>
- * @return the value of the preference or the given default value
- * @see IScopeContext
- * @see #get(java.lang.String, java.lang.String, org.osgi.service.prefs.Preferences[])
- * @see #getLookupOrder(java.lang.String, java.lang.String)
- * @see #getDefaultLookupOrder(java.lang.String, java.lang.String)
- */
- public boolean getBoolean(String qualifier, String key, boolean defaultValue, IScopeContext[] contexts);
-
- /**
- * Return the value stored in the preference store for the given key.
- * If the key is not defined then return the specified default value.
- * Use the canonical scope lookup order for finding the preference value.
- * <p>
- * The semantics of this method are to calculate the appropriate
- * {@link Preferences} nodes in the preference hierarchy to use
- * and then call the {@link #get(String, String, Preferences[])}
- * method. The order of the nodes is calculated by consulting the default
- * scope lookup order as set by {@link #setDefaultLookupOrder(String, String, String[])}.
- * </p><p>
- * The specified key may either refer to a simple key or be the concatenation of the
- * path of a child node and key. If the key contains a slash ("/") character, then a
- * double-slash must be used to denote the end of they child path and the beginning
- * of the key. Otherwise it is assumed that the key is the last segment of the path.
- * The following are some examples of keys and their meanings:
- * <ul>
- * <li>"a" - look for a value for the property "a"
- * <li>"//a" - look for a value for the property "a"
- * <li>"///a" - look for a value for the property "/a"
- * <li>"//a//b" - look for a value for the property "a//b"
- * <li>"a/b/c" - look in the child node "a/b" for property "c"
- * <li>"/a/b/c" - look in the child node "a/b" for property "c"
- * <li>"/a/b//c" - look in the child node "a/b" for the property "c"
- * <li>"a/b//c/d" - look in the child node "a/b" for the property "c/d"
- * <li>"/a/b//c/d" - look in the child node "a/b" for the property "c/d"
- * <li>"/a/b//c//d" - look in the child node "a/b" for the property "c//d"
- * </ul>
- * </p><p>
- * Callers may specify an array of scope context objects to aid in the
- * determination of the correct nodes. For each entry in the lookup
- * order, the array of contexts is consulted and if one matching the
- * scope exists, then it is used to calculate the node. Otherwise a
- * default calculation algorithm is used.
- * </p><p>
- * An example of a qualifier for an Eclipse 2.1 preference is the
- * plug-in identifier. (e.g. "org.eclipse.core.resources" for "description.autobuild")
- * </p>
- * @param qualifier a namespace qualifier for the preference
- * @param key the name of the preference (optionally including its path)
- * @param defaultValue the value to use if the preference is not defined
- * @param contexts optional context objects to help scopes determine which nodes to search, or <code>null</code>
- * @return the value of the preference or the given default value
- * @see IScopeContext
- * @see #get(java.lang.String, java.lang.String, org.osgi.service.prefs.Preferences[])
- * @see #getLookupOrder(java.lang.String, java.lang.String)
- * @see #getDefaultLookupOrder(java.lang.String, java.lang.String)
- */
- public byte[] getByteArray(String qualifier, String key, byte[] defaultValue, IScopeContext[] contexts);
-
- /**
- * Return the value stored in the preference store for the given key.
- * If the key is not defined then return the specified default value.
- * Use the canonical scope lookup order for finding the preference value.
- * <p>
- * The semantics of this method are to calculate the appropriate
- * {@link Preferences} nodes in the preference hierarchy to use
- * and then call the {@link #get(String, String, Preferences[])}
- * method. The order of the nodes is calculated by consulting the default
- * scope lookup order as set by {@link #setDefaultLookupOrder(String, String, String[])}.
- * </p><p>
- * The specified key may either refer to a simple key or be the concatenation of the
- * path of a child node and key. If the key contains a slash ("/") character, then a
- * double-slash must be used to denote the end of they child path and the beginning
- * of the key. Otherwise it is assumed that the key is the last segment of the path.
- * The following are some examples of keys and their meanings:
- * <ul>
- * <li>"a" - look for a value for the property "a"
- * <li>"//a" - look for a value for the property "a"
- * <li>"///a" - look for a value for the property "/a"
- * <li>"//a//b" - look for a value for the property "a//b"
- * <li>"a/b/c" - look in the child node "a/b" for property "c"
- * <li>"/a/b/c" - look in the child node "a/b" for property "c"
- * <li>"/a/b//c" - look in the child node "a/b" for the property "c"
- * <li>"a/b//c/d" - look in the child node "a/b" for the property "c/d"
- * <li>"/a/b//c/d" - look in the child node "a/b" for the property "c/d"
- * <li>"/a/b//c//d" - look in the child node "a/b" for the property "c//d"
- * </ul>
- * </p><p>
- * Callers may specify an array of scope context objects to aid in the
- * determination of the correct nodes. For each entry in the lookup
- * order, the array of contexts is consulted and if one matching the
- * scope exists, then it is used to calculate the node. Otherwise a
- * default calculation algorithm is used.
- * </p><p>
- * An example of a qualifier for an Eclipse 2.1 preference is the
- * plug-in identifier. (e.g. "org.eclipse.core.resources" for "description.autobuild")
- * </p>
- * @param qualifier a namespace qualifier for the preference
- * @param key the name of the preference (optionally including its path)
- * @param defaultValue the value to use if the preference is not defined
- * @param contexts optional context objects to help scopes determine which nodes to search, or <code>null</code>
- * @return the value of the preference or the given default value
- * @see IScopeContext
- * @see #get(java.lang.String, java.lang.String, org.osgi.service.prefs.Preferences[])
- * @see #getLookupOrder(java.lang.String, java.lang.String)
- * @see #getDefaultLookupOrder(java.lang.String, java.lang.String)
- */
- public double getDouble(String qualifier, String key, double defaultValue, IScopeContext[] contexts);
-
- /**
- * Return the value stored in the preference store for the given key.
- * If the key is not defined then return the specified default value.
- * Use the canonical scope lookup order for finding the preference value.
- * <p>
- * The semantics of this method are to calculate the appropriate
- * {@link Preferences} nodes in the preference hierarchy to use
- * and then call the {@link #get(String, String, Preferences[])}
- * method. The order of the nodes is calculated by consulting the default
- * scope lookup order as set by {@link #setDefaultLookupOrder(String, String, String[])}.
- * </p><p>
- * The specified key may either refer to a simple key or be the concatenation of the
- * path of a child node and key. If the key contains a slash ("/") character, then a
- * double-slash must be used to denote the end of they child path and the beginning
- * of the key. Otherwise it is assumed that the key is the last segment of the path.
- * The following are some examples of keys and their meanings:
- * <ul>
- * <li>"a" - look for a value for the property "a"
- * <li>"//a" - look for a value for the property "a"
- * <li>"///a" - look for a value for the property "/a"
- * <li>"//a//b" - look for a value for the property "a//b"
- * <li>"a/b/c" - look in the child node "a/b" for property "c"
- * <li>"/a/b/c" - look in the child node "a/b" for property "c"
- * <li>"/a/b//c" - look in the child node "a/b" for the property "c"
- * <li>"a/b//c/d" - look in the child node "a/b" for the property "c/d"
- * <li>"/a/b//c/d" - look in the child node "a/b" for the property "c/d"
- * <li>"/a/b//c//d" - look in the child node "a/b" for the property "c//d"
- * </ul>
- * </p><p>
- * Callers may specify an array of scope context objects to aid in the
- * determination of the correct nodes. For each entry in the lookup
- * order, the array of contexts is consulted and if one matching the
- * scope exists, then it is used to calculate the node. Otherwise a
- * default calculation algorithm is used.
- * </p><p>
- * An example of a qualifier for an Eclipse 2.1 preference is the
- * plug-in identifier. (e.g. "org.eclipse.core.resources" for "description.autobuild")
- * </p>
- * @param qualifier a namespace qualifier for the preference
- * @param key the name of the preference (optionally including its path)
- * @param defaultValue the value to use if the preference is not defined
- * @param contexts optional context objects to help scopes determine which nodes to search, or <code>null</code>
- * @return the value of the preference or the given default value
- * @see IScopeContext
- * @see #get(java.lang.String, java.lang.String, org.osgi.service.prefs.Preferences[])
- * @see #getLookupOrder(java.lang.String, java.lang.String)
- * @see #getDefaultLookupOrder(java.lang.String, java.lang.String)
- */
- public float getFloat(String qualifier, String key, float defaultValue, IScopeContext[] contexts);
-
- /**
- * Return the value stored in the preference store for the given key.
- * If the key is not defined then return the specified default value.
- * Use the canonical scope lookup order for finding the preference value.
- * <p>
- * The semantics of this method are to calculate the appropriate
- * {@link Preferences} nodes in the preference hierarchy to use
- * and then call the {@link #get(String, String, Preferences[])}
- * method. The order of the nodes is calculated by consulting the default
- * scope lookup order as set by {@link #setDefaultLookupOrder(String, String, String[])}.
- * </p><p>
- * The specified key may either refer to a simple key or be the concatenation of the
- * path of a child node and key. If the key contains a slash ("/") character, then a
- * double-slash must be used to denote the end of they child path and the beginning
- * of the key. Otherwise it is assumed that the key is the last segment of the path.
- * The following are some examples of keys and their meanings:
- * <ul>
- * <li>"a" - look for a value for the property "a"
- * <li>"//a" - look for a value for the property "a"
- * <li>"///a" - look for a value for the property "/a"
- * <li>"//a//b" - look for a value for the property "a//b"
- * <li>"a/b/c" - look in the child node "a/b" for property "c"
- * <li>"/a/b/c" - look in the child node "a/b" for property "c"
- * <li>"/a/b//c" - look in the child node "a/b" for the property "c"
- * <li>"a/b//c/d" - look in the child node "a/b" for the property "c/d"
- * <li>"/a/b//c/d" - look in the child node "a/b" for the property "c/d"
- * <li>"/a/b//c//d" - look in the child node "a/b" for the property "c//d"
- * </ul>
- * </p><p>
- * Callers may specify an array of scope context objects to aid in the
- * determination of the correct nodes. For each entry in the lookup
- * order, the array of contexts is consulted and if one matching the
- * scope exists, then it is used to calculate the node. Otherwise a
- * default calculation algorithm is used.
- * </p><p>
- * An example of a qualifier for an Eclipse 2.1 preference is the
- * plug-in identifier. (e.g. "org.eclipse.core.resources" for "description.autobuild")
- * </p>
- * @param qualifier a namespace qualifier for the preference
- * @param key the name of the preference (optionally including its path)
- * @param defaultValue the value to use if the preference is not defined
- * @param contexts optional context objects to help scopes determine which nodes to search, or <code>null</code>
- * @return the value of the preference or the given default value
- * @see IScopeContext
- * @see #get(java.lang.String, java.lang.String, org.osgi.service.prefs.Preferences[])
- * @see #getLookupOrder(java.lang.String, java.lang.String)
- * @see #getDefaultLookupOrder(java.lang.String, java.lang.String)
- */
- public int getInt(String qualifier, String key, int defaultValue, IScopeContext[] contexts);
-
- /**
- * Return the value stored in the preference store for the given key.
- * If the key is not defined then return the specified default value.
- * Use the canonical scope lookup order for finding the preference value.
- * <p>
- * The semantics of this method are to calculate the appropriate
- * {@link Preferences} nodes in the preference hierarchy to use
- * and then call the {@link #get(String, String, Preferences[])}
- * method. The order of the nodes is calculated by consulting the default
- * scope lookup order as set by {@link #setDefaultLookupOrder(String, String, String[])}.
- * </p><p>
- * The specified key may either refer to a simple key or be the concatenation of the
- * path of a child node and key. If the key contains a slash ("/") character, then a
- * double-slash must be used to denote the end of they child path and the beginning
- * of the key. Otherwise it is assumed that the key is the last segment of the path.
- * The following are some examples of keys and their meanings:
- * <ul>
- * <li>"a" - look for a value for the property "a"
- * <li>"//a" - look for a value for the property "a"
- * <li>"///a" - look for a value for the property "/a"
- * <li>"//a//b" - look for a value for the property "a//b"
- * <li>"a/b/c" - look in the child node "a/b" for property "c"
- * <li>"/a/b/c" - look in the child node "a/b" for property "c"
- * <li>"/a/b//c" - look in the child node "a/b" for the property "c"
- * <li>"a/b//c/d" - look in the child node "a/b" for the property "c/d"
- * <li>"/a/b//c/d" - look in the child node "a/b" for the property "c/d"
- * <li>"/a/b//c//d" - look in the child node "a/b" for the property "c//d"
- * </ul>
- * </p><p>
- * Callers may specify an array of scope context objects to aid in the
- * determination of the correct nodes. For each entry in the lookup
- * order, the array of contexts is consulted and if one matching the
- * scope exists, then it is used to calculate the node. Otherwise a
- * default calculation algorithm is used.
- * </p><p>
- * An example of a qualifier for an Eclipse 2.1 preference is the
- * plug-in identifier. (e.g. "org.eclipse.core.resources" for "description.autobuild")
- * </p>
- * @param qualifier a namespace qualifier for the preference
- * @param key the name of the preference (optionally including its path)
- * @param defaultValue the value to use if the preference is not defined
- * @param contexts optional context objects to help scopes determine which nodes to search, or <code>null</code>
- * @return the value of the preference or the given default value
- * @see IScopeContext
- * @see #get(java.lang.String, java.lang.String, org.osgi.service.prefs.Preferences[])
- * @see #getLookupOrder(java.lang.String, java.lang.String)
- * @see #getDefaultLookupOrder(java.lang.String, java.lang.String)
- */
- public long getLong(String qualifier, String key, long defaultValue, IScopeContext[] contexts);
-
- /**
- * Return the value stored in the preference store for the given key.
- * If the key is not defined then return the specified default value.
- * Use the canonical scope lookup order for finding the preference value.
- * <p>
- * The semantics of this method are to calculate the appropriate
- * {@link Preferences} nodes in the preference hierarchy to use
- * and then call the {@link #get(String, String, Preferences[])}
- * method. The order of the nodes is calculated by consulting the default
- * scope lookup order as set by {@link #setDefaultLookupOrder(String, String, String[])}.
- * </p><p>
- * The specified key may either refer to a simple key or be the concatenation of the
- * path of a child node and key. If the key contains a slash ("/") character, then a
- * double-slash must be used to denote the end of they child path and the beginning
- * of the key. Otherwise it is assumed that the key is the last segment of the path.
- * The following are some examples of keys and their meanings:
- * <ul>
- * <li>"a" - look for a value for the property "a"
- * <li>"//a" - look for a value for the property "a"
- * <li>"///a" - look for a value for the property "/a"
- * <li>"//a//b" - look for a value for the property "a//b"
- * <li>"a/b/c" - look in the child node "a/b" for property "c"
- * <li>"/a/b/c" - look in the child node "a/b" for property "c"
- * <li>"/a/b//c" - look in the child node "a/b" for the property "c"
- * <li>"a/b//c/d" - look in the child node "a/b" for the property "c/d"
- * <li>"/a/b//c/d" - look in the child node "a/b" for the property "c/d"
- * <li>"/a/b//c//d" - look in the child node "a/b" for the property "c//d"
- * </ul>
- * </p><p>
- * Callers may specify an array of scope context objects to aid in the
- * determination of the correct nodes. For each entry in the lookup
- * order, the array of contexts is consulted and if one matching the
- * scope exists, then it is used to calculate the node. Otherwise a
- * default calculation algorithm is used.
- * </p><p>
- * An example of a qualifier for an Eclipse 2.1 preference is the
- * plug-in identifier. (e.g. "org.eclipse.core.resources" for "description.autobuild")
- * </p>
- * @param qualifier a namespace qualifier for the preference
- * @param key the name of the preference (optionally including its path)
- * @param defaultValue the value to use if the preference is not defined
- * @param contexts optional context objects to help scopes determine which nodes to search, or <code>null</code>
- * @return the value of the preference or the given default value
- * @see IScopeContext
- * @see #get(java.lang.String, java.lang.String, org.osgi.service.prefs.Preferences[])
- * @see #getLookupOrder(java.lang.String, java.lang.String)
- * @see #getDefaultLookupOrder(java.lang.String, java.lang.String)
- */
- public String getString(String qualifier, String key, String defaultValue, IScopeContext[] contexts);
-
- /**
- * Return the root node of the Eclipse preference hierarchy.
- *
- * @return the root of the hierarchy
- */
- public IEclipsePreferences getRootNode();
-
- /**
- * Exports all preferences for the given preference node and all its children to the specified
- * output stream. It is the responsibility of the client to close the given output stream.
- * <p>
- * If the given export list is <code>null</code> then all preferences for all sub-nodes
- * of the given node are exported to the given stream. Otherwise the export list is
- * consulted before exporting each preference value. If there is a string match then
- * the preference is not exported. The exclusion can also occur at a per-node level.
- * Wild cards are <em>not</em> accepted in the excludes list as a basic String compare
- * is done. The basic algorithm is similar to the following:
- * <pre>
- * String fullPath = node.absolutePath() + '/' + key;
- * if (!fullPath.startsWith(excludesList[i]))
- * // export preference
- * </pre>
- * </p>
- * <p>
- * The values stored in the resulting stream are suitable for later being read by the
- * by {@link #importPreferences(InputStream)} or {@link #readPreferences(InputStream)} methods.
- * </p>
- * @param node the node to treat as the root of the export
- * @param output the stream to write to
- * @param excludesList a list of path prefixes to exclude from the export, or <code>null</code>
- * @return a status object describing success or detailing failure reasons
- * @throws CoreException if there was a problem exporting the preferences
- * @throws IllegalArgumentException if the node or stream is <code>null</code>
- * @see #importPreferences(java.io.InputStream)
- * @see #readPreferences(InputStream)
- */
- public IStatus exportPreferences(IEclipsePreferences node, OutputStream output, String[] excludesList) throws CoreException;
-
- /**
- * Loads preferences from the given file and stores them in the preferences store.
- * Existing values are over-ridden by those from the stream. The stream must not be
- * <code>null</code> and is closed upon return from this method.
- * <p>
- * This file must have been written by the
- * {@link #exportPreferences(IEclipsePreferences, OutputStream, String[])}
- * method.
- * </p>
- * <p>
- * This method is equivalent to calling <code>applyPreferences(readPreferences(input));</code>.
- * </p>
- * @param input the stream to load the preferences from
- * @return a status object describing success or detailing failure reasons
- * @throws CoreException if there are problems importing the preferences
- * @throws IllegalArgumentException if the stream is <code>null</code>
- * @see #exportPreferences(IEclipsePreferences, OutputStream, String[])
- */
- public IStatus importPreferences(InputStream input) throws CoreException;
-
- /**
- * Take the given preference tree and apply it to the Eclipse
- * global preference hierarchy. If a node is an export root, then
- * remove it from the global tree before adding any preferences
- * contained in it or its children. The given preferences object
- * must not be <code>null</code>.
- * <p>
- * Before the tree is applied to the global preference tree,
- * the registered <code>PreferenceModifyListener</code> objects
- * are called and given the opportunity to modify the tree.
- * </p>
- *
- * @param preferences the preferences to apply globally
- * @return status object indicating success or failure
- * @throws IllegalArgumentException if the preferences are <code>null</code>
- * @throws CoreException if there are problems applying the preferences
- * @see PreferenceModifyListener
- */
- public IStatus applyPreferences(IExportedPreferences preferences) throws CoreException;
-
- /**
- * Read from the given input stream and create a node hierarchy
- * representing the preferences and their values. The given input stream
- * must not be <code>null</code>. The result of this function is suitable
- * for passing as an argument to {@link #applyPreferences(IExportedPreferences)}.
- * <p>
- * It is assumed the contents of the input stream have been written by
- * {@link #exportPreferences(IEclipsePreferences, OutputStream, String[])}.
- * </p>
- * @param input the input stream to read from
- * @return the node hierarchy representing the stream contents
- * @throws IllegalArgumentException if the given stream is null
- * @throws CoreException if there are problems reading the preferences
- * @see #exportPreferences(IEclipsePreferences, OutputStream, String[])
- * @see #applyPreferences(IExportedPreferences)
- */
- public IExportedPreferences readPreferences(InputStream input) throws CoreException;
-
- /**
- * Return an array with the default lookup order for the preference keyed by the given
- * qualifier and simple name. Return <code>null</code> if no default has been set.
- * <p>
- * The lookup order returned is based on an exact match to the specified qualifier
- * and simple name. For instance, if the given key is non-<code>null</code> and
- * no default lookup order is found, the default lookup order for the qualifier (and a
- * <code>null</code> key) is <em>NOT</em> returned. Clients should call
- * {@link #getLookupOrder(String, String)} if they desire this behavior.
- * </p>
- * @param qualifier the namespace qualifier for the preference
- * @param key the preference name or <code>null</code>
- * @return the scope order or <code>null</code>
- * @see #setDefaultLookupOrder(String, String, String[])
- * @see #getLookupOrder(String, String)
- */
- public String[] getDefaultLookupOrder(String qualifier, String key);
-
- /**
- * Return an array with the lookup order for the preference keyed by the given
- * qualifier and simple name.
- * <p>
- * First do an exact match lookup with the given qualifier and simple name. If a match
- * is found then return it. Otherwise if the key is non-<code>null</code> then
- * do a lookup based on only the qualifier and return the set value.
- * Return the default-default order as defined by the platform if no order has been set.
- * </p>
- * @param qualifier the namespace qualifier for the preference
- * @param key the preference name or <code>null</code>
- * @return the scope order
- * @throws IllegalArgumentException if the qualifier is <code>null</code>
- * @see #getDefaultLookupOrder(String, String)
- * @see #setDefaultLookupOrder(String, String, String[])
- */
- public String[] getLookupOrder(String qualifier, String key);
-
- /**
- * Set the default scope lookup order for the preference keyed by the given
- * qualifier and simple name. If the given order is <code>null</code> then the set
- * ordering (if it exists) is removed.
- * <p>
- * If the given simple name is <code>null</code> then set the given lookup
- * order to be used for all keys with the given qualifier.
- * </p><p>
- * Note that the default lookup order is not persisted across platform invocations.
- * </p>
- * @param qualifier the namespace qualifier for the preference
- * @param key the preference name or <code>null</code>
- * @param order the lookup order or <code>null</code>
- * @throws IllegalArgumentException
- * <ul>
- * <li>if the qualifier is <code>null</code></li>
- * <li>if an entry in the order array is <code>null</code> (the array itself is
- * allowed to be <code>null</code></li>
- * </ul>
- * @see #getDefaultLookupOrder(String, String)
- */
- public void setDefaultLookupOrder(String qualifier, String key, String[] order);
-
- /**
- * Export the preference tree rooted at the given node, to the specified output
- * stream. Apply the given list of preference filters, only exporting
- * preference node and keys which are applicable to at least one filter in the list.
- * <p>
- * The given node and output stream must not be <code>null</code>.
- * If the list of filters is <code>null</code> or empty then do nothing.
- * </p>
- * <p>
- * It is the responsibility of the client to close the given output stream.
- * </p>
- *
- * @param node the tree to export
- * @param filters the list of filters to export
- * @param output the stream to export to
- * @throws CoreException
- * @see #exportPreferences(IEclipsePreferences, OutputStream, String[])
- * @see #readPreferences(InputStream)
- * @see #applyPreferences(IEclipsePreferences, IPreferenceFilter[])
- * @see #applyPreferences(IExportedPreferences)
- * @see IPreferenceFilter
- * @since 3.1
- */
- public void exportPreferences(IEclipsePreferences node, IPreferenceFilter[] filters, OutputStream output) throws CoreException;
-
- /**
- * Return a list of filters which match the given tree and is a subset of the given
- * filter list. If the specified list of filters is <code>null</code>, empty, or there
- * are no matches, then return an empty list.
- *
- * @param node the tree to match against
- * @param filters the list of filters to match against
- * @return the array of matching transfers
- * @throws CoreException
- * @see IPreferenceFilter
- * @since 3.1
- */
- public IPreferenceFilter[] matches(IEclipsePreferences node, IPreferenceFilter[] filters) throws CoreException;
-
- /**
- * Apply the preference tree rooted at the given node, to the system's preference tree.
- * The list of preference filters will act as a filter and only preferences in the tree which
- * apply to at least one filter in the list, will be applied.
- * <p>
- * If the list of filters is <code>null</code> or empty then do nothing.
- * </p>
- * <p>
- * Before the tree is applied to the global preference tree,
- * the registered <code>PreferenceModifyListener</code> objects
- * are called and given the opportunity to modify the tree.
- * </p>
- *
- * @param node the tree to consider applying
- * @param filters the filters to use
- * @throws CoreException
- * @see #applyPreferences(IExportedPreferences)
- * @see #readPreferences(InputStream)
- * @see IPreferenceFilter
- * @see PreferenceModifyListener
- * @since 3.1
- */
- public void applyPreferences(IEclipsePreferences node, IPreferenceFilter[] filters) throws CoreException;
-}
diff --git a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/IProductPreferencesService.java b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/IProductPreferencesService.java
deleted file mode 100644
index be739dbf1..000000000
--- a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/IProductPreferencesService.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime.preferences;
-
-import java.util.Properties;
-
-/**
- * A product can customize preferences by implementing this service.
- *
- * @since org.eclipse.equinox.preferences 1.0
- */
-public interface IProductPreferencesService {
- /**
- * @return default preferences specified by the product.
- */
- public Properties getProductCustomization();
-
- /**
- * @return translation table for default preferences
- */
- public Properties getProductTranslation();
-}
diff --git a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/IScope.java b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/IScope.java
deleted file mode 100644
index 29d3c1936..000000000
--- a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/IScope.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime.preferences;
-
-/**
- * Clients contributing a scope to the Eclipse preference system must
- * implement this interface to aid Eclipse in creating a new node for the
- * hierarchy.
- * <p>
- * Clients may implement this interface.
- * </p>
- * @since 3.0
- */
-public interface IScope {
-
- /**
- * Create and return a new preference node with the given parent and name.
- * Must not return <code>null</code>. Clients are able to create a new node
- * in memory or load the node's contents from the backing store. Neither the
- * parent or name arguments should be <code>null</code>.
- * <p>
- * Implementors should note that the node might not have been added to the
- * child list of the parent yet, and therefore might not be able to be referenced
- * through navigation from the root node.
- * </p>
- * @param parent the node's parent
- * @param name the name of the node
- * @return the new node
- */
- public IEclipsePreferences create(IEclipsePreferences parent, String name);
-}
diff --git a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/IScopeContext.java b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/IScopeContext.java
deleted file mode 100644
index f1fd7607f..000000000
--- a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/IScopeContext.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime.preferences;
-
-import org.eclipse.core.runtime.IPath;
-
-/**
- * Clients implement this interface to provide context to a
- * particular scope. Instances of implementations of this interface are
- * passed to the {@link IPreferencesService} for use in
- * preference searching.
- * <p>
- * Clients may implement this interface.
- * </p>
- *
- * @see IPreferencesService
- * @since 3.0
- */
-public interface IScopeContext {
-
- /**
- * Return the name of the scope that this context is associated with.
- * Must not be <code>null</code>.
- *
- * @return the name of the scope
- */
- public String getName();
-
- /**
- * Return the preferences node that contains the preferences for the
- * given qualifier or <code>null</code> if the node cannot be determined.
- * The given qualifier must not be <code>null</code> but may be a path
- * to a sub-node within the scope.
- * <p>
- * An example of a qualifier in Eclipse 2.1 would be the plug-in identifier that
- * the preference is associated with (e.g. the "org.eclipse.core.resources"
- * plug-in defines the "description.autobuild" preference).
- * </p><p>
- * This method can be used to determine the appropriate preferences node
- * to aid in setting key/value pairs. For instance:
- * <code>new InstanceScope().getNode("org.eclipse.core.resources");</code>
- * returns the preference node in the instance scope where the preferences
- * for "org.eclipse.core.resources" are stored.
- * </p>
- * @param qualifier a qualifier for the preference name
- * @return the node containing the plug-in preferences or <code>null</code>
- * @see IPreferencesService
- */
- public IEclipsePreferences getNode(String qualifier);
-
- /**
- * Return a path to a location in the file-system where clients are able
- * to write files that will have the same sharing/scope properties as
- * preferences defined in this scope.
- * <p>
- * Implementors may return <code>null</code> if the location is not known,
- * is unavailable, or is not applicable to this scope.
- * </p>
- * @return a writable location in the file system or <code>null</code>
- */
- public IPath getLocation();
-}
diff --git a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/InstanceScope.java b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/InstanceScope.java
deleted file mode 100644
index 1ce5512a9..000000000
--- a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/InstanceScope.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime.preferences;
-
-import org.eclipse.core.internal.preferences.AbstractScope;
-import org.eclipse.core.runtime.IPath;
-
-/**
- * Object representing the instance scope in the Eclipse preferences
- * hierarchy. Can be used as a context for searching for preference
- * values (in the IPreferencesService APIs) or for determining the
- * correct preference node to set values in the store.
- * <p>
- * Instance preferences are stored on a per instance basis in the
- * platform's instance area as specified by {@link org.eclipse.core.runtime.Platform#getInstanceLocation}.
- * </p><p>
- * The path for preferences defined in the instance scope hierarchy
- * is as follows: <code>/instance/&lt;qualifier&gt;</code>
- * </p>
- * <p>
- * This class is not intended to be subclassed. This class may be instantiated.
- * </p>
- * @see org.eclipse.core.runtime.Platform#getInstanceLocation()
- * @since 3.0
- */
-public final class InstanceScope extends AbstractScope implements IScopeContext {
-
- /**
- * String constant (value of <code>"instance"</code>) used for the
- * scope name for the instance preference scope.
- */
- public static final String SCOPE = "instance"; //$NON-NLS-1$
-
- /**
- * Create and return a new instance scope instance.
- */
- public InstanceScope() {
- super();
- }
-
- /*
- * @see org.eclipse.core.runtime.preferences.IScopeContext#getLocation()
- */
- public IPath getLocation() {
- // Return null. The instance location usually corresponds to the state
- // location of the bundle and we don't know what bundle we are dealing with.
- return null;
- }
-
- /*
- * @see org.eclipse.core.runtime.preferences.IScopeContext#getName()
- */
- public String getName() {
- return SCOPE;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.preferences.IScopeContext#getNode(java.lang.String)
- */
- public IEclipsePreferences getNode(String qualifier) {
- return super.getNode(qualifier);
- }
-}
diff --git a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/PreferenceFilterEntry.java b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/PreferenceFilterEntry.java
deleted file mode 100644
index dc6470f31..000000000
--- a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/PreferenceFilterEntry.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime.preferences;
-
-/**
- * Class which represents and preference filter entry to be used during preference
- * import/export (for example).
- *
- * @since 3.1
- * @see org.eclipse.core.runtime.preferences.IPreferenceFilter
- */
-public final class PreferenceFilterEntry {
-
- private String key;
-
- /**
- * Constructor for the class. Create a new preference filter entry with the given
- * key. The key must <em>not</em> be <code>null</code> or empty.
- *
- * @param key the name of the preference key
- */
- public PreferenceFilterEntry(String key) {
- super();
- if (key == null || key.length() == 0)
- throw new IllegalArgumentException();
- this.key = key;
- }
-
- /**
- * Return the name of the preference key for this filter entry.
- * It will <em>not</em> return <code>null</code> or the
- * empty string.
- *
- * @return the name of the preference key
- */
- public String getKey() {
- return key;
- }
-}
diff --git a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/PreferenceModifyListener.java b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/PreferenceModifyListener.java
deleted file mode 100644
index 7149a3ac2..000000000
--- a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/PreferenceModifyListener.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime.preferences;
-
-/**
- * This class provides a hook into the preference service before particular operations
- * on the global preference tree. Preference modify listeners are registered with
- * the preference service via XML and the <code>org.eclipse.core.runtime.preferences</code>
- * extension point.
- * <p>
- * Clients may subclass this type.
- * </p>
- *
- * @since 3.1
- */
-public abstract class PreferenceModifyListener {
-
- /**
- * Clients are given the opportunity to modify the given tree before it is applied
- * to the global preference tree. Clients should return the tree which should be
- * applied globally. The tree passed in will not be <code>null</code> and clients
- * <em>must not</em> return a <code>null</code> tree.
- * <p>
- * This method is called by the preference service from within calls to
- * {@link IPreferencesService#applyPreferences(IExportedPreferences)} or
- * {@link IPreferencesService#applyPreferences(IEclipsePreferences, IPreferenceFilter[])}.
- * </p>
- * <p>
- * A typical action for clients to perform would be to intercept the incoming preference tree,
- * migrate old preference values to new ones, and then return the new tree.
- * </p>
- *
- * @param node the tree to modify
- * @return the tree to apply to the global preferences
- */
- public IEclipsePreferences preApply(IEclipsePreferences node) {
- // default implementation makes no modifications
- return node;
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/package.html b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/package.html
deleted file mode 100644
index 7c88d888b..000000000
--- a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/package.html
+++ /dev/null
@@ -1,17 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <title>Package-level Javadoc</title>
-</head>
-<body>
-Provides core support for Eclipse preferences.
-<h2>
-Package Specification</h2>
-<p>
-This package specifies API for defining and accessing preferences in the runtime.
-<p>
-@since 3.0
-<p>
-</body>
-</html>
diff --git a/bundles/org.eclipse.equinox.preferences/src/org/osgi/service/prefs/BackingStoreException.java b/bundles/org.eclipse.equinox.preferences/src/org/osgi/service/prefs/BackingStoreException.java
deleted file mode 100644
index cad818066..000000000
--- a/bundles/org.eclipse.equinox.preferences/src/org/osgi/service/prefs/BackingStoreException.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * $Header: /home/eclipse/org.eclipse.core.runtime/src/org/osgi/service/prefs/BackingStoreException.java,v 1.5 2005/11/11 22:07:19 johna Exp $
- *
- * Copyright (c) OSGi Alliance (2001, 2005). 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.
- */
-package org.osgi.service.prefs;
-
-/**
- * Thrown to indicate that a preferences operation could not complete because of
- * a failure in the backing store, or a failure to contact the backing store.
- *
- * @version $Revision: 1.5 $
- */
-public class BackingStoreException extends Exception {
- static final long serialVersionUID = -1415637364122829574L;
- /**
- * Nested exception.
- */
- private Throwable cause;
-
- /**
- * Constructs a <code>BackingStoreException</code> with the specified detail
- * message.
- *
- * @param s The detail message.
- */
- public BackingStoreException(String s) {
- super(s);
- }
-
- /**
- * Constructs a <code>BackingStoreException</code> with the specified detail
- * message.
- *
- * @param s The detail message.
- * @param cause The cause of the exception. May be <code>null</code>.
- * @since 1.1
- */
- public BackingStoreException(String s, Throwable cause) {
- super(s);
- this.cause = cause;
- }
-
- /**
- * Returns the cause of this exception or <code>null</code> if no cause was
- * specified when this exception was created.
- *
- * @return The cause of this exception or <code>null</code> if no cause was
- * specified.
- * @since 1.1
- */
- public Throwable getCause() {
- return cause;
- }
-
- /**
- * The cause of this exception can only be set when constructed.
- *
- * @param cause Cause of the exception.
- * @return This object.
- * @throws java.lang.IllegalStateException This method will always throw an
- * <code>IllegalStateException</code> since the cause of this
- * exception can only be set when constructed.
- * @since 1.1
- */
- public Throwable initCause(Throwable cause) {
- throw new IllegalStateException();
- }
-
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.preferences/src/org/osgi/service/prefs/Preferences.java b/bundles/org.eclipse.equinox.preferences/src/org/osgi/service/prefs/Preferences.java
deleted file mode 100644
index 09dd2fd56..000000000
--- a/bundles/org.eclipse.equinox.preferences/src/org/osgi/service/prefs/Preferences.java
+++ /dev/null
@@ -1,694 +0,0 @@
-/*
- * $Header: /home/eclipse/org.eclipse.core.runtime/src/org/osgi/service/prefs/Preferences.java,v 1.4 2005/11/11 22:07:19 johna Exp $
- *
- * Copyright (c) OSGi Alliance (2001, 2005). 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.
- */
-package org.osgi.service.prefs;
-
-/**
- * A node in a hierarchical collection of preference data.
- *
- * <p>
- * This interface allows applications to store and retrieve user and system
- * preference data. This data is stored persistently in an
- * implementation-dependent backing store. Typical implementations include flat
- * files, OS-specific registries, directory servers and SQL databases.
- *
- * <p>
- * For each bundle, there is a separate tree of nodes for each user, and one for
- * system preferences. The precise description of "user" and "system" will vary
- * from one bundle to another. Typical information stored in the user preference
- * tree might include font choice, and color choice for a bundle which interacts
- * with the user via a servlet. Typical information stored in the system
- * preference tree might include installation data, or things like high score
- * information for a game program.
- *
- * <p>
- * Nodes in a preference tree are named in a similar fashion to directories in a
- * hierarchical file system. Every node in a preference tree has a <i>node name
- * </i> (which is not necessarily unique), a unique <i>absolute path name </i>,
- * and a path name <i>relative </i> to each ancestor including itself.
- *
- * <p>
- * The root node has a node name of the empty <code>String</code> object ("").
- * Every other node has an arbitrary node name, specified at the time it is
- * created. The only restrictions on this name are that it cannot be the empty
- * string, and it cannot contain the slash character ('/').
- *
- * <p>
- * The root node has an absolute path name of <code>"/"</code>. Children of the
- * root node have absolute path names of <code>"/" + </code> <i>&lt;node name&gt;
- * </i>. All other nodes have absolute path names of <i>&lt;parent's absolute
- * path name&gt; </i> <code> + "/" + </code> <i>&lt;node name&gt; </i>. Note that
- * all absolute path names begin with the slash character.
- *
- * <p>
- * A node <i>n </i>'s path name relative to its ancestor <i>a </i> is simply the
- * string that must be appended to <i>a </i>'s absolute path name in order to
- * form <i>n </i>'s absolute path name, with the initial slash character (if
- * present) removed. Note that:
- * <ul>
- * <li>No relative path names begin with the slash character.
- * <li>Every node's path name relative to itself is the empty string.
- * <li>Every node's path name relative to its parent is its node name (except
- * for the root node, which does not have a parent).
- * <li>Every node's path name relative to the root is its absolute path name
- * with the initial slash character removed.
- * </ul>
- *
- * <p>
- * Note finally that:
- * <ul>
- * <li>No path name contains multiple consecutive slash characters.
- * <li>No path name with the exception of the root's absolute path name end in
- * the slash character.
- * <li>Any string that conforms to these two rules is a valid path name.
- * </ul>
- *
- * <p>
- * Each <code>Preference</code> node has zero or more properties associated with
- * it, where a property consists of a name and a value. The bundle writer is
- * free to choose any appropriate names for properties. Their values can be of
- * type <code>String</code>,<code>long</code>,<code>int</code>,<code>boolean</code>,
- * <code>byte[]</code>,<code>float</code>, or <code>double</code> but they can
- * always be accessed as if they were <code>String</code> objects.
- *
- * <p>
- * All node name and property name comparisons are case-sensitive.
- *
- * <p>
- * All of the methods that modify preference data are permitted to operate
- * asynchronously; they may return immediately, and changes will eventually
- * propagate to the persistent backing store, with an implementation-dependent
- * delay. The <code>flush</code> method may be used to synchronously force updates
- * to the backing store.
- *
- * <p>
- * Implementations must automatically attempt to flush to the backing store any
- * pending updates for a bundle's preferences when the bundle is stopped or
- * otherwise ungets the Preferences Service.
- *
- * <p>
- * The methods in this class may be invoked concurrently by multiple threads in
- * a single Java Virtual Machine (JVM) without the need for external
- * synchronization, and the results will be equivalent to some serial execution.
- * If this class is used concurrently <i>by multiple JVMs </i> that store their
- * preference data in the same backing store, the data store will not be
- * corrupted, but no other guarantees are made concerning the consistency of the
- * preference data.
- *
- *
- * @version $Revision: 1.4 $
- */
-public interface Preferences {
- /**
- * Associates the specified value with the specified key in this node.
- *
- * @param key key with which the specified value is to be associated.
- * @param value value to be associated with the specified key.
- * @throws NullPointerException if <code>key</code> or <code>value</code> is
- * <code>null</code>.
- * @throws IllegalStateException if this node (or an ancestor) has been
- * removed with the {@link #removeNode()}method.
- */
- public void put(String key, String value);
-
- /**
- * Returns the value associated with the specified <code>key</code> in this
- * node. Returns the specified default if there is no value associated with
- * the <code>key</code>, or the backing store is inaccessible.
- *
- * @param key key whose associated value is to be returned.
- * @param def the value to be returned in the event that this node has no
- * value associated with <code>key</code> or the backing store is
- * inaccessible.
- * @return the value associated with <code>key</code>, or <code>def</code> if
- * no value is associated with <code>key</code>.
- * @throws IllegalStateException if this node (or an ancestor) has been
- * removed with the {@link #removeNode()}method.
- * @throws NullPointerException if <code>key</code> is <code>null</code>. (A
- * <code>null</code> default <i>is </i> permitted.)
- */
- public String get(String key, String def);
-
- /**
- * Removes the value associated with the specified <code>key</code> in this
- * node, if any.
- *
- * @param key key whose mapping is to be removed from this node.
- * @see #get(String,String)
- * @throws IllegalStateException if this node (or an ancestor) has been
- * removed with the {@link #removeNode()}method.
- */
- public void remove(String key);
-
- /**
- * Removes all of the properties (key-value associations) in this node. This
- * call has no effect on any descendants of this node.
- *
- * @throws BackingStoreException if this operation cannot be completed due
- * to a failure in the backing store, or inability to communicate
- * with it.
- * @throws IllegalStateException if this node (or an ancestor) has been
- * removed with the {@link #removeNode()}method.
- * @see #remove(String)
- */
- public void clear() throws BackingStoreException;
-
- /**
- * Associates a <code>String</code> object representing the specified
- * <code>int</code> value with the specified <code>key</code> in this node. The
- * associated string is the one that would be returned if the <code>int</code>
- * value were passed to <code>Integer.toString(int)</code>. This method is
- * intended for use in conjunction with {@link #getInt}method.
- *
- * <p>
- * Implementor's note: it is <i>not </i> necessary that the property value
- * be represented by a <code>String</code> object in the backing store. If the
- * backing store supports integer values, it is not unreasonable to use
- * them. This implementation detail is not visible through the
- * <code>Preferences</code> API, which allows the value to be read as an
- * <code>int</code> (with <code>getInt</code> or a <code>String</code> (with
- * <code>get</code>) type.
- *
- * @param key key with which the string form of value is to be associated.
- * @param value <code>value</code> whose string form is to be associated with
- * <code>key</code>.
- * @throws NullPointerException if <code>key</code> is <code>null</code>.
- * @throws IllegalStateException if this node (or an ancestor) has been
- * removed with the {@link #removeNode()}method.
- * @see #getInt(String,int)
- */
- public void putInt(String key, int value);
-
- /**
- * Returns the <code>int</code> value represented by the <code>String</code>
- * object associated with the specified <code>key</code> in this node. The
- * <code>String</code> object is converted to an <code>int</code> as by
- * <code>Integer.parseInt(String)</code>. Returns the specified default if
- * there is no value associated with the <code>key</code>, the backing store
- * is inaccessible, or if <code>Integer.parseInt(String)</code> would throw a
- * <code>NumberFormatException</code> if the associated <code>value</code> were
- * passed. This method is intended for use in conjunction with the
- * {@link #putInt}method.
- *
- * @param key key whose associated value is to be returned as an
- * <code>int</code>.
- * @param def the value to be returned in the event that this node has no
- * value associated with <code>key</code> or the associated value
- * cannot be interpreted as an <code>int</code> or the backing store is
- * inaccessible.
- * @return the <code>int</code> value represented by the <code>String</code>
- * object associated with <code>key</code> in this node, or
- * <code>def</code> if the associated value does not exist or cannot
- * be interpreted as an <code>int</code> type.
- * @throws NullPointerException if <code>key</code> is <code>null</code>.
- * @throws IllegalStateException if this node (or an ancestor) has been
- * removed with the {@link #removeNode()}method.
- * @see #putInt(String,int)
- * @see #get(String,String)
- */
- public int getInt(String key, int def);
-
- /**
- * Associates a <code>String</code> object representing the specified
- * <code>long</code> value with the specified <code>key</code> in this node. The
- * associated <code>String</code> object is the one that would be returned if
- * the <code>long</code> value were passed to <code>Long.toString(long)</code>.
- * This method is intended for use in conjunction with the {@link #getLong}
- * method.
- *
- * <p>
- * Implementor's note: it is <i>not </i> necessary that the <code>value</code>
- * be represented by a <code>String</code> type in the backing store. If the
- * backing store supports <code>long</code> values, it is not unreasonable to
- * use them. This implementation detail is not visible through the <code>
- * Preferences</code> API, which allows the value to be read as a
- * <code>long</code> (with <code>getLong</code> or a <code>String</code> (with
- * <code>get</code>) type.
- *
- * @param key <code>key</code> with which the string form of <code>value</code>
- * is to be associated.
- * @param value <code>value</code> whose string form is to be associated with
- * <code>key</code>.
- * @throws NullPointerException if <code>key</code> is <code>null</code>.
- * @throws IllegalStateException if this node (or an ancestor) has been
- * removed with the {@link #removeNode()}method.
- * @see #getLong(String,long)
- */
- public void putLong(String key, long value);
-
- /**
- * Returns the <code>long</code> value represented by the <code>String</code>
- * object associated with the specified <code>key</code> in this node. The
- * <code>String</code> object is converted to a <code>long</code> as by
- * <code>Long.parseLong(String)</code>. Returns the specified default if
- * there is no value associated with the <code>key</code>, the backing store
- * is inaccessible, or if <code>Long.parseLong(String)</code> would throw a
- * <code>NumberFormatException</code> if the associated <code>value</code> were
- * passed. This method is intended for use in conjunction with the
- * {@link #putLong}method.
- *
- * @param key <code>key</code> whose associated value is to be returned as a
- * <code>long</code> value.
- * @param def the value to be returned in the event that this node has no
- * value associated with <code>key</code> or the associated value
- * cannot be interpreted as a <code>long</code> type or the backing
- * store is inaccessible.
- * @return the <code>long</code> value represented by the <code>String</code>
- * object associated with <code>key</code> in this node, or
- * <code>def</code> if the associated value does not exist or cannot
- * be interpreted as a <code>long</code> type.
- * @throws NullPointerException if <code>key</code> is <code>null</code>.
- * @throws IllegalStateException if this node (or an ancestor) has been
- * removed with the {@link #removeNode()}method.
- * @see #putLong(String,long)
- * @see #get(String,String)
- */
- public long getLong(String key, long def);
-
- /**
- * Associates a <code>String</code> object representing the specified
- * <code>boolean</code> value with the specified key in this node. The
- * associated string is "true" if the value is <code>true</code>, and "false"
- * if it is <code>false</code>. This method is intended for use in
- * conjunction with the {@link #getBoolean}method.
- *
- * <p>
- * Implementor's note: it is <i>not </i> necessary that the value be
- * represented by a string in the backing store. If the backing store
- * supports <code>boolean</code> values, it is not unreasonable to use them.
- * This implementation detail is not visible through the <code>Preferences
- * </code> API, which allows the value to be read as a <code>boolean</code>
- * (with <code>getBoolean</code>) or a <code>String</code> (with <code>get</code>)
- * type.
- *
- * @param key <code>key</code> with which the string form of value is to be
- * associated.
- * @param value value whose string form is to be associated with
- * <code>key</code>.
- * @throws NullPointerException if <code>key</code> is <code>null</code>.
- * @throws IllegalStateException if this node (or an ancestor) has been
- * removed with the {@link #removeNode()}method.
- * @see #getBoolean(String,boolean)
- * @see #get(String,String)
- */
- public void putBoolean(String key, boolean value);
-
- /**
- * Returns the <code>boolean</code> value represented by the <code>String</code>
- * object associated with the specified <code>key</code> in this node. Valid
- * strings are "true", which represents <code>true</code>, and "false", which
- * represents <code>false</code>. Case is ignored, so, for example, "TRUE"
- * and "False" are also valid. This method is intended for use in
- * conjunction with the {@link #putBoolean}method.
- *
- * <p>
- * Returns the specified default if there is no value associated with the
- * <code>key</code>, the backing store is inaccessible, or if the associated
- * value is something other than "true" or "false", ignoring case.
- *
- * @param key <code>key</code> whose associated value is to be returned as a
- * <code>boolean</code>.
- * @param def the value to be returned in the event that this node has no
- * value associated with <code>key</code> or the associated value
- * cannot be interpreted as a <code>boolean</code> or the backing store
- * is inaccessible.
- * @return the <code>boolean</code> value represented by the <code>String</code>
- * object associated with <code>key</code> in this node, or
- * <code>null</code> if the associated value does not exist or cannot
- * be interpreted as a <code>boolean</code>.
- * @throws NullPointerException if <code>key</code> is <code>null</code>.
- * @throws IllegalStateException if this node (or an ancestor) has been
- * removed with the {@link #removeNode()}method.
- * @see #get(String,String)
- * @see #putBoolean(String,boolean)
- */
- public boolean getBoolean(String key, boolean def);
-
- /**
- * Associates a <code>String</code> object representing the specified
- * <code>float</code> value with the specified <code>key</code> in this node.
- * The associated <code>String</code> object is the one that would be returned
- * if the <code>float</code> value were passed to
- * <code>Float.toString(float)</code>. This method is intended for use in
- * conjunction with the {@link #getFloat}method.
- *
- * <p>
- * Implementor's note: it is <i>not </i> necessary that the value be
- * represented by a string in the backing store. If the backing store
- * supports <code>float</code> values, it is not unreasonable to use them.
- * This implementation detail is not visible through the <code>Preferences
- * </code> API, which allows the value to be read as a <code>float</code> (with
- * <code>getFloat</code>) or a <code>String</code> (with <code>get</code>) type.
- *
- * @param key <code>key</code> with which the string form of value is to be
- * associated.
- * @param value value whose string form is to be associated with
- * <code>key</code>.
- * @throws NullPointerException if <code>key</code> is <code>null</code>.
- * @throws IllegalStateException if this node (or an ancestor) has been
- * removed with the {@link #removeNode()}method.
- * @see #getFloat(String,float)
- */
- public void putFloat(String key, float value);
-
- /**
- * Returns the float <code>value</code> represented by the <code>String</code>
- * object associated with the specified <code>key</code> in this node. The
- * <code>String</code> object is converted to a <code>float</code> value as by
- * <code>Float.parseFloat(String)</code>. Returns the specified default if
- * there is no value associated with the <code>key</code>, the backing store
- * is inaccessible, or if <code>Float.parseFloat(String)</code> would throw a
- * <code>NumberFormatException</code> if the associated value were passed.
- * This method is intended for use in conjunction with the {@link #putFloat}
- * method.
- *
- * @param key <code>key</code> whose associated value is to be returned as a
- * <code>float</code> value.
- * @param def the value to be returned in the event that this node has no
- * value associated with <code>key</code> or the associated value
- * cannot be interpreted as a <code>float</code> type or the backing
- * store is inaccessible.
- * @return the <code>float</code> value represented by the string associated
- * with <code>key</code> in this node, or <code>def</code> if the
- * associated value does not exist or cannot be interpreted as a
- * <code>float</code> type.
- * @throws IllegalStateException if this node (or an ancestor) has been
- * removed with the {@link #removeNode()}method.
- * @throws NullPointerException if <code>key</code> is <code>null</code>.
- * @see #putFloat(String,float)
- * @see #get(String,String)
- */
- public float getFloat(String key, float def);
-
- /**
- * Associates a <code>String</code> object representing the specified
- * <code>double</code> value with the specified <code>key</code> in this node.
- * The associated <code>String</code> object is the one that would be returned
- * if the <code>double</code> value were passed to
- * <code>Double.toString(double)</code>. This method is intended for use in
- * conjunction with the {@link #getDouble}method
- *
- * <p>
- * Implementor's note: it is <i>not </i> necessary that the value be
- * represented by a string in the backing store. If the backing store
- * supports <code>double</code> values, it is not unreasonable to use them.
- * This implementation detail is not visible through the <code>Preferences
- * </code> API, which allows the value to be read as a <code>double</code> (with
- * <code>getDouble</code>) or a <code>String</code> (with <code>get</code>)
- * type.
- *
- * @param key <code>key</code> with which the string form of value is to be
- * associated.
- * @param value value whose string form is to be associated with
- * <code>key</code>.
- * @throws NullPointerException if <code>key</code> is <code>null</code>.
- * @throws IllegalStateException if this node (or an ancestor) has been
- * removed with the {@link #removeNode()}method.
- * @see #getDouble(String,double)
- */
- public void putDouble(String key, double value);
-
- /**
- * Returns the <code>double</code> value represented by the <code>String</code>
- * object associated with the specified <code>key</code> in this node. The
- * <code>String</code> object is converted to a <code>double</code> value as by
- * <code>Double.parseDouble(String)</code>. Returns the specified default if
- * there is no value associated with the <code>key</code>, the backing store
- * is inaccessible, or if <code>Double.parseDouble(String)</code> would throw
- * a <code>NumberFormatException</code> if the associated value were passed.
- * This method is intended for use in conjunction with the
- * {@link #putDouble}method.
- *
- * @param key <code>key</code> whose associated value is to be returned as a
- * <code>double</code> value.
- * @param def the value to be returned in the event that this node has no
- * value associated with <code>key</code> or the associated value
- * cannot be interpreted as a <code>double</code> type or the backing
- * store is inaccessible.
- * @return the <code>double</code> value represented by the <code>String</code>
- * object associated with <code>key</code> in this node, or
- * <code>def</code> if the associated value does not exist or cannot
- * be interpreted as a <code>double</code> type.
- * @throws IllegalStateException if this node (or an ancestor) has been
- * removed with the the {@link #removeNode()}method.
- * @throws NullPointerException if <code>key</code> is <code>null</code>.
- * @see #putDouble(String,double)
- * @see #get(String,String)
- */
- public double getDouble(String key, double def);
-
- /**
- * Associates a <code>String</code> object representing the specified
- * <code>byte[]</code> with the specified <code>key</code> in this node. The
- * associated <code>String</code> object the <i>Base64 </i> encoding of the
- * <code>byte[]</code>, as defined in <a
- * href="http://www.ietf.org/rfc/rfc2045.txt">RFC 2045 </a>, Section 6.8,
- * with one minor change: the string will consist solely of characters from
- * the <i>Base64 Alphabet </i>; it will not contain any newline characters.
- * This method is intended for use in conjunction with the
- * {@link #getByteArray}method.
- *
- * <p>
- * Implementor's note: it is <i>not </i> necessary that the value be
- * represented by a <code>String</code> type in the backing store. If the
- * backing store supports <code>byte[]</code> values, it is not unreasonable
- * to use them. This implementation detail is not visible through the <code>
- * Preferences</code> API, which allows the value to be read as an a
- * <code>byte[]</code> object (with <code>getByteArray</code>) or a
- * <code>String</code> object (with <code>get</code>).
- *
- * @param key <code>key</code> with which the string form of <code>value</code>
- * is to be associated.
- * @param value <code>value</code> whose string form is to be associated with
- * <code>key</code>.
- * @throws NullPointerException if <code>key</code> or <code>value</code> is
- * <code>null</code>.
- * @throws IllegalStateException if this node (or an ancestor) has been
- * removed with the {@link #removeNode()}method.
- * @see #getByteArray(String,byte[])
- * @see #get(String,String)
- */
- public void putByteArray(String key, byte[] value);
-
- /**
- * Returns the <code>byte[]</code> value represented by the <code>String</code>
- * object associated with the specified <code>key</code> in this node. Valid
- * <code>String</code> objects are <i>Base64 </i> encoded binary data, as
- * defined in <a href="http://www.ietf.org/rfc/rfc2045.txt">RFC 2045 </a>,
- * Section 6.8, with one minor change: the string must consist solely of
- * characters from the <i>Base64 Alphabet </i>; no newline characters or
- * extraneous characters are permitted. This method is intended for use in
- * conjunction with the {@link #putByteArray}method.
- *
- * <p>
- * Returns the specified default if there is no value associated with the
- * <code>key</code>, the backing store is inaccessible, or if the associated
- * value is not a valid Base64 encoded byte array (as defined above).
- *
- * @param key <code>key</code> whose associated value is to be returned as a
- * <code>byte[]</code> object.
- * @param def the value to be returned in the event that this node has no
- * value associated with <code>key</code> or the associated value
- * cannot be interpreted as a <code>byte[]</code> type, or the backing
- * store is inaccessible.
- * @return the <code>byte[]</code> value represented by the <code>String</code>
- * object associated with <code>key</code> in this node, or
- * <code>def</code> if the associated value does not exist or cannot
- * be interpreted as a <code>byte[]</code>.
- * @throws NullPointerException if <code>key</code> is <code>null</code>. (A
- * <code>null</code> value for <code>def</code> <i>is </i> permitted.)
- * @throws IllegalStateException if this node (or an ancestor) has been
- * removed with the {@link #removeNode()}method.
- * @see #get(String,String)
- * @see #putByteArray(String,byte[])
- */
- public byte[] getByteArray(String key, byte[] def);
-
- /**
- * Returns all of the keys that have an associated value in this node. (The
- * returned array will be of size zero if this node has no preferences and
- * not <code>null</code>!)
- *
- * @return an array of the keys that have an associated value in this node.
- * @throws BackingStoreException if this operation cannot be completed due
- * to a failure in the backing store, or inability to communicate
- * with it.
- * @throws IllegalStateException if this node (or an ancestor) has been
- * removed with the {@link #removeNode()}method.
- */
- public String[] keys() throws BackingStoreException;
-
- /**
- * Returns the names of the children of this node. (The returned array will
- * be of size zero if this node has no children and not <code>null</code>!)
- *
- * @return the names of the children of this node.
- * @throws BackingStoreException if this operation cannot be completed due
- * to a failure in the backing store, or inability to communicate
- * with it.
- * @throws IllegalStateException if this node (or an ancestor) has been
- * removed with the {@link #removeNode()}method.
- */
- public String[] childrenNames() throws BackingStoreException;
-
- /**
- * Returns the parent of this node, or <code>null</code> if this is the root.
- *
- * @return the parent of this node.
- * @throws IllegalStateException if this node (or an ancestor) has been
- * removed with the {@link #removeNode()}method.
- */
- public Preferences parent();
-
- /**
- * Returns a named <code>Preferences</code> object (node), creating it and any
- * of its ancestors if they do not already exist. Accepts a relative or
- * absolute pathname. Absolute pathnames (which begin with <code>'/'</code>)
- * are interpreted relative to the root of this node. Relative pathnames
- * (which begin with any character other than <code>'/'</code>) are
- * interpreted relative to this node itself. The empty string (<code>""</code>)
- * is a valid relative pathname, referring to this node itself.
- *
- * <p>
- * If the returned node did not exist prior to this call, this node and any
- * ancestors that were created by this call are not guaranteed to become
- * persistent until the <code>flush</code> method is called on the returned
- * node (or one of its descendants).
- *
- * @param pathName the path name of the <code>Preferences</code> object to
- * return.
- * @return the specified <code>Preferences</code> object.
- * @throws IllegalArgumentException if the path name is invalid.
- * @throws IllegalStateException if this node (or an ancestor) has been
- * removed with the {@link #removeNode()}method.
- * @throws NullPointerException if path name is <code>null</code>.
- * @see #flush()
- */
- public Preferences node(String pathName);
-
- /**
- * Returns true if the named node exists. Accepts a relative or absolute
- * pathname. Absolute pathnames (which begin with <code>'/'</code>) are
- * interpreted relative to the root of this node. Relative pathnames (which
- * begin with any character other than <code>'/'</code>) are interpreted
- * relative to this node itself. The pathname <code>""</code> is valid, and
- * refers to this node itself.
- *
- * <p>
- * If this node (or an ancestor) has already been removed with the
- * {@link #removeNode()}method, it <i>is </i> legal to invoke this method,
- * but only with the pathname <code>""</code>; the invocation will return
- * <code>false</code>. Thus, the idiom <code>p.nodeExists("")</code> may be
- * used to test whether <code>p</code> has been removed.
- *
- * @param pathName the path name of the node whose existence is to be
- * checked.
- * @return true if the specified node exists.
- * @throws BackingStoreException if this operation cannot be completed due
- * to a failure in the backing store, or inability to communicate
- * with it.
- * @throws IllegalStateException if this node (or an ancestor) has been
- * removed with the {@link #removeNode()}method and
- * <code>pathname</code> is not the empty string (<code>""</code>).
- * @throws IllegalArgumentException if the path name is invalid (i.e., it
- * contains multiple consecutive slash characters, or ends with a
- * slash character and is more than one character long).
- */
- public boolean nodeExists(String pathName)
- throws BackingStoreException;
-
- /**
- * Removes this node and all of its descendants, invalidating any properties
- * contained in the removed nodes. Once a node has been removed, attempting
- * any method other than <code>name()</code>,<code>absolutePath()</code> or
- * <code>nodeExists("")</code> on the corresponding <code>Preferences</code>
- * instance will fail with an <code>IllegalStateException</code>. (The
- * methods defined on <code>Object</code> can still be invoked on a node after
- * it has been removed; they will not throw <code>IllegalStateException</code>.)
- *
- * <p>
- * The removal is not guaranteed to be persistent until the <code>flush</code>
- * method is called on the parent of this node.
- *
- * @throws IllegalStateException if this node (or an ancestor) has already
- * been removed with the {@link #removeNode()}method.
- * @throws BackingStoreException if this operation cannot be completed due
- * to a failure in the backing store, or inability to communicate
- * with it.
- * @see #flush()
- */
- public void removeNode() throws BackingStoreException;
-
- /**
- * Returns this node's name, relative to its parent.
- *
- * @return this node's name, relative to its parent.
- */
- public String name();
-
- /**
- * Returns this node's absolute path name. Note that:
- * <ul>
- * <li>Root node - The path name of the root node is <code>"/"</code>.
- * <li>Slash at end - Path names other than that of the root node may not
- * end in slash (<code>'/'</code>).
- * <li>Unusual names -<code>"."</code> and <code>".."</code> have <i>no </i>
- * special significance in path names.
- * <li>Illegal names - The only illegal path names are those that contain
- * multiple consecutive slashes, or that end in slash and are not the root.
- * </ul>
- *
- * @return this node's absolute path name.
- */
- public String absolutePath();
-
- /**
- * Forces any changes in the contents of this node and its descendants to
- * the persistent store.
- *
- * <p>
- * Once this method returns successfully, it is safe to assume that all
- * changes made in the subtree rooted at this node prior to the method
- * invocation have become permanent.
- *
- * <p>
- * Implementations are free to flush changes into the persistent store at
- * any time. They do not need to wait for this method to be called.
- *
- * <p>
- * When a flush occurs on a newly created node, it is made persistent, as
- * are any ancestors (and descendants) that have yet to be made persistent.
- * Note however that any properties value changes in ancestors are <i>not
- * </i> guaranteed to be made persistent.
- *
- * @throws BackingStoreException if this operation cannot be completed due
- * to a failure in the backing store, or inability to communicate
- * with it.
- * @throws IllegalStateException if this node (or an ancestor) has been
- * removed with the {@link #removeNode()}method.
- * @see #sync()
- */
- public void flush() throws BackingStoreException;
-
- /**
- * Ensures that future reads from this node and its descendants reflect any
- * changes that were committed to the persistent store (from any VM) prior
- * to the <code>sync</code> invocation. As a side-effect, forces any changes
- * in the contents of this node and its descendants to the persistent store,
- * as if the <code>flush</code> method had been invoked on this node.
- *
- * @throws BackingStoreException if this operation cannot be completed due
- * to a failure in the backing store, or inability to communicate
- * with it.
- * @throws IllegalStateException if this node (or an ancestor) has been
- * removed with the {@link #removeNode()}method.
- * @see #flush()
- */
- public void sync() throws BackingStoreException;
-}
diff --git a/bundles/org.eclipse.equinox.preferences/src/org/osgi/service/prefs/PreferencesService.java b/bundles/org.eclipse.equinox.preferences/src/org/osgi/service/prefs/PreferencesService.java
deleted file mode 100644
index 41331bcc0..000000000
--- a/bundles/org.eclipse.equinox.preferences/src/org/osgi/service/prefs/PreferencesService.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * $Header: /home/eclipse/org.eclipse.core.runtime/src/org/osgi/service/prefs/PreferencesService.java,v 1.4 2005/11/11 22:07:19 johna Exp $
- *
- * Copyright (c) OSGi Alliance (2001, 2005). 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.
- */
-package org.osgi.service.prefs;
-
-/**
- * The Preferences Service.
- *
- * <p>
- * Each bundle using this service has its own set of preference trees: one for
- * system preferences, and one for each user.
- *
- * <p>
- * A <code>PreferencesService</code> object is specific to the bundle which
- * obtained it from the service registry. If a bundle wishes to allow another
- * bundle to access its preferences, it should pass its
- * <code>PreferencesService</code> object to that bundle.
- *
- */
-public interface PreferencesService {
- /**
- * Returns the root system node for the calling bundle.
- *
- * @return The root system node for the calling bundle.
- */
- public Preferences getSystemPreferences();
-
- /**
- * Returns the root node for the specified user and the calling bundle.
- *
- * @param name The user for which to return the preference root node.
- * @return The root node for the specified user and the calling bundle.
- */
- public Preferences getUserPreferences(String name);
-
- /**
- * Returns the names of users for which node trees exist.
- *
- * @return The names of users for which node trees exist.
- */
- public String[] getUsers();
-}
diff --git a/bundles/org.eclipse.equinox.useradmin/.classpath b/bundles/org.eclipse.equinox.useradmin/.classpath
deleted file mode 100644
index 1fa3e6803..000000000
--- a/bundles/org.eclipse.equinox.useradmin/.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"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/bundles/org.eclipse.equinox.useradmin/.cvsignore b/bundles/org.eclipse.equinox.useradmin/.cvsignore
deleted file mode 100644
index ba077a403..000000000
--- a/bundles/org.eclipse.equinox.useradmin/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
diff --git a/bundles/org.eclipse.equinox.useradmin/.project b/bundles/org.eclipse.equinox.useradmin/.project
deleted file mode 100644
index b878668a1..000000000
--- a/bundles/org.eclipse.equinox.useradmin/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.equinox.useradmin</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.jdt.core.javanature</nature>
- <nature>org.eclipse.pde.PluginNature</nature>
- </natures>
-</projectDescription>
diff --git a/bundles/org.eclipse.equinox.useradmin/.settings/org.eclipse.jdt.core.prefs b/bundles/org.eclipse.equinox.useradmin/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 825f3954b..000000000
--- a/bundles/org.eclipse.equinox.useradmin/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,49 +0,0 @@
-#Fri Dec 16 09:20:48 CST 2005
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
-org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
-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=warning
-org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
-org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
-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=warning
-org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
-org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
-org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
-org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
-org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
-org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
-org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore
-org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
-org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
-org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning
-org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
-org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
-org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
-org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.unusedImport=error
-org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
-org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
-org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
-org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
diff --git a/bundles/org.eclipse.equinox.useradmin/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.useradmin/META-INF/MANIFEST.MF
deleted file mode 100644
index b59383cb3..000000000
--- a/bundles/org.eclipse.equinox.useradmin/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,18 +0,0 @@
-Bundle-ManifestVersion: 2
-Bundle-Vendor: %bundleVendor
-Bundle-Version: 1.0.0.qualifier
-Bundle-Activator: org.eclipse.equinox.useradmin.Activator
-Bundle-Copyright: %bundleCopyright
-Bundle-SymbolicName: org.eclipse.equinox.useradmin
-Import-Service: org.osgi.service.log.LogService
-Bundle-Name: %bundleName
-Export-Service: org.osgi.service.useradmin.UserAdmin
-Import-Package: org.eclipse.osgi.framework.eventmgr,
- org.osgi.framework;version="1.1",
- org.osgi.service.log;version="1.0",
- org.osgi.service.prefs;version="1.0",
- org.osgi.service.useradmin;version="1.0",
- org.osgi.util.tracker;version="1.1",
- org.eclipse.osgi.util
-Export-Package: org.eclipse.equinox.useradmin;x-internal:=true
-Bundle-Localization: plugin
diff --git a/bundles/org.eclipse.equinox.useradmin/about.html b/bundles/org.eclipse.equinox.useradmin/about.html
deleted file mode 100644
index b2f1e6bad..000000000
--- a/bundles/org.eclipse.equinox.useradmin/about.html
+++ /dev/null
@@ -1,22 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
-<!-- saved from url=(0043)http://www.eclipse.org/legal/epl/about.html -->
-<HTML><HEAD><TITLE>About</TITLE>
-<META http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-<META content="MSHTML 6.00.2800.1498" name=GENERATOR></HEAD>
-<BODY lang=EN-US>
-<H2>About This Content</H2>
-<P>February 24, 2005</P>
-<H3>License</H3>
-<P>The Eclipse Foundation makes available all content in this plug-in
-("Content"). Unless otherwise indicated below, the Content is provided to you
-under the terms and conditions of the Eclipse Public License Version 1.0
-("EPL"). A copy of the EPL is available at <A
-href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</A>.
-For purposes of the EPL, "Program" will mean the Content.</P>
-<P>If you did not receive this Content directly from the Eclipse Foundation, the
-Content is being redistributed by another party ("Redistributor") and different
-terms and conditions may apply to your use of any object code in the Content.
-Check the Redistributor's license that was provided with the Content. If no such
-license exists, contact the Redistributor. Unless otherwise indicated below, the
-terms and conditions of the EPL still apply to any source code in the
-Content.</P></BODY></HTML>
diff --git a/bundles/org.eclipse.equinox.useradmin/build.properties b/bundles/org.eclipse.equinox.useradmin/build.properties
deleted file mode 100644
index 873261924..000000000
--- a/bundles/org.eclipse.equinox.useradmin/build.properties
+++ /dev/null
@@ -1,17 +0,0 @@
-###############################################################################
-# Copyright (c) 2005 IBM Corporation.
-# 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:
-# IBM Corporation - initial API and implementation
-###############################################################################
-bin.includes = META-INF/,\
- plugin*.properties,\
- about.html,\
- .
-src.includes = about.html
-source.. = src/
-output.. = bin/
diff --git a/bundles/org.eclipse.equinox.useradmin/plugin.properties b/bundles/org.eclipse.equinox.useradmin/plugin.properties
deleted file mode 100644
index 3bf3c5cb1..000000000
--- a/bundles/org.eclipse.equinox.useradmin/plugin.properties
+++ /dev/null
@@ -1,13 +0,0 @@
-###############################################################################
-# Copyright (c) 2005 IBM Corporation.
-# 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:
-# IBM Corporation - initial API and implementation
-###############################################################################
-bundleVendor = Eclipse.org
-bundleName = User Admin Service
-bundleCopyright = Copyright (c) IBM Corp. 2001, 2005
diff --git a/bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/Activator.java b/bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/Activator.java
deleted file mode 100644
index 487e21451..000000000
--- a/bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/Activator.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.useradmin;
-
-import java.util.Hashtable;
-import org.osgi.framework.*;
-import org.osgi.service.prefs.PreferencesService;
-import org.osgi.util.tracker.ServiceTracker;
-import org.osgi.util.tracker.ServiceTrackerCustomizer;
-
-/** This is the bundle activator for the UserAdmin bundle.
- */
-
-public class Activator implements BundleActivator, ServiceFactory, ServiceTrackerCustomizer {
- /*
- * ----------------------------------------------------------------------
- * BundleActivator Interface implementation
- * ----------------------------------------------------------------------
- */
-
- protected ServiceRegistration registration;
- protected UserAdmin userAdmin;
- protected static String userAdminClazz = "org.osgi.service.useradmin.UserAdmin"; //$NON-NLS-1$
- protected PreferencesService prefs;
- protected BundleContext context;
- protected ServiceTracker prefsTracker;
-
- public Activator() {
- //a public constructor is required for a BundleActivator
- }
-
- /**
- * Required by BundleActivator Interface.
- */
- public void start(BundleContext context_) throws Exception {
- this.context = context_;
- prefsTracker = new ServiceTracker(context, PreferencesService.class.getName(), this);
- prefsTracker.open();
- }
-
- /**
- * Required by BundleActivator Interface.
- */
- public void stop(BundleContext context_) throws Exception {
- prefsTracker.close();
- unregisterUserAdminService();
- }
-
-
- public Object getService(Bundle bundle, ServiceRegistration registration_) {
- userAdmin.setServiceReference(registration_.getReference());
- return userAdmin;
- }
-
- public void ungetService(Bundle bundle, ServiceRegistration registration_, Object service) {
- //do nothing
- }
-
- public Object addingService(ServiceReference reference) {
- if (prefs == null) {
- prefs = (PreferencesService) context.getService(reference);
- try {
- registerUserAdminService();
- } catch (Exception ex) {
- return null;
- }
- return prefs;
- }
- return null; //we don't want to track a service we are not using
- }
-
- public void modifiedService(ServiceReference reference, Object service) {
- // do nothing
- }
-
- public void removedService(ServiceReference reference, Object service) {
- if (service == prefs) {
- prefs = null;
- }
- unregisterUserAdminService();
- }
-
-
- /**
- * Register the UserAdmin service.
- */
- protected void registerUserAdminService() throws Exception {
- Hashtable properties = new Hashtable(7);
-
- properties.put(Constants.SERVICE_VENDOR, UserAdminMsg.Service_Vendor);
- properties.put(Constants.SERVICE_DESCRIPTION, UserAdminMsg.OSGi_User_Admin_service_IBM_Implementation_3);
- properties.put(Constants.SERVICE_PID, getClass().getName());
-
- userAdmin = new UserAdmin(prefs, context);
- registration = context.registerService(userAdminClazz, this, properties);
- userAdmin.setServiceReference(registration.getReference());
- }
-
- protected void unregisterUserAdminService() {
- if(registration != null)
- {
- registration.unregister();
- registration = null;
- userAdmin.destroy();
- userAdmin = null;
- }
- }
-}
diff --git a/bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/Authorization.java b/bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/Authorization.java
deleted file mode 100644
index 50e3a7113..000000000
--- a/bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/Authorization.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.useradmin;
-
-import java.util.Vector;
-
-/**
- * This interface encapsulates an authorization context on which bundles
- * can base authorization decisions where appropriate.
- * <p>
- * Bundles associate the privilege to access restricted resources or
- * operations with roles. Before granting access to a restricted resource
- * or operation, a bundle will check if the Authorization object passed
- * to it possesses the required role, by calling its hasRole method.
- * <p>
- * Authorization contexts are instantiated by calling
- * {@link UserAdmin#getAuthorization}
- * <p>
- * <font size="+1">Trusting Authorization objects.</font>
- * <p>
- * There are no restrictions regarding the creation of Authorization objects.
- * Hence, a service must only accept Authorization objects from bundles that
- * has been authorized to use the service using code based (or Java 2)
- * permissions.
- * <p>
- * In some cases it is useful to use ServicePermissions to do the code based
- * access control. A service basing user access control on Authorization
- * objects passed to it, will then require that a calling bundle has the
- * ServicePermission to get the service in question. This is the most
- * convenient way. The framework will do the code based permission check
- * when the calling bundle attempts to get the service from the service
- * registry.
- * <p>
- * Example: A servlet using a service on a user's behalf. The bundle with the
- * servlet must be given the ServicePermission to get the Service.
- * <p>
- * However, in some cases the code based permission checks need to be more
- * fine-grained. A service might allow all bundles to get it, but
- * require certain code based permissions for some of its methods.
- * <p>
- * Example: A servlet using a service on a user's behalf, where some
- * service functionality is open to anyone, and some is restricted by code
- * based permissions. When a restricted method is called
- * (e.g., one handing over
- * an Authorization object), the service explicitly checks that the calling
- * bundle has permission to make the call.
- */
-public class Authorization implements org.osgi.service.useradmin.Authorization {
-
- protected UserAdmin useradmin;
- protected Role user;
- protected String name; //user to distinguish between the anonymous user and user.anyone
-
- protected Authorization(User user, UserAdmin useradmin) {
- this.useradmin = useradmin;
- if (user != null) {
- this.user = user;
- name = user.getName();
- } else {
- //anonymous user
- this.user = (Role) useradmin.getRole(Role.anyoneString);
- name = null;
- }
- }
-
- /**
- * Gets the name of the {@link User} that this Authorization
- * context was created for.
- *
- * @return The name of the {@link User} that this Authorization
- * context was created for, or <code>null</code> if no user was specified
- * when this Authorization context was created.
- */
- public String getName() {
- useradmin.checkAlive();
- return (name);
- }
-
- /**
- * Checks if the role with the specified name is implied by this
- * Authorization context.
- * <p>
-
- * Bundles must define globally unique role names that are associated with
- * the privilege of accessing restricted resources or operations.
- * System administrators will grant users access to these resources, by
- * creating a {@link Group} for each role and adding {@link User}s to it.
- *
- * @param name The name of the role to check for.
- *
- * @return <code>true</code> if this Authorization context implies the
- * specified role, otherwise <code>false</code>.
- */
- public boolean hasRole(String name_) {
- useradmin.checkAlive();
- synchronized (useradmin) {
- Role checkRole = (org.eclipse.equinox.useradmin.Role) useradmin.getRole(name_);
- if (checkRole == null) {
- return (false);
- }
- return (checkRole.isImpliedBy(user, new Vector()));
- }
- }
-
- /**
- * Gets the names of all roles encapsulated by this Authorization context.
- *
- * @return The names of all roles encapsulated by this Authorization
- * context, or <code>null</code> if no roles are in the context.
- */
- public String[] getRoles() {
- useradmin.checkAlive();
-
- // go through all of the roles and find out which ones are implied by this
- // authorization context.
- synchronized (useradmin) //we don't want anything changing while we get the list
- {
- int length = useradmin.roles.size();
- Vector result = new Vector(length);
- for (int i = 0; i < length; i++) {
- Role role = (Role) useradmin.roles.elementAt(i);
- if (role.isImpliedBy(user, new Vector())) {
- String roleName = role.getName();
- //exclude user.anyone from the list
- if (!roleName.equals(Role.anyoneString))
- {
- result.addElement(roleName);
- }
- }
- }
- int size = result.size();
- if (size == 0) {
- return (null);
- }
- String[] copyrole = new String[size];
- result.copyInto(copyrole);
- return (copyrole);
- }
- }
-}
diff --git a/bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/ExternalMessages.properties b/bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/ExternalMessages.properties
deleted file mode 100644
index 4e658dfd7..000000000
--- a/bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/ExternalMessages.properties
+++ /dev/null
@@ -1,27 +0,0 @@
-###############################################################################
-# Copyright (c) 2001, 2005 IBM Corporation.
-# 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:
-# IBM Corporation - initial API and implementation
-###############################################################################
-# NLS_MESSAGEFORMAT_ALL
-
-OSGi_User_Admin_service_IBM_Implementation_3=OSGi User Admin service - IBM Implementation
-Service_Vendor=IBM
-adding_Credential_to__15=adding Credential to {0}
-adding_member__18=adding member {0} to group {1}
-adding_required_member__21=adding required member {0} to group {1}
-removing_member__24=removing member {0} from group {1}
-Unable_to_load_role__27=Unable to load role {0}
-Backing_Store_Read_Exception=UserAdmin is unable to read its data from backing store {0}
-Backing_Store_Write_Exception=UserAdmin is unable to write its data from backing store {0}
-Event_Delivery_Exception=A UserAdminListener threw an Exception
-CREATE_NULL_ROLE_EXCEPTION =Role can not be null
-CREATE_INVALID_TYPE_ROLE_EXCEPTION=Invalid type for createRole
-INVALID_KEY_EXCEPTION=Key can only be of type String
-INVALID_VALUE_EXCEPTION=Value can only be of type String or byte[]
-USERADMIN_UNREGISTERED_EXCEPTION=UserAdmin service has been unregistered \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/Group.java b/bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/Group.java
deleted file mode 100644
index d744c96ca..000000000
--- a/bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/Group.java
+++ /dev/null
@@ -1,295 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.useradmin;
-
-import java.util.Enumeration;
-import java.util.Vector;
-import org.osgi.service.prefs.BackingStoreException;
-
-/**
- * A named grouping of roles.
- * <p>
- * Whether or not a given authorization context implies a Group role
- * depends on the members of that role.
- * <p>
- * A Group role can have two kinds of member roles: <i>basic</i> and
- * <i>required</i>.
- * A Group role is implied by an authorization context if all of
- * its required member roles are implied
- * and at least one of its basic member roles is implied.
- * <p>
- * A Group role must contain at least one basic member role in order
- * to be implied. In other words, a Group without any basic member
- * roles is never implied by any authorization context.
- * <p>
- * A User role always implies itself.
- * <p>
- * No loop detection is performed when adding members to groups, which
- * means that it is possible to create circular implications. Loop
- * detection is instead done when roles are checked. The semantics is that
- * if a role depends on itself (i.e., there is an implication loop), the
- * role is not implied.
- * <p>
- * The rule that a group must have at least one basic member to be implied
- * is motivated by the following example:
- *
- * <pre>
- * group foo
- * required members: marketing
- * basic members: alice, bob
- * </pre>
- *
- * Privileged operations that require membership in "foo" can be performed
- * only by alice and bob, who are in marketing.
- * <p>
- * If alice and bob ever transfer to a different department, anybody in
- * marketing will be able to assume the "foo" role, which certainly must be
- * prevented.
- * Requiring that "foo" (or any Group role for that matter) must have at least
- * one basic member accomplishes that.
- * <p>
- * However, this would make it impossible for a group to be implied by just
- * its required members. An example where this implication might be useful
- * is the following declaration: "Any citizen who is an adult is allowed to
- * vote."
- * An intuitive configuration of "voter" would be:
- *
- * <pre>
- * group voter
- * required members: citizen, adult
- * basic members:
- * </pre>
- *
- * However, according to the above rule, the "voter" role could never be
- * assumed by anybody, since it lacks any basic members.
- * In order to address this deficiency a predefined role named
- * "user.anyone" can be specified, which is always implied.
- * The desired implication of the "voter" group can then be achieved by
- * specifying "user.anyone" as its basic member, as follows:
- *
- * <pre>
- * group voter
- * required members: citizen, adult
- * basic members: user.anyone
- * </pre>
- */
-
-public class Group extends User implements org.osgi.service.useradmin.Group {
-
- protected Vector requiredMembers;
- protected Vector basicMembers;
-
- protected Group(String name, UserAdmin useradmin) {
- super(name, useradmin);
- this.useradmin = useradmin;
- basicMembers = new Vector();
- requiredMembers = new Vector();
- }
-
- /**
- * Adds the specified role as a basic member to this Group.
- *
- * @param role The role to add as a basic member.
- *
- * @return <code>true</code> if the given role could be added as a basic
- * member,
- * and <code>false</code> if this Group already contains a role whose name
- * matches that of the specified role.
- *
- * @throws SecurityException If a security manager exists and the caller
- * does not have the <tt>UserAdminPermission</tt> with name <tt>admin</tt>.
- */
- public boolean addMember(org.osgi.service.useradmin.Role role) {
- useradmin.checkAlive();
- useradmin.checkAdminPermission();
- //only need to check for null for the public methods
- if (role == null) {
- return (false);
- }
- synchronized (useradmin) {
- if (basicMembers.contains(role)) {
- return (false);
- }
- return (addMember(role, true));
- }
- }
-
- // When we are loading from storage this method is called directly. We
- // do not want to write to storage when we are loading form storage.
- protected boolean addMember(org.osgi.service.useradmin.Role role, boolean store) {
- ((org.eclipse.equinox.useradmin.Role) role).addImpliedRole(this);
- if (store) {
- try {
- useradmin.userAdminStore.addMember(this, (org.eclipse.equinox.useradmin.Role) role);
- } catch (BackingStoreException ex) {
- return (false);
- }
- }
- basicMembers.addElement(role);
- return (true);
- }
-
- /**
- * Adds the specified role as a required member to this Group.
- *
- * @param role The role to add as a required member.
- *
- * @return <code>true</code> if the given role could be added as a required
- * member, and <code>false</code> if this Group already contains a role
- * whose name matches that of the specified role.
- *
- * @throws SecurityException If a security manager exists and the caller
- * does not have the <tt>UserAdminPermission</tt> with name <tt>admin</tt>.
- */
- public boolean addRequiredMember(org.osgi.service.useradmin.Role role) {
- useradmin.checkAlive();
- useradmin.checkAdminPermission();
- if (role == null) {
- return (false);
- }
- synchronized (useradmin) {
- if (requiredMembers.contains(role)) {
- return (false);
- }
- return (addRequiredMember(role, true));
- }
- }
-
- protected boolean addRequiredMember(org.osgi.service.useradmin.Role role, boolean store) {
- ((org.eclipse.equinox.useradmin.Role) role).addImpliedRole(this);
- if (store) {
- try {
- useradmin.userAdminStore.addRequiredMember(this, (org.eclipse.equinox.useradmin.Role) role);
- } catch (BackingStoreException ex) {
- return (false);
- }
- }
- requiredMembers.addElement(role);
- return (true);
- }
-
- /**
- * Removes the specified role from this Group.
- *
- * @param role The role to remove from this Group.
- *
- * @return <code>true</code> if the role could be removed,
- * otherwise <code>false</code>.
- *
- * @throws SecurityException If a security manager exists and the caller
- * does not have the <tt>UserAdminPermission</tt> with name <tt>admin</tt>.
- */
- public boolean removeMember(org.osgi.service.useradmin.Role role) {
- useradmin.checkAlive();
- useradmin.checkAdminPermission();
- if (role == null) {
- return (false);
- }
- synchronized (useradmin) {
- try {
- useradmin.userAdminStore.removeMember(this, (org.eclipse.equinox.useradmin.Role) role);
- } catch (BackingStoreException ex) {
- return (false);
- }
- //The role keeps track of which groups it is a member of so it can remove itself from
- //the group if it is deleted. In this case, this group is being removed from the role's
- //list.
- ((org.eclipse.equinox.useradmin.Role) role).removeImpliedRole(this);
-
- // We don't know if the Role to be removed is a basic orrequired member, or both. We
- // simply try to remove it from both.
- boolean removeRequired = requiredMembers.removeElement(role);
- boolean removeBasic = basicMembers.removeElement(role);
- return (removeRequired || removeBasic);
- }
- }
-
- /**
- * Gets the basic members of this Group.
- *
- * @return The basic members of this Group, or <code>null</code> if this
- * Group does not contain any basic members.
- */
- public org.osgi.service.useradmin.Role[] getMembers() {
- useradmin.checkAlive();
- synchronized (useradmin) {
- if (basicMembers.isEmpty()) {
- return (null);
- }
- Role[] roles = new Role[basicMembers.size()];
- basicMembers.copyInto(roles);
- return (roles);
- }
- }
-
- /**
- * Gets the required members of this Group.
- *
- * @return The required members of this Group, or <code>null</code> if this
- * Group does not contain any required members.
- */
- public org.osgi.service.useradmin.Role[] getRequiredMembers() {
- useradmin.checkAlive();
- synchronized (useradmin) {
- if (requiredMembers.isEmpty()) {
- return (null);
- }
- Role[] roles = new Role[requiredMembers.size()];
- requiredMembers.copyInto(roles);
- return (roles);
- }
- }
-
- /**
- * Returns the type of this role.
- *
- * @return The role's type.
- */
- public int getType() {
- useradmin.checkAlive();
- return (org.osgi.service.useradmin.Role.GROUP);
- }
-
- protected boolean isImpliedBy(Role role, Vector checkLoop) {
- if (checkLoop.contains(name)) {
- //we have a circular dependency
- return (false);
- }
- if (name.equals(role.getName())) //A User always implies itself. A Group is a User.
- {
- return (true);
- }
- checkLoop.addElement(name);
- Vector requiredCheckLoop = (Vector) checkLoop.clone();
- Vector basicCheckLoop = (Vector) checkLoop.clone();
- Enumeration e = requiredMembers.elements();
-
- //check to see if we imply all of the 0 or more required roles
- Role requiredRole;
- while (e.hasMoreElements()) {
- requiredRole = (Role) e.nextElement();
- if (!requiredRole.isImpliedBy(role, requiredCheckLoop)) {
- return (false);
- }
- }
- //check to see if we imply any of the basic roles (there must be at least one)
- e = basicMembers.elements();
- Role basicRole;
- while (e.hasMoreElements()) {
- basicRole = (Role) e.nextElement();
- if (basicRole.isImpliedBy(role, basicCheckLoop)) {
- return (true);
- }
- }
- return (false);
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/LogMessages.properties b/bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/LogMessages.properties
deleted file mode 100644
index f22b676e2..000000000
--- a/bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/LogMessages.properties
+++ /dev/null
@@ -1,15 +0,0 @@
-###############################################################################
-# Copyright (c) 2001, 2005 IBM Corporation.
-# 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:
-# IBM Corporation - initial API and implementation
-###############################################################################
-# NLS_MESSAGEFORMAT_ALL
-Unknown_Log_level=Unknown Log Level
-Info=Log Info
-Warning=Log Warning
-Error=Log Error \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/LogTracker.java b/bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/LogTracker.java
deleted file mode 100644
index 8a801ef65..000000000
--- a/bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/LogTracker.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.useradmin;
-
-import java.io.PrintStream;
-import java.text.DateFormat;
-import java.util.Calendar;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.log.LogService;
-import org.osgi.util.tracker.ServiceTracker;
-
-/**
- * LogTracker class. This class encapsulates the LogService
- * and handles all issues such as the service coming and going.
- */
-
-public class LogTracker extends ServiceTracker implements LogService {
- /** LogService interface class name */
- protected final static String clazz = "org.osgi.service.log.LogService"; //$NON-NLS-1$
-
- /** PrintStream to use if LogService is unavailable */
- protected PrintStream out;
-
- /** Calendar and DateFormat to user if LogService is unavailable */
- private static Calendar calendar;
- private static DateFormat dateFormat;
- private String timestamp;
-
- /**
- * Create new LogTracker.
- *
- * @param context BundleContext of parent bundle.
- * @param out Default PrintStream to use if LogService is unavailable.
- */
- public LogTracker(BundleContext context, PrintStream out) {
- super(context, clazz, null);
- this.out = out;
- calendar = Calendar.getInstance();
- dateFormat = DateFormat.getDateTimeInstance();
- open();
- }
-
- /*
- * ----------------------------------------------------------------------
- * LogService Interface implementation
- * ----------------------------------------------------------------------
- */
-
- public void log(int level, String message) {
- log(null, level, message, null);
- }
-
- public void log(int level, String message, Throwable exception) {
- log(null, level, message, exception);
- }
-
- public void log(ServiceReference reference, int level, String message) {
- log(reference, level, message, null);
- }
-
- public synchronized void log(ServiceReference reference, int level, String message, Throwable exception) {
- ServiceReference[] references = getServiceReferences();
-
- if (references != null) {
- int size = references.length;
-
- for (int i = 0; i < size; i++) {
- LogService service = (LogService) getService(references[i]);
- if (service != null) {
- try {
- service.log(reference, level, message, exception);
- } catch (Exception e) { // do nothing
- }
- }
- }
-
- return;
- }
-
- noLogService(level, message, exception, reference);
- }
-
- /**
- * The LogService is not available so we write the message to a PrintStream.
- *
- * @param level Logging level
- * @param message Log message.
- * @param throwable Log exception or null if none.
- * @param reference ServiceReference associated with message or null if none.
- */
- protected void noLogService(int level, String message, Throwable throwable, ServiceReference reference) {
- if (out != null) {
- synchronized (out) {
- // Bug #113286. If no log service present and messages are being
- // printed to stdout, prepend message with a timestamp.
- timestamp = dateFormat.format(calendar.getTime());
- out.print(timestamp + " "); //$NON-NLS-1$
-
- switch (level) {
- case LOG_DEBUG : {
- out.print("Debug: "); //$NON-NLS-1$
-
- break;
- }
- case LOG_INFO : {
- out.print(LogTrackerMsg.Info);
-
- break;
- }
- case LOG_WARNING : {
- out.print(LogTrackerMsg.Warning);
-
- break;
- }
- case LOG_ERROR : {
- out.print(LogTrackerMsg.Error);
-
- break;
- }
- default : {
- out.print("["); //$NON-NLS-1$
- out.print(LogTrackerMsg.Unknown_Log_level);
- out.print("]: "); //$NON-NLS-1$
-
- break;
- }
- }
-
- out.println(message);
-
- if (reference != null) {
- out.println(reference);
- }
-
- if (throwable != null) {
- throwable.printStackTrace(out);
- }
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/LogTrackerMsg.java b/bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/LogTrackerMsg.java
deleted file mode 100644
index d257de27d..000000000
--- a/bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/LogTrackerMsg.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.useradmin;
-
-import org.eclipse.osgi.util.NLS;
-
-public class LogTrackerMsg extends NLS {
- private static final String BUNDLE_NAME = "org.eclipse.equinox.useradmin.LogMessages"; //$NON-NLS-1$
-
- public static String Unknown_Log_level;
- public static String Info;
- public static String Warning;
- public static String Error;
-
- static {
- // initialize resource bundles
- NLS.initializeMessages(BUNDLE_NAME, LogTrackerMsg.class);
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/Role.java b/bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/Role.java
deleted file mode 100644
index 3c772d922..000000000
--- a/bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/Role.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.useradmin;
-
-import java.util.*;
-
-/**
- * The base interface for Role objects managed by the {@link UserAdmin}
- * service.
- * <p>
- * This interface exposes the characteristics shared by all Roles: a name,
- * a type, and a set of properties.
- * <p>
- * Properties represent public information about the Role that can be read by
- * anyone. Specific {@link UserAdminPermission}s are required to
- * change a Role's properties.
- * <p>
- * Role properties are Dictionary objects. Changes to
- * these objects are propagated to the {@link UserAdmin} service and
- * made persistent.
- * <p>
- * Every UserAdmin contains a set of predefined roles that are always present
- * and cannot be removed. All predefined roles are of type <tt>ROLE</tt>.
- * This version of the <tt>org.osgi.service.useradmin</tt> package defines a
- * single predefined role named &quot;user.anyone&quot;, which is inherited
- * by any other role. Other predefined roles may be added in the future.
- */
-
-public class Role implements org.osgi.service.useradmin.Role {
-
- protected String name;
- protected UserAdminHashtable properties;
- protected Vector impliedRoles;
- protected UserAdmin useradmin;
- protected static final String anyoneString = "user.anyone"; //$NON-NLS-1$
- protected boolean exists = true;
-
- protected Role(String name, UserAdmin useradmin) {
- this.name = name;
- this.properties = new UserAdminHashtable(this, useradmin, UserAdminHashtable.PROPERTIES);
- this.useradmin = useradmin;
-
- // This is used only to track which Groups this role is directly a member of.
- // This info is needed so when we delete a Role, we know which groups to remove
- // it from.
- impliedRoles = new Vector();
- }
-
- /**
- * Returns the name of this role.
- *
- * @return The role's name.
- */
-
- public String getName() {
- useradmin.checkAlive();
- return (name);
- }
-
- /**
- * Returns the type of this role.
- *
- * @return The role's type.
- */
- public int getType() {
- useradmin.checkAlive();
- return (org.osgi.service.useradmin.Role.ROLE);
- }
-
- /**
- * Returns a Dictionary of the (public) properties of this Role. Any changes
- * to the returned Dictionary will change the properties of this Role. This
- * will cause a UserAdminEvent of type {@link UserAdminEvent#ROLE_CHANGED}
- * to be broadcast to any UserAdminListeners.
- * <p>
- * Only objects of type <tt>String</tt> may be used as property keys, and
- * only objects of type <tt>String</tt> or <tt>byte[]</tt>
- * may be used as property values.
- * Any other types will cause an exception of type
- * <tt>IllegalArgumentException</tt> to be raised.
- * <p>
- * In order to add, change, or remove a property in the returned Dictionary,
- * a {@link UserAdminPermission} named after the property name (or
- * a prefix of it) with action <code>changeProperty</code> is required.
- *
- * @return Dictionary containing the properties of this Role.
- */
- public Dictionary getProperties() {
- useradmin.checkAlive();
- return (properties);
- }
-
- protected void addImpliedRole(Group group) {
- impliedRoles.addElement(group);
- }
-
- protected void removeImpliedRole(Group group) {
- if (exists) //this prevents a loop when destroy is called
- {
- impliedRoles.removeElement(group);
- }
- }
-
- //we are being deleted so delete ourselves from all of the groups
- protected synchronized void destroy() {
- exists = false;
- Enumeration e = impliedRoles.elements();
- while (e.hasMoreElements()) {
- Group group = (Group) e.nextElement();
- if (group.exists) //so we don't try to remove any groups twice from storage
- {
- group.removeMember(this);
- }
- }
- properties = null;
- impliedRoles = null;
- }
-
- protected boolean isImpliedBy(Role role, Vector checkLoop) { //Roles do not imply themselves
- //The user.anyone role is always implied
- if (checkLoop.contains(name)) {
- //we have a circular dependency
- return (false);
- }
- checkLoop.addElement(name);
- return (name.equals(Role.anyoneString));
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/User.java b/bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/User.java
deleted file mode 100644
index a76e25421..000000000
--- a/bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/User.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.useradmin;
-
-import java.util.Dictionary;
-import java.util.Vector;
-
-/**
- * A User managed by a {@link UserAdmin} service.
- * <p>
- * In this context, the term &quot;user&quot; is not limited to just
- * human beings.
- * Instead, it refers to any entity that may have any number of
- * credentials associated with it that it may use to authenticate itself.
- * <p>
- * In general, User objects are associated with a specific {@link UserAdmin}
- * service (namely the one that created them), and cannot be used with other
- * UserAdmin services.
- * <p>
- * A User may have credentials (and properties, inherited from {@link Role})
- * associated with it. Specific {@link UserAdminPermission}s are required to
- * read or change a User's credentials.
- * <p>
- * Credentials are Dictionary objects and have semantics that are similar
- * to the properties in Role.
- */
-
-public class User extends Role implements org.osgi.service.useradmin.User {
-
- protected UserAdminHashtable credentials;
-
- protected User(String name, UserAdmin useradmin) {
- super(name, useradmin);
- this.useradmin = useradmin;
- credentials = new UserAdminHashtable(this, useradmin, UserAdminHashtable.CREDENTIALS);
- }
-
- /**
- * Returns a Dictionary of the credentials of this User. Any changes
- * to the returned Dictionary will change the credentials of this User.
- * This will cause a UserAdminEvent of type
- * {@link UserAdminEvent#ROLE_CHANGED} to be broadcast to any
- * UserAdminListeners.
- * <p>
- * Only objects of type String may be used as credential keys, and only
- * objects of type <code>String</code> or of type <code>byte[]</code>
- * may be used as credential values. Any other types will cause an exception
- * of type <code>IllegalArgumentException</code> to be raised.
- * <p>
- * In order to retrieve a credential from the returned Dictionary,
- * a {@link UserAdminPermission} named after the credential name (or
- * a prefix of it) with action <code>getCredential</code> is required.
- * <p>
- * In order to add or remove a credential from the returned Dictionary,
- * a {@link UserAdminPermission} named after the credential name (or
- * a prefix of it) with action <code>changeCredential</code> is required.
- *
- * @return Dictionary containing the credentials of this User.
- */
-
- public Dictionary getCredentials() {
- useradmin.checkAlive();
- return (credentials);
- }
-
- /**
- * Checks to see if this User has a credential with the specified key
- * set to the specified value.
- * <p>
- * If the specified credential value is not of type <tt>String</tt> or
- * <tt>byte[]</tt>, it is ignored, that is, <tt>false</tt> is returned
- * (as opposed to an <tt>IllegalArgumentException</tt> being raised).
- *
- * @param key The credential key.
- * @param value The credential value.
- *
- * @return <code>true</code> if this user has the specified credential;
- * <code>false</code> otherwise.
- *
- * @throws SecurityException If a security manager exists and the caller
- * does not have the <tt>UserAdminPermission</tt> named after the credential
- * key (or a prefix of it) with action <code>getCredential</code>.
- */
- public boolean hasCredential(String key, Object value) {
- useradmin.checkAlive();
- Object checkValue = credentials.get(key);
- if (checkValue != null) {
- if (value instanceof String) {
- if (checkValue.equals(value)) {
- return (true);
- }
- } else if (value instanceof byte[])//FIXME Is there a good way to do this compare???
- {
- if (!(checkValue instanceof byte[])) {
- return (false);
- }
- //???do they need to be in order?
- byte[] valueArray = (byte[]) value;
- byte[] checkValueArray = (byte[]) checkValue;
- int length = valueArray.length;
- if (length != checkValueArray.length) {
- return (false);
- }
- for (int i = 0; i < length; i++) {
- if (valueArray[i] != checkValueArray[i]) {
- return (false);
- }
- }
- return (true);
- }
- }
- return (false); //if checkValue is null
- }
-
- /**
- * Returns the type of this role.
- *
- * @return The role's type.
- */
- public int getType() {
- useradmin.checkAlive();
- return org.osgi.service.useradmin.Role.USER;
- }
-
- //A user always implies itself
- protected boolean isImpliedBy(Role role, Vector checkLoop) {
- if (checkLoop.contains(name)) {
- //we have a circular dependency
- return (false);
- }
- checkLoop.addElement(name);
- return ((role.getName()).equals(name));
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/UserAdmin.java b/bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/UserAdmin.java
deleted file mode 100644
index e8493d180..000000000
--- a/bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/UserAdmin.java
+++ /dev/null
@@ -1,362 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.useradmin;
-
-import java.util.Dictionary;
-import java.util.Enumeration;
-import java.util.Vector;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Filter;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.log.LogService;
-import org.osgi.service.prefs.BackingStoreException;
-import org.osgi.service.prefs.PreferencesService;
-import org.osgi.service.useradmin.UserAdminEvent;
-import org.osgi.service.useradmin.UserAdminPermission;
-
-/**
- * This interface is used to manage a database of named roles, which can
- * be used for authentication and authorization purposes.
- * <p>
- * This version of UserAdmin defines two types of roles: "User" and
- * "Group". Each type of role is represented by an "int" constant and an
- * interface. The range of positive integers is reserved for new types of
- * roles that may be added in the future. When defining proprietary role
- * types, negative constant values must be used.
- * <p>
- * Every role has a name and a type.
- * <p>
- * A {@link User} role can be configured with credentials (e.g., a password)
- * and properties (e.g., a street address, phone number, etc.).
- * <p>
- * A {@link Group} role represents an aggregation of {@link User} and
- * {@link Group} roles. In
- * other words, the members of a Group role are roles themselves.
- * <p>
- * Every UserAdmin manages and maintains its own
- * namespace of roles, in which each role has a unique name.
- */
-
-public class UserAdmin implements org.osgi.service.useradmin.UserAdmin {
-
- protected Vector users;
- protected Vector roles;
- protected BundleContext context;
- protected UserAdminEventProducer eventProducer;
- protected boolean alive;
- protected UserAdminStore userAdminStore;
- protected UserAdminPermission adminPermission;
- protected ServiceReference reference;
- protected LogTracker log;
-
- protected UserAdmin(PreferencesService preferencesService, BundleContext context) throws Exception {
- roles = new Vector();
- users = new Vector();
- this.context = context;
-
- log = new LogTracker(context, System.out);
- alive = true;
- //This handles user admin persistence
- try {
- userAdminStore = new UserAdminStore(preferencesService, this, log);
- userAdminStore.init();
- } catch (Exception e) {
- log.log(LogService.LOG_ERROR, UserAdminMsg.Backing_Store_Read_Exception, e);
- throw e;
- }
- }
-
- protected void setServiceReference(ServiceReference reference) {
- if (this.reference == null) {
- this.reference = reference;
-
- eventProducer = new UserAdminEventProducer(reference, context, log);
- }
- }
-
- /**
- * Creates a role with the given name and of the given type.
- *
- * <p> If a role was created, a UserAdminEvent of type
- * {@link UserAdminEvent#ROLE_CREATED} is broadcast to any
- * UserAdminListener.
- *
- * @param name The name of the role to create.
- * @param type The type of the role to create. Must be either
- * {@link Role#USER} or {@link Role#GROUP}.
- *
- * @return The newly created role, or <code>null</code> if a role with
- * the given name already exists.
- *
- * @throws IllegalArgumentException if <tt>type</tt> is invalid.
- *
- * @throws SecurityException If a security manager exists and the caller
- * does not have the <tt>UserAdminPermission</tt> with name <tt>admin</tt>.
- */
- public org.osgi.service.useradmin.Role createRole(String name, int type) {
- checkAlive();
- checkAdminPermission();
- if (name == null) {
- throw (new IllegalArgumentException(UserAdminMsg.CREATE_NULL_ROLE_EXCEPTION));
- }
- if ((type != org.osgi.service.useradmin.Role.GROUP) && (type != org.osgi.service.useradmin.Role.USER)) {
- throw (new IllegalArgumentException(UserAdminMsg.CREATE_INVALID_TYPE_ROLE_EXCEPTION));
- }
- //if the role already exists, return null
- if (getRole(name) != null) {
- return (null);
- }
-
- synchronized (this) {
- return createRole(name, type, true);
- }
- }
-
- protected org.osgi.service.useradmin.Role createRole(String name, int type, boolean store) {
- Role newRole = null;
- if (type == org.osgi.service.useradmin.Role.ROLE) {
- newRole = new Role(name, this);
- } else if (type == org.osgi.service.useradmin.Role.USER) {
- newRole = new User(name, this);
- } else if (type == org.osgi.service.useradmin.Role.GROUP) {
- newRole = new Group(name, this);
- } else //unknown type
- {
- return (null);
- }
- if (store) {
- try {
- userAdminStore.addRole(newRole);
- } catch (BackingStoreException ex) {
- return (null);
- }
- if (eventProducer != null) {
- eventProducer.generateEvent(UserAdminEvent.ROLE_CREATED, newRole);
- }
- }
- if (type == org.osgi.service.useradmin.Role.GROUP || type == org.osgi.service.useradmin.Role.USER) {
- users.addElement(newRole);
- }
- roles.addElement(newRole);
- return (newRole);
- }
-
- /**
- * Removes the role with the given name from this UserAdmin.
- *
- * <p> If the role was removed, a UserAdminEvent of type
- * {@link UserAdminEvent#ROLE_REMOVED} is broadcast to any
- * UserAdminListener.
- *
- * @param name The name of the role to remove.
- *
- * @return <code>true</code> If a role with the given name is present in this
- * UserAdmin and could be removed, otherwise <code>false</code>.
- *
- * @throws SecurityException If a security manager exists and the caller
- * does not have the <tt>UserAdminPermission</tt> with name <tt>admin</tt>.
- */
- public boolean removeRole(String name) {
- checkAlive();
- checkAdminPermission();
- if (name.equals(Role.anyoneString)) {
- //silently ignore
- return (true);
- }
- synchronized (this) {
- Role role = (org.eclipse.equinox.useradmin.Role) getRole(name);
- if (role != null) {
- try {
- userAdminStore.removeRole(role);
- } catch (BackingStoreException ex) {
- return (false);
- }
- roles.removeElement(role);
- users.removeElement(role);
- role.destroy();
- eventProducer.generateEvent(UserAdminEvent.ROLE_REMOVED, role);
- role = null;
- return (true);
- }
- return (false);
- }
- }
-
- /**
- * Gets the role with the given name from this UserAdmin.
- *
- * @param name The name of the role to get.
- *
- * @return The requested role, or <code>null</code> if this UserAdmin does
- * not have a role with the given name.
- */
- public org.osgi.service.useradmin.Role getRole(String name) {
- checkAlive();
- if (name == null) {
- return (null);
- }
- synchronized (this) {
- Enumeration e = roles.elements();
- while (e.hasMoreElements()) {
- Role role = (Role) e.nextElement();
- if (role.getName().equals(name)) {
- return (role);
- }
- }
- return (null);
- }
- }
-
- /**
- * Gets the roles managed by this UserAdmin that have properties matching
- * the specified LDAP filter criteria. See
- * <code>org.osgi.framework.Filter</code> or IETF RFC 2254 for a
- * description of the filter syntax. If a <code>null</code> filter is
- * specified, all roles managed by this UserAdmin are returned.
- *
- * @param filter The filter criteria to match.
- *
- * @return The roles managed by this UserAdmin whose properties
- * match the specified filter criteria, or all roles if a
- * <code>null</code> filter is specified.
- *
- */
- public org.osgi.service.useradmin.Role[] getRoles(String filterString) throws InvalidSyntaxException {
- checkAlive();
- Vector returnedRoles;
- synchronized (this) {
- if (filterString == null) {
- returnedRoles = roles;
- } else {
- Filter filter = context.createFilter(filterString); //We do this first so an
- //InvalidSyntaxException will be
- //thrown even if there are no roles
- //present.
- returnedRoles = new Vector();
- for (int i = 0; i < roles.size(); i++) {
- Role role = (Role) roles.elementAt(i);
- if (filter.match(role.getProperties())) {
- returnedRoles.addElement(role);
- }
- }
- }
- int size = returnedRoles.size();
- if (size == 0) {
- return (null);
- }
- Role[] roleArray = new Role[size];
- returnedRoles.copyInto(roleArray);
- return (roleArray);
- }
- }
-
- /**
- * Gets the user with the given property key-value pair from the UserAdmin
- * database. This is a convenience method for retrieving a user based on
- * a property for which every user is supposed to have a unique value
- * (within the scope of this UserAdmin), such as a user's
- * X.500 distinguished name.
- *
- * @param key The property key to look for.
- * @param value The property value to compare with.
- *
- * @return A matching user, if <em>exactly</em> one is found. If zero or
- * more than one matching users are found, <code>null</code> is returned.
- */
- public org.osgi.service.useradmin.User getUser(String key, String value) {
- checkAlive();
- if (key == null) {
- return (null);
- }
- User user;
- User foundUser = null;
- Dictionary props;
- String keyValue;
- synchronized (this) {
- Enumeration e = users.elements();
- while (e.hasMoreElements()) {
- user = (User) e.nextElement();
- props = user.getProperties();
- keyValue = (String) props.get(key);
- if (keyValue != null && keyValue.equals(value)) {
- if (foundUser != null) {
- return (null); //we found more than one match
- }
- foundUser = user;
- }
- }
- return (foundUser);
- }
- }
-
- /**
- * Creates an Authorization object that encapsulates the specified user
- * and the roles it possesses. The <code>null</code> user is interpreted
- * as the anonymous user.
- *
- * @param user The user to create an Authorization object for, or
- * <code>null</code> for the anonymous user.
- *
- * @return the Authorization object for the specified user.
- */
- public org.osgi.service.useradmin.Authorization getAuthorization(org.osgi.service.useradmin.User user) {
- checkAlive();
- return (new Authorization((User) user, this));
- }
-
- protected synchronized void destroy() {
- alive = false;
- eventProducer.close();
- userAdminStore.destroy();
-
- log.close();
- }
-
- public void checkAdminPermission() {
- SecurityManager sm = System.getSecurityManager();
- if (sm != null) {
- if (adminPermission == null) {
- adminPermission = new UserAdminPermission(UserAdminPermission.ADMIN, null);
- }
- sm.checkPermission(adminPermission);
- }
- }
-
- public void checkGetCredentialPermission(String credential) {
- SecurityManager sm = System.getSecurityManager();
- if (sm != null) {
- sm.checkPermission(new org.osgi.service.useradmin.UserAdminPermission(credential, org.osgi.service.useradmin.UserAdminPermission.GET_CREDENTIAL));
- }
- }
-
- public void checkChangeCredentialPermission(String credential) {
- SecurityManager sm = System.getSecurityManager();
- if (sm != null) {
- sm.checkPermission(new org.osgi.service.useradmin.UserAdminPermission(credential, org.osgi.service.useradmin.UserAdminPermission.CHANGE_CREDENTIAL));
- }
- }
-
- public void checkChangePropertyPermission(String property) {
- SecurityManager sm = System.getSecurityManager();
- if (sm != null) {
- sm.checkPermission(new org.osgi.service.useradmin.UserAdminPermission(property, org.osgi.service.useradmin.UserAdminPermission.CHANGE_PROPERTY));
- }
- }
-
- public void checkAlive() {
- if (!alive) {
- throw (new IllegalStateException(UserAdminMsg.USERADMIN_UNREGISTERED_EXCEPTION));
- }
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/UserAdminEventProducer.java b/bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/UserAdminEventProducer.java
deleted file mode 100644
index 545625055..000000000
--- a/bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/UserAdminEventProducer.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.useradmin;
-
-import org.eclipse.osgi.framework.eventmgr.*;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.log.LogService;
-import org.osgi.service.useradmin.UserAdminEvent;
-import org.osgi.service.useradmin.UserAdminListener;
-import org.osgi.util.tracker.ServiceTracker;
-
-/*
- * UserAdminEventProducer is responsible for sending out UserAdminEvents
- * to all UserAdminListeners.
- */
-
-public class UserAdminEventProducer extends ServiceTracker implements EventDispatcher {
-
- protected ServiceReference userAdmin;
- static protected final String userAdminListenerClass = "org.osgi.service.useradmin.UserAdminListener"; //$NON-NLS-1$
- protected LogService log;
- /** List of UserAdminListeners */
- protected EventListeners listeners;
- /** EventManager for event delivery. */
- protected EventManager eventManager;
-
- protected UserAdminEventProducer(ServiceReference userAdmin, BundleContext context, LogService log) {
- super(context, userAdminListenerClass, null);
- this.userAdmin = userAdmin;
- this.log = log;
- eventManager = new EventManager("UserAdmin Event Dispatcher"); //$NON-NLS-1$
- listeners = new EventListeners();
-
- open();
- }
-
- public void close() {
- super.close();
- listeners.removeAllListeners();
- eventManager.close();
- userAdmin = null;
- }
-
- protected void generateEvent(int type, Role role) {
- if (userAdmin != null) {
- UserAdminEvent event = new UserAdminEvent(userAdmin, type, role);
-
- /* queue to hold set of listeners */
- ListenerQueue queue = new ListenerQueue(eventManager);
-
- /* add set of UserAdminListeners to queue */
- queue.queueListeners(listeners, this);
-
- /* dispatch event to set of listeners */
- queue.dispatchEventAsynchronous(0, event);
- }
- }
-
- /**
- * A service is being added to the <tt>ServiceTracker</tt> object.
- *
- * <p>This method is called before a service which matched
- * the search parameters of the <tt>ServiceTracker</tt> object is
- * added to it. This method should return the
- * service object to be tracked for this <tt>ServiceReference</tt> object.
- * The returned service object is stored in the <tt>ServiceTracker</tt> object
- * and is available from the <tt>getService</tt> and <tt>getServices</tt>
- * methods.
- *
- * @param reference Reference to service being added to the <tt>ServiceTracker</tt> object.
- * @return The service object to be tracked for the
- * <tt>ServiceReference</tt> object or <tt>null</tt> if the <tt>ServiceReference</tt> object should not
- * be tracked.
- */
- public Object addingService(ServiceReference reference) {
- Object service = super.addingService(reference);
-
- listeners.addListener(service, service);
-
- return service;
- }
-
- /**
- * A service tracked by the <tt>ServiceTracker</tt> object has been removed.
- *
- * <p>This method is called after a service is no longer being tracked
- * by the <tt>ServiceTracker</tt> object.
- *
- * @param reference Reference to service that has been removed.
- * @param service The service object for the removed service.
- */
- public void removedService(ServiceReference reference, Object service) {
- listeners.removeListener(service);
-
- super.removedService(reference, service);
- }
-
- /**
- * This method is the call back that is called once for each listener.
- * This method must cast the EventListener object to the appropriate listener
- * class for the event type and call the appropriate listener method.
- *
- * @param listener This listener must be cast to the appropriate listener
- * class for the events created by this source and the appropriate listener method
- * must then be called.
- * @param listenerObject This is the optional object that was passed to
- * ListenerList.addListener when the listener was added to the ListenerList.
- * @param eventAction This value was passed to the EventQueue object via one of its
- * dispatchEvent* method calls. It can provide information (such
- * as which listener method to call) so that this method
- * can complete the delivery of the event to the listener.
- * @param eventObject This object was passed to the EventQueue object via one of its
- * dispatchEvent* method calls. This object was created by the event source and
- * is passed to this method. It should contain all the necessary information (such
- * as what event object to pass) so that this method
- * can complete the delivery of the event to the listener.
- */
- public void dispatchEvent(Object listener, Object listenerObject, int eventAction, Object eventObject) {
- if (userAdmin == null) {
- return;
- }
-
- UserAdminListener ual = (UserAdminListener) listener;
- try {
- ual.roleChanged((UserAdminEvent) eventObject);
- } catch (Throwable t) {
- log.log(userAdmin, LogService.LOG_WARNING, UserAdminMsg.Event_Delivery_Exception, t);
- }
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/UserAdminHashtable.java b/bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/UserAdminHashtable.java
deleted file mode 100644
index 9d89c4560..000000000
--- a/bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/UserAdminHashtable.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.useradmin;
-
-import java.util.Enumeration;
-import java.util.Hashtable;
-import org.osgi.service.prefs.BackingStoreException;
-import org.osgi.service.useradmin.UserAdminEvent;
-
-/* The UserAdminHashtable is a Hashtable that generates UserAdminEvents when there
- * is a change to the Hashtable. This is used specifically to store Role properties
- * and User credentials.
- */
-
-public class UserAdminHashtable extends Hashtable {
-
- /**
- *
- */
- private static final long serialVersionUID = -397030865421289240L;
- protected Role role;
- protected int propertyType;
- protected UserAdmin userAdmin;
- protected UserAdminStore userAdminStore;
-
- //TODO - split this into two classes so we don't have to do this
- protected static final int CREDENTIALS = 0;
- protected static final int PROPERTIES = 1;
-
- protected UserAdminHashtable(Role role, UserAdmin userAdmin, int propertyType) {
- this.role = role;
- this.propertyType = propertyType;
- this.userAdmin = userAdmin;
- this.userAdminStore = userAdmin.userAdminStore;
- }
-
- /*
- * We want to generate an event every time we put something into the hashtable, except
- * upon initialization where role data is being read from persistent store.
- */
- protected synchronized Object put(String key, Object value, boolean generateEvent) {
-
- if (generateEvent) {
- if (propertyType == UserAdminHashtable.PROPERTIES) {
- try {
- userAdminStore.addProperty(role, key, value);
- } catch (BackingStoreException ex) {
- return (null);
- }
- userAdmin.eventProducer.generateEvent(UserAdminEvent.ROLE_CHANGED, role);
- } else if (propertyType == UserAdminHashtable.CREDENTIALS) {
- try {
- userAdminStore.addCredential(role, key, value);
- } catch (BackingStoreException ex) {
- return (null);
- }
- userAdmin.eventProducer.generateEvent(UserAdminEvent.ROLE_CHANGED, role);
- }
- }
- Object retVal = super.put(key, value);
- return retVal;
- }
-
- public Object put(Object key, Object value) {
- if (!(key instanceof String)) {
- throw new IllegalArgumentException(UserAdminMsg.INVALID_KEY_EXCEPTION);
- }
-
- if (!((value instanceof String) || (value instanceof byte[]))) {
- throw new IllegalArgumentException(UserAdminMsg.INVALID_VALUE_EXCEPTION);
- }
-
- String name = (String) key;
-
- switch (propertyType) {
- case PROPERTIES :
- userAdmin.checkChangePropertyPermission(name);
- break;
- case CREDENTIALS :
- userAdmin.checkChangeCredentialPermission(name);
- break;
- }
-
- return put(name, value, true);
- }
-
- public synchronized Object remove(Object key) {
- if (!(key instanceof String)) {
- throw new IllegalArgumentException(UserAdminMsg.INVALID_KEY_EXCEPTION);
- }
-
- String name = (String) key;
-
- switch (propertyType) {
- case PROPERTIES :
- userAdmin.checkChangePropertyPermission(name);
- try {
- userAdminStore.removeProperty(role, name);
- } catch (BackingStoreException ex) {
- return (null);
- }
- userAdmin.eventProducer.generateEvent(UserAdminEvent.ROLE_CHANGED, role);
- break;
- case CREDENTIALS :
- userAdmin.checkChangeCredentialPermission(name);
- try {
- userAdminStore.removeCredential(role, name);
- } catch (BackingStoreException ex) {
- return (null);
- }
- userAdmin.eventProducer.generateEvent(UserAdminEvent.ROLE_CHANGED, role);
- break;
- }
-
- return super.remove(name);
- }
-
- public synchronized void clear() {
- Enumeration e = keys();
-
- while (e.hasMoreElements()) {
- String name = (String) e.nextElement();
-
- switch (propertyType) {
- case PROPERTIES :
- userAdmin.checkChangePropertyPermission(name);
- break;
- case CREDENTIALS :
- userAdmin.checkChangeCredentialPermission(name);
- break;
- }
- }
-
- switch (propertyType) {
- case PROPERTIES :
- try {
- userAdminStore.clearProperties(role);
- } catch (BackingStoreException ex) {
- return;
- }
- userAdmin.eventProducer.generateEvent(UserAdminEvent.ROLE_CHANGED, role);
- break;
- case CREDENTIALS :
- try {
- userAdminStore.clearCredentials(role);
- } catch (BackingStoreException ex) {
- return;
- }
- userAdmin.eventProducer.generateEvent(UserAdminEvent.ROLE_CHANGED, role);
- break;
- }
-
- super.clear();
- }
-
- public Object get(Object key) {
- if (!(key instanceof String)) {
- throw new IllegalArgumentException(UserAdminMsg.INVALID_KEY_EXCEPTION);
- }
-
- String name = (String) key;
-
- if (propertyType == CREDENTIALS) {
- userAdmin.checkGetCredentialPermission(name);
- }
-
- return super.get(name);
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/UserAdminMsg.java b/bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/UserAdminMsg.java
deleted file mode 100644
index be4bf7618..000000000
--- a/bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/UserAdminMsg.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.useradmin;
-
-import org.eclipse.osgi.util.NLS;
-
-public class UserAdminMsg extends NLS {
- private static final String BUNDLE_NAME = "org.eclipse.equinox.useradmin.ExternalMessages"; //$NON-NLS-1$
-
- public static String adding_Credential_to__15;
- public static String adding_member__18;
- public static String adding_required_member__21;
- public static String removing_member__24;
- public static String Unable_to_load_role__27;
- public static String Backing_Store_Read_Exception;
- public static String Backing_Store_Write_Exception;
- public static String Event_Delivery_Exception;
- public static String CREATE_NULL_ROLE_EXCEPTION;
- public static String CREATE_INVALID_TYPE_ROLE_EXCEPTION;
- public static String INVALID_KEY_EXCEPTION;
- public static String INVALID_VALUE_EXCEPTION;
- public static String USERADMIN_UNREGISTERED_EXCEPTION;
- public static String Service_Vendor;
- public static String OSGi_User_Admin_service_IBM_Implementation_3;
-
- static {
- // initialize resource bundles
- NLS.initializeMessages(BUNDLE_NAME, UserAdminMsg.class);
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/UserAdminStore.java b/bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/UserAdminStore.java
deleted file mode 100644
index 95c7929ad..000000000
--- a/bundles/org.eclipse.equinox.useradmin/src/org/eclipse/equinox/useradmin/UserAdminStore.java
+++ /dev/null
@@ -1,353 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.useradmin;
-
-import java.security.AccessController;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-
-import org.eclipse.osgi.util.NLS;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.log.LogService;
-import org.osgi.service.prefs.BackingStoreException;
-import org.osgi.service.prefs.Preferences;
-import org.osgi.service.prefs.PreferencesService;
-
-/*
- * UserAdminStore is responsible for managing the persistence data of the useradmin
- * service. It uses the PersistenceNode service as its underlying storage.
- */
-
-public class UserAdminStore {
-
- static protected final String propertiesNode = "properties"; //$NON-NLS-1$
- static protected final String credentialsNode = "credentials"; //$NON-NLS-1$
- static protected final String membersNode = "members"; //$NON-NLS-1$
- static protected final String basicString = "basic"; //$NON-NLS-1$
- static protected final String requiredString = "required"; //$NON-NLS-1$
- static protected final String typeString = "type"; //$NON-NLS-1$
- static protected final String persistenceUserName = "UserAdmin"; //$NON-NLS-1$
-
- protected ServiceReference prefsRef;
- protected ServiceRegistration userAdminListenerReg;
- protected UserAdmin useradmin;
- protected LogService log;
- protected Preferences rootNode;
- protected PreferencesService preferencesService;
-
- protected UserAdminStore(PreferencesService preferencesService, UserAdmin useradmin, LogService log) {
- this.preferencesService = preferencesService;
- this.useradmin = useradmin;
- this.log = log;
- }
-
- protected void init() throws BackingStoreException {
- try {
- AccessController.doPrivileged(new PrivilegedExceptionAction() {
-
- public Object run() throws BackingStoreException {
- rootNode = preferencesService.getUserPreferences(persistenceUserName);
- loadRoles();
- return (null);
- }
- });
- } catch (PrivilegedActionException ex) {
-
- throw ((BackingStoreException) ex.getException());
- }
- }
-
- protected void addRole(final org.osgi.service.useradmin.Role role) throws BackingStoreException {
- try {
- AccessController.doPrivileged(new PrivilegedExceptionAction() {
- public Object run() throws BackingStoreException {
- Preferences node = rootNode.node(role.getName());
- node.putInt(typeString, role.getType());
- node.flush();
- return (null);
- }
- });
- } catch (PrivilegedActionException ex) {
- log.log(LogService.LOG_ERROR, UserAdminMsg.Backing_Store_Write_Exception, ex);
- throw ((BackingStoreException) ex.getException());
- }
- }
-
- protected void removeRole(final org.osgi.service.useradmin.Role role) throws BackingStoreException {
- try {
- AccessController.doPrivileged(new PrivilegedExceptionAction() {
- public Object run() throws BackingStoreException {
- Preferences node = rootNode.node(role.getName());
- node.removeNode();
- rootNode.node("").flush(); //$NON-NLS-1$
- return (null);
- }
- });
- } catch (PrivilegedActionException ex) {
- log.log(LogService.LOG_ERROR, UserAdminMsg.Backing_Store_Write_Exception, ex);
- throw ((BackingStoreException) ex.getException());
- }
- }
-
- protected void clearProperties(final org.osgi.service.useradmin.Role role) throws BackingStoreException {
- try {
- AccessController.doPrivileged(new PrivilegedExceptionAction() {
- public Object run() throws BackingStoreException {
- Preferences propertyNode = rootNode.node(role.getName() + "/" + propertiesNode); //$NON-NLS-1$
- propertyNode.clear();
- propertyNode.flush();
- return (null);
- }
- });
- } catch (PrivilegedActionException ex) {
- log.log(LogService.LOG_ERROR, UserAdminMsg.Backing_Store_Write_Exception, ex);
- throw ((BackingStoreException) ex.getException());
- }
- }
-
- protected void addProperty(final org.osgi.service.useradmin.Role role, final String key, final Object value) throws BackingStoreException {
- try {
- AccessController.doPrivileged(new PrivilegedExceptionAction() {
- public Object run() throws BackingStoreException {
- Preferences propertyNode = rootNode.node(role.getName() + "/" + propertiesNode); //$NON-NLS-1$
- if (value instanceof String) {
- propertyNode.put(key, (String) value);
- } else //must be a byte array, then
- {
- propertyNode.putByteArray(key, (byte[]) value);
- }
- propertyNode.flush();
- return (null);
- }
- });
- } catch (PrivilegedActionException ex) {
- log.log(LogService.LOG_ERROR, UserAdminMsg.Backing_Store_Write_Exception, ex);
- throw ((BackingStoreException) ex.getException());
- }
- }
-
- protected void removeProperty(final org.osgi.service.useradmin.Role role, final String key) throws BackingStoreException {
- try {
- AccessController.doPrivileged(new PrivilegedExceptionAction() {
- public Object run() throws BackingStoreException {
- Preferences propertyNode = rootNode.node(role.getName() + "/" + propertiesNode); //$NON-NLS-1$
- propertyNode.remove(key);
- propertyNode.flush();
- return (null);
- }
- });
- } catch (PrivilegedActionException ex) {
- log.log(LogService.LOG_ERROR, UserAdminMsg.Backing_Store_Write_Exception, ex);
- throw ((BackingStoreException) ex.getException());
- }
- }
-
- protected void clearCredentials(final org.osgi.service.useradmin.Role role) throws BackingStoreException {
- try {
- AccessController.doPrivileged(new PrivilegedExceptionAction() {
- public Object run() throws BackingStoreException {
- Preferences credentialNode = rootNode.node(role.getName() + "/" + credentialsNode); //$NON-NLS-1$
- credentialNode.clear();
- credentialNode.flush();
- return (null);
- }
- });
- } catch (PrivilegedActionException ex) {
- log.log(LogService.LOG_ERROR, UserAdminMsg.Backing_Store_Write_Exception, ex);
- throw ((BackingStoreException) ex.getException());
- }
- }
-
- protected void addCredential(final org.osgi.service.useradmin.Role role, final String key, final Object value) throws BackingStoreException {
-
- try {
- AccessController.doPrivileged(new PrivilegedExceptionAction() {
- public Object run() throws BackingStoreException {
- Preferences credentialNode = rootNode.node(role.getName() + "/" + credentialsNode); //$NON-NLS-1$
- if (value instanceof String) {
- credentialNode.put(key, (String) value);
- } else //assume it is a byte array
- {
- credentialNode.putByteArray(key, (byte[]) value);
- }
- credentialNode.flush();
- return (null);
- }
- });
- } catch (PrivilegedActionException ex) {
- log.log(LogService.LOG_ERROR, NLS.bind(UserAdminMsg.Backing_Store_Write_Exception, new Object[] {NLS.bind(UserAdminMsg.adding_Credential_to__15, role.getName())}), ex);
- throw ((BackingStoreException) ex.getException());
- }
-
- }
-
- protected void removeCredential(final org.osgi.service.useradmin.Role role, final String key) throws BackingStoreException {
- try {
- AccessController.doPrivileged(new PrivilegedExceptionAction() {
- public Object run() throws BackingStoreException {
- Preferences credentialNode = rootNode.node(role.getName() + "/" + credentialsNode); //$NON-NLS-1$
- credentialNode.remove(key);
- credentialNode.flush();
- return (null);
- }
- });
- } catch (PrivilegedActionException ex) {
- log.log(LogService.LOG_ERROR, UserAdminMsg.Backing_Store_Write_Exception, ex);
- throw ((BackingStoreException) ex.getException());
- }
- }
-
- protected void addMember(final Group group, final Role role) throws BackingStoreException {
- try {
- AccessController.doPrivileged(new PrivilegedExceptionAction() {
- public Object run() throws BackingStoreException {
- Preferences memberNode = rootNode.node(group.getName() + "/" + membersNode); //$NON-NLS-1$
- memberNode.put(role.getName(), basicString);
- memberNode.flush();
- return (null);
- }
- });
- } catch (PrivilegedActionException ex) {
- log.log(LogService.LOG_ERROR, NLS.bind(UserAdminMsg.Backing_Store_Write_Exception, new Object[] {NLS.bind(UserAdminMsg.adding_member__18, role.getName(), group.getName())}), ex);
- throw ((BackingStoreException) ex.getException());
- }
- }
-
- protected void addRequiredMember(final Group group, final Role role) throws BackingStoreException {
- try {
- AccessController.doPrivileged(new PrivilegedExceptionAction() {
- public Object run() throws BackingStoreException {
- Preferences memberNode = rootNode.node(group.getName() + "/" + membersNode); //$NON-NLS-1$
- memberNode.put(role.getName(), requiredString);
- memberNode.flush();
- return (null);
- }
- });
- } catch (PrivilegedActionException ex) {
- log.log(LogService.LOG_ERROR, NLS.bind(UserAdminMsg.Backing_Store_Write_Exception, new Object[] {NLS.bind(UserAdminMsg.adding_required_member__21, role.getName(), group.getName())}), ex);
- throw ((BackingStoreException) ex.getException());
- }
- }
-
- protected void removeMember(final Group group, final Role role) throws BackingStoreException {
- try {
- AccessController.doPrivileged(new PrivilegedExceptionAction() {
- public Object run() throws BackingStoreException {
- Preferences memberNode = rootNode.node(group.getName() + "/" + membersNode); //$NON-NLS-1$
- memberNode.remove(role.getName());
- memberNode.flush();
- return (null);
- }
- });
- } catch (PrivilegedActionException ex) {
- log.log(LogService.LOG_ERROR, NLS.bind(UserAdminMsg.Backing_Store_Write_Exception, new Object[] {NLS.bind(UserAdminMsg.removing_member__24, role.getName(), group.getName())}), ex);
- throw ((BackingStoreException) ex.getException());
- }
- }
-
- protected void loadRoles() throws BackingStoreException {
- synchronized (this) {
- createAnonRole();
-
- String[] children = rootNode.node("").childrenNames(); //$NON-NLS-1$
-
- for (int i = 0; i < children.length; i++) {
- if (useradmin.getRole(children[i]) == null) //check to see if it is already loaded
- { //(we may have had to load some roles out of
- loadRole(rootNode.node(children[i]), null); // order due to dependencies)
- //modified to solve defect 95982
- }
- }
- }
- }
-
- /* modified to solve defect 95982 */
- protected void loadRole(Preferences node, Role role) throws BackingStoreException {
- int type = node.getInt(typeString, Integer.MIN_VALUE);
-
- if (type == Integer.MIN_VALUE) {
- String errorString = NLS.bind(UserAdminMsg.Backing_Store_Read_Exception, new Object[] {NLS.bind(UserAdminMsg.Unable_to_load_role__27, node.name())});
- BackingStoreException ex = new BackingStoreException(errorString);
- log.log(LogService.LOG_ERROR, errorString, ex);
- throw (ex);
- }
- if (role == null) {
- role = (Role) useradmin.createRole(node.name(), type, false);
- }
- Preferences propsNode = node.node(propertiesNode);
- String[] keys = propsNode.keys();
- UserAdminHashtable properties = (UserAdminHashtable) role.getProperties();
- String value;
-
- //load properties
- for (int i = 0; i < keys.length; i++) {
- value = propsNode.get(keys[i], null);
- properties.put(keys[i], value, false);
- }
-
- //load credentials
- if (type == org.osgi.service.useradmin.Role.USER || type == org.osgi.service.useradmin.Role.GROUP) {
- Object credValue;
- Preferences credNode = node.node(credentialsNode);
- keys = credNode.keys();
- UserAdminHashtable credentials = (UserAdminHashtable) ((User) role).getCredentials();
- for (int i = 0; i < keys.length; i++) {
- credValue = credNode.get(keys[i], null);
- credentials.put(keys[i], credValue, false);
- }
- }
-
- //load group members
- if (type == org.osgi.service.useradmin.Role.GROUP) {
- Preferences memberNode = node.node(membersNode);
- keys = memberNode.keys();
- for (int i = 0; i < keys.length; i++) {
- value = memberNode.get(keys[i], null);
- Role member = (Role) useradmin.getRole(keys[i]);
- if (member == null) //then we have not loaded this one yet, so load it
- {
- loadRole(rootNode.node(keys[i]), null); // modified to solve defect 95982
- member = (Role) useradmin.getRole(keys[i]);
- }
- if (value.equals(requiredString)) {
- ((Group) role).addRequiredMember(member, false);
- } else {
- ((Group) role).addMember(member, false);
- }
- }
- }
- }
-
- protected void destroy() {
- try {
- rootNode.flush();
- rootNode = null;
- preferencesService = null;
- } catch (BackingStoreException ex) {
- log.log(LogService.LOG_ERROR, UserAdminMsg.Backing_Store_Write_Exception, ex);
- }
- }
-
- private void createAnonRole() throws BackingStoreException {
- Role role = null;
- if (!rootNode.nodeExists(Role.anyoneString)) {
- //If the user.anyone role is not present, create it
- role = (Role) useradmin.createRole(Role.anyoneString, org.osgi.service.useradmin.Role.ROLE, true);
- }
- /* modified to solve defect 95982 */
- if (role != null)
- loadRole(rootNode.node(Role.anyoneString), role);
- else
- loadRole(rootNode.node(Role.anyoneString), null);
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.wireadmin/.classpath b/bundles/org.eclipse.equinox.wireadmin/.classpath
deleted file mode 100644
index 751c8f2e5..000000000
--- a/bundles/org.eclipse.equinox.wireadmin/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/bundles/org.eclipse.equinox.wireadmin/.cvsignore b/bundles/org.eclipse.equinox.wireadmin/.cvsignore
deleted file mode 100644
index ba077a403..000000000
--- a/bundles/org.eclipse.equinox.wireadmin/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
diff --git a/bundles/org.eclipse.equinox.wireadmin/.project b/bundles/org.eclipse.equinox.wireadmin/.project
deleted file mode 100644
index 72bdd5f39..000000000
--- a/bundles/org.eclipse.equinox.wireadmin/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.equinox.wireadmin</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/bundles/org.eclipse.equinox.wireadmin/.settings/org.eclipse.jdt.core.prefs b/bundles/org.eclipse.equinox.wireadmin/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 7b307193c..000000000
--- a/bundles/org.eclipse.equinox.wireadmin/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,49 +0,0 @@
-#Fri Dec 16 09:21:02 CST 2005
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
-org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
-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=warning
-org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
-org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
-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=warning
-org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
-org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
-org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
-org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
-org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
-org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
-org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore
-org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
-org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
-org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning
-org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
-org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
-org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
-org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.unusedImport=error
-org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
-org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
-org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
-org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
diff --git a/bundles/org.eclipse.equinox.wireadmin/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.wireadmin/META-INF/MANIFEST.MF
deleted file mode 100644
index ab535c006..000000000
--- a/bundles/org.eclipse.equinox.wireadmin/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,18 +0,0 @@
-Bundle-ManifestVersion: 2
-Bundle-SymbolicName: org.eclipse.equinox.wireadmin
-Bundle-Name: %bundleName
-Bundle-Vendor: %bundleVendor
-Bundle-Copyright: %bundleCopyright
-Bundle-Version: 1.0.0.qualifier
-Bundle-Activator: org.eclipse.equinox.wireadmin.Activator
-Bundle-Localization: plugin
-Import-Package: org.eclipse.osgi.framework.eventmgr,
- org.osgi.framework;version="1.1",
- org.osgi.service.log;version="1.2",
- org.osgi.service.prefs;version="1.0",
- org.osgi.service.wireadmin;version="1.0",
- org.osgi.util.tracker;version="1.2",
- org.eclipse.osgi.util
-Export-Package: org.eclipse.equinox.wireadmin;x-internal=true
-Import-Service: org.osgi.service.log.LogService, org.osgi.service.prefs
-Export-Service: org.osgi.service.wireadmin.WireAdmin
diff --git a/bundles/org.eclipse.equinox.wireadmin/about.html b/bundles/org.eclipse.equinox.wireadmin/about.html
deleted file mode 100644
index b2f1e6bad..000000000
--- a/bundles/org.eclipse.equinox.wireadmin/about.html
+++ /dev/null
@@ -1,22 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
-<!-- saved from url=(0043)http://www.eclipse.org/legal/epl/about.html -->
-<HTML><HEAD><TITLE>About</TITLE>
-<META http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-<META content="MSHTML 6.00.2800.1498" name=GENERATOR></HEAD>
-<BODY lang=EN-US>
-<H2>About This Content</H2>
-<P>February 24, 2005</P>
-<H3>License</H3>
-<P>The Eclipse Foundation makes available all content in this plug-in
-("Content"). Unless otherwise indicated below, the Content is provided to you
-under the terms and conditions of the Eclipse Public License Version 1.0
-("EPL"). A copy of the EPL is available at <A
-href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</A>.
-For purposes of the EPL, "Program" will mean the Content.</P>
-<P>If you did not receive this Content directly from the Eclipse Foundation, the
-Content is being redistributed by another party ("Redistributor") and different
-terms and conditions may apply to your use of any object code in the Content.
-Check the Redistributor's license that was provided with the Content. If no such
-license exists, contact the Redistributor. Unless otherwise indicated below, the
-terms and conditions of the EPL still apply to any source code in the
-Content.</P></BODY></HTML>
diff --git a/bundles/org.eclipse.equinox.wireadmin/build.properties b/bundles/org.eclipse.equinox.wireadmin/build.properties
deleted file mode 100644
index d855c169e..000000000
--- a/bundles/org.eclipse.equinox.wireadmin/build.properties
+++ /dev/null
@@ -1,16 +0,0 @@
-###############################################################################
-# Copyright (c) 2005 IBM Corporation.
-# 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:
-# IBM Corporation - initial API and implementation
-###############################################################################
-bin.includes = META-INF/,\
- plugin*.properties,\
- about.html,\
- .
-source.. = src/
-output.. = bin/
diff --git a/bundles/org.eclipse.equinox.wireadmin/plugin.properties b/bundles/org.eclipse.equinox.wireadmin/plugin.properties
deleted file mode 100644
index 7eff0861a..000000000
--- a/bundles/org.eclipse.equinox.wireadmin/plugin.properties
+++ /dev/null
@@ -1,13 +0,0 @@
-###############################################################################
-# Copyright (c) 2005 IBM Corporation.
-# 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:
-# IBM Corporation - initial API and implementation
-###############################################################################
-bundleVendor = Eclipse.org
-bundleName = Wire Admin Service
-bundleCopyright = Copyright (c) IBM Corp. 2003, 2005
diff --git a/bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/Activator.java b/bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/Activator.java
deleted file mode 100644
index 73594576b..000000000
--- a/bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/Activator.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.wireadmin;
-
-import org.osgi.framework.*;
-import org.osgi.service.prefs.PreferencesService;
-import org.osgi.util.tracker.ServiceTracker;
-import org.osgi.util.tracker.ServiceTrackerCustomizer;
-
-public class Activator implements BundleActivator, ServiceTrackerCustomizer {
-
- private String wireadminString = "org.osgi.service.wireadmin.WireAdmin"; //$NON-NLS-1$
- private WireAdmin wireadmin;
- private ServiceRegistration wireadminReg;
- private PreferencesService preferencesService;
- private BundleContext context;
- private ServiceTracker prefsTracker;
-
- /**
- * @see BundleActivator#start(BundleContext)
- */
- public void start(BundleContext context_) throws Exception {
-
- this.context = context_;
- prefsTracker = new ServiceTracker(context, PreferencesService.class.getName(), this);
- prefsTracker.open();
- }
-
- /**
- * @see BundleActivator#stop(BundleContext)
- */
- public void stop(BundleContext context_) throws Exception {
- if(wireadminReg != null)
- {
- wireadminReg.unregister();
- wireadmin.destroy();
- }
-
- }
-
- public Object addingService(ServiceReference reference) {
- prefsTracker.close();
- if (preferencesService == null) {
- preferencesService = (PreferencesService) context.getService(reference);
- registerWireAdminService();
- return preferencesService;
- }
- return null; //we don't want to track a service we are not using
- }
-
- public void modifiedService(ServiceReference reference, Object service) { //do nothing
-
- }
-
- public void removedService(ServiceReference reference, Object service) {
- if (service == preferencesService) {
- preferencesService = null;
- wireadminReg.unregister();
- }
- }
-
- public void registerWireAdminService() {
- wireadmin = new WireAdmin(context);
- wireadminReg = context.registerService(wireadminString, wireadmin, null);
- wireadmin.setServiceReference(wireadminReg.getReference());
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/ConsumerCustomizer.java b/bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/ConsumerCustomizer.java
deleted file mode 100644
index 9a2ca949c..000000000
--- a/bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/ConsumerCustomizer.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.wireadmin;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.wireadmin.Consumer;
-import org.osgi.util.tracker.ServiceTrackerCustomizer;
-
-public class ConsumerCustomizer implements ServiceTrackerCustomizer {
-
- protected Wire wire;
- protected BundleContext context;
-
- public ConsumerCustomizer(BundleContext context, Wire wire) {
- this.wire = wire;
- this.context = context;
- }
-
- /**
- * @see ServiceTrackerCustomizer#addingService(ServiceReference)
- */
- public Object addingService(ServiceReference reference) {
- Consumer service = (Consumer) context.getService(reference);
- synchronized (wire) {
- wire.setConsumer(service, reference);
-
- return (service);
- }
- }
-
- /**
- * @see ServiceTrackerCustomizer#modifiedService(ServiceReference, Object)
- */
- public void modifiedService(ServiceReference reference, Object service) {
- synchronized (wire) {
- //our flavors and other properties may have changed
- wire.setConsumerProperties(reference);
- }
- }
-
- /**
- * @see ServiceTrackerCustomizer#removedService(ServiceReference, Object)
- */
- public void removedService(ServiceReference reference, Object service) {
- synchronized (wire) {
- wire.removeConsumer();
- context.ungetService(reference);
- }
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/ConsumersCustomizer.java b/bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/ConsumersCustomizer.java
deleted file mode 100644
index 8e866abdf..000000000
--- a/bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/ConsumersCustomizer.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.wireadmin;
-
-import org.osgi.framework.*;
-import org.osgi.service.wireadmin.Consumer;
-import org.osgi.util.tracker.ServiceTrackerCustomizer;
-
-public class ConsumersCustomizer implements ServiceTrackerCustomizer {
-
- protected BundleContext context;
- protected WireAdmin wireAdmin;
-
- public ConsumersCustomizer(BundleContext context, WireAdmin wireAdmin) {
- this.context = context;
- this.wireAdmin = wireAdmin;
- }
-
- /**
- * @see ServiceTrackerCustomizer#addingService(ServiceReference)
- */
- public Object addingService(ServiceReference reference) {
- Consumer service = (Consumer) context.getService(reference);
- String pid = (String) reference.getProperty("service.pid"); //$NON-NLS-1$
-
- try {
- //if a wire contains this producer, the wire notify it
- if (wireAdmin.getWires(wireAdmin.consumerFilter + pid + ")") == null) { //$NON-NLS-1$
- wireAdmin.notifyConsumer(service, pid);
- }
- } catch (InvalidSyntaxException ex) {
- ex.printStackTrace();
- }
- return (service);
- }
-
- /**
- * @see ServiceTrackerCustomizer#modifiedService(ServiceReference, Object)
- */
- public void modifiedService(ServiceReference reference, Object service) {
- //do nothing
- }
-
- /**
- * @see ServiceTrackerCustomizer#removedService(ServiceReference, Object)
- */
- public void removedService(ServiceReference reference, Object service) {
-
- context.ungetService(reference);
- }
-}
diff --git a/bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/ExternalMessages.properties b/bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/ExternalMessages.properties
deleted file mode 100644
index f90e6525f..000000000
--- a/bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/ExternalMessages.properties
+++ /dev/null
@@ -1,14 +0,0 @@
-###############################################################################
-# Copyright (c) 2002, 2005 IBM Corporation.
-# 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:
-# IBM Corporation - initial API and implementation
-###############################################################################
-BACKING_STORE_READ_EXCEPTION=WireAdmin is unable to read its data from backing store {0}
-WIREADMIN_UNREGISTERED_EXCEPTION=The WireAdmin Service has been unregistered {0}
-WIREADMIN_EVENT_DISPATCH_ERROR=Error dispatching WireAdmin Events {0}
-WIREADMIN_KEYS_CASE_INSENSITIVE_MATCH=Property keys can not be case insensitive matches \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/LogMessages.properties b/bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/LogMessages.properties
deleted file mode 100644
index bc1bf530c..000000000
--- a/bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/LogMessages.properties
+++ /dev/null
@@ -1,14 +0,0 @@
-###############################################################################
-# Copyright (c) 2002, 2005 IBM Corporation.
-# 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:
-# IBM Corporation - initial API and implementation
-###############################################################################
-Unknown_Log_level=Unknown Log Level
-Info=Log Info
-Warning=Log Warning
-Error=Log Error \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/LogTracker.java b/bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/LogTracker.java
deleted file mode 100644
index 67b8cd1ee..000000000
--- a/bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/LogTracker.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.wireadmin;
-
-import java.io.PrintStream;
-import java.text.DateFormat;
-import java.util.Calendar;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.log.LogService;
-import org.osgi.util.tracker.ServiceTracker;
-
-/**
- * LogTracker class. This class encapsulates the LogService
- * and handles all issues such as the service coming and going.
- */
-
-public class LogTracker extends ServiceTracker implements LogService {
- /** LogService interface class name */
- protected final static String clazz = "org.osgi.service.log.LogService"; //$NON-NLS-1$
-
- /** PrintStream to use if LogService is unavailable */
- protected PrintStream out;
-
- /** Calendar and DateFormat to user if LogService is unavailable */
- private static Calendar calendar;
- private static DateFormat dateFormat;
- private String timestamp;
-
- /**
- * Create new LogTracker.
- *
- * @param context BundleContext of parent bundle.
- * @param out Default PrintStream to use if LogService is unavailable.
- */
- public LogTracker(BundleContext context, PrintStream out) {
- super(context, clazz, null);
- this.out = out;
- calendar = Calendar.getInstance();
- dateFormat = DateFormat.getDateTimeInstance();
- open();
- }
-
- /*
- * ----------------------------------------------------------------------
- * LogService Interface implementation
- * ----------------------------------------------------------------------
- */
-
- public void log(int level, String message) {
- log(null, level, message, null);
- }
-
- public void log(int level, String message, Throwable exception) {
- log(null, level, message, exception);
- }
-
- public void log(ServiceReference reference, int level, String message) {
- log(reference, level, message, null);
- }
-
- public synchronized void log(ServiceReference reference, int level, String message, Throwable exception) {
- ServiceReference[] references = getServiceReferences();
-
- if (references != null) {
- int size = references.length;
-
- for (int i = 0; i < size; i++) {
- LogService service = (LogService) getService(references[i]);
- if (service != null) {
- try {
- service.log(reference, level, message, exception);
- } catch (Exception e) {
- //do nothing
- }
- }
- }
-
- return;
- }
-
- noLogService(level, message, exception, reference);
- }
-
- /**
- * The LogService is not available so we write the message to a PrintStream.
- *
- * @param level Logging level
- * @param message Log message.
- * @param throwable Log exception or null if none.
- * @param reference ServiceReference associated with message or null if none.
- */
- protected void noLogService(int level, String message, Throwable throwable, ServiceReference reference) {
- if (out != null) {
- synchronized (out) {
- // Bug #113286. If no log service present and messages are being
- // printed to stdout, prepend message with a timestamp.
- timestamp = dateFormat.format(calendar.getTime());
- out.print(timestamp + " "); //$NON-NLS-1$
-
- switch (level) {
- case LOG_DEBUG : {
- out.print("Debug: "); //$NON-NLS-1$
-
- break;
- }
- case LOG_INFO : {
- out.print(LogTrackerMsg.Info);
-
- break;
- }
- case LOG_WARNING : {
- out.print(LogTrackerMsg.Warning);
-
- break;
- }
- case LOG_ERROR : {
- out.print(LogTrackerMsg.Error);
-
- break;
- }
- default : {
- out.print("["); //$NON-NLS-1$
- out.print(LogTrackerMsg.Unknown_Log_level);
- out.print("]: "); //$NON-NLS-1$
-
- break;
- }
- }
-
- out.println(message);
-
- if (reference != null) {
- out.println(reference);
- }
-
- if (throwable != null) {
- throwable.printStackTrace(out);
- }
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/LogTrackerMsg.java b/bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/LogTrackerMsg.java
deleted file mode 100644
index 7a9a0d29f..000000000
--- a/bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/LogTrackerMsg.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.wireadmin;
-
-import org.eclipse.osgi.util.NLS;
-
-public class LogTrackerMsg extends NLS {
- private static final String BUNDLE_NAME = "org.eclipse.equinox.wireadmin.LogMessages"; //$NON-NLS-1$
-
- public static String Unknown_Log_level;
- public static String Info;
- public static String Warning;
- public static String Error;
-
- static {
- // initialize resource bundles
- NLS.initializeMessages(BUNDLE_NAME, LogTrackerMsg.class);
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/ProducerCustomizer.java b/bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/ProducerCustomizer.java
deleted file mode 100644
index ed6b3bfd5..000000000
--- a/bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/ProducerCustomizer.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.wireadmin;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.wireadmin.Producer;
-import org.osgi.util.tracker.ServiceTrackerCustomizer;
-
-public class ProducerCustomizer implements ServiceTrackerCustomizer {
-
- protected Wire wire;
- protected BundleContext context;
-
- public ProducerCustomizer(BundleContext context, Wire wire) {
- this.wire = wire;
- this.context = context;
- }
-
- /**
- * @see ServiceTrackerCustomizer#addingService(ServiceReference)
- */
- public Object addingService(ServiceReference reference) {
- Object service = context.getService(reference);
- wire.setProducer((Producer) service, reference);
- return (service);
- }
-
- /**
- * @see ServiceTrackerCustomizer#modifiedService(ServiceReference, Object)
- */
- public void modifiedService(ServiceReference reference, Object service) {
- //the producer flavor filters may have changed
- wire.setProducerProperties(reference);
- }
-
- /**
- * @see ServiceTrackerCustomizer#removedService(ServiceReference, Object)
- */
- public void removedService(ServiceReference reference, Object service) {
- wire.removeProducer();
- context.ungetService(reference);
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/ProducersCustomizer.java b/bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/ProducersCustomizer.java
deleted file mode 100644
index 55ce4864f..000000000
--- a/bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/ProducersCustomizer.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.wireadmin;
-
-import org.osgi.framework.*;
-import org.osgi.service.wireadmin.Producer;
-import org.osgi.util.tracker.ServiceTrackerCustomizer;
-
-public class ProducersCustomizer implements ServiceTrackerCustomizer {
-
- protected BundleContext context;
- protected WireAdmin wireAdmin;
-
- public ProducersCustomizer(BundleContext context, WireAdmin wireAdmin) {
- this.context = context;
- this.wireAdmin = wireAdmin;
- }
-
- /**
- * @see ServiceTrackerCustomizer#addingService(ServiceReference)
- */
- public Object addingService(ServiceReference reference) {
- Producer service = (Producer) context.getService(reference);
- String pid = (String) reference.getProperty("service.pid"); //$NON-NLS-1$
-
- try {
- //if a wire contains this producer, the wire notifies it
- if (wireAdmin.getWires(wireAdmin.producerFilter + pid + ")") == null) { //$NON-NLS-1$
- wireAdmin.notifyProducer(service, pid);
- }
- } catch (InvalidSyntaxException ex) {
- ex.printStackTrace();
- }
-
- return (service);
- }
-
- /**
- * @see ServiceTrackerCustomizer#modifiedService(ServiceReference, Object)
- */
- public void modifiedService(ServiceReference reference, Object service) {
- //do nothing
- }
-
- /**
- * @see ServiceTrackerCustomizer#removedService(ServiceReference, Object)
- */
- public void removedService(ServiceReference reference, Object service) {
-
- context.ungetService(reference);
- }
-}
diff --git a/bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/ReadOnlyDictionary.java b/bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/ReadOnlyDictionary.java
deleted file mode 100644
index bc5a49318..000000000
--- a/bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/ReadOnlyDictionary.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.wireadmin;
-
-import java.util.*;
-
-public class ReadOnlyDictionary extends Hashtable {
-
- /**
- * Serial Version UID
- */
- private static final long serialVersionUID = 2878360633574220743L;
- private Dictionary dictionary;
-
- public ReadOnlyDictionary(Dictionary dictionary) {
- this.dictionary = dictionary;
- }
-
- public Object put(Object key, Object value) {
- return (null);
- }
-
- public void clear() {
- //??? Do I need to throw an exception
- }
-
- public Enumeration elements() {
- return dictionary.elements();
- }
-
- public boolean equals(Object object) {
- //??? - What should we really do here
- if (object instanceof ReadOnlyDictionary) {
- return super.equals(object);
- }
- return dictionary.equals(object);
- }
-
- public Object get(Object key) {
- return dictionary.get(key);
- }
-
- public int hashCode() {
- //??? is this right
- return dictionary.hashCode();
- }
-
- public boolean isEmpty() {
- return dictionary.isEmpty();
- }
-
- public Enumeration keys() {
- return dictionary.keys();
- }
-
- public Object remove(Object key) {
- //??? - throw exception???
- return (null);
- }
-
- public int size() {
- return dictionary.size();
- }
-
- public String toString() {
- return dictionary.toString();
- }
-}
diff --git a/bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/Wire.java b/bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/Wire.java
deleted file mode 100644
index 1ba108cf3..000000000
--- a/bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/Wire.java
+++ /dev/null
@@ -1,490 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.wireadmin;
-
-import java.util.*;
-import org.osgi.framework.*;
-import org.osgi.service.wireadmin.*;
-import org.osgi.util.tracker.ServiceTracker;
-
-public class Wire implements org.osgi.service.wireadmin.Wire {
-
- protected boolean valid = false;
- protected boolean connected = false;
-
- protected ServiceTracker consumerTracker;
- protected ServiceTracker producerTracker;
-
- protected Producer producer = null;
- protected Consumer consumer = null;
-
- protected Class[] flavors = null;
- protected Class[] producerFlavors = null;
-
- protected Object lastValue;
- protected long lastTime = -1;
-
- protected Dictionary properties;
- protected WireAdmin wireadmin;
-
- private String pid;
- private String producerPID;
- private String consumerPID;
-
- private boolean producerFilterExists;
- private Filter wireFilter;
-
- protected Wire(String pid, String producerPID, String consumerPID, Dictionary props, WireAdmin wireadmin) {
- this.pid = pid;
- this.producerPID = producerPID;
- this.consumerPID = consumerPID;
-
- this.wireadmin = wireadmin;
- setProperties(props);
-
- String consumerFilterString = "(&(objectClass=org.osgi.service.wireadmin.Consumer)(service.pid=" + consumerPID + "))";//$NON-NLS-1$ //$NON-NLS-2$
- String producerFilterString = "(&(objectClass=org.osgi.service.wireadmin.Producer)(service.pid=" + producerPID + "))";//$NON-NLS-1$ //$NON-NLS-2$
- Filter consumerFilter = null;
- Filter producerFilter = null;
- wireFilter = (Filter) properties.get(WireConstants.WIREADMIN_FILTER);
- try {
- consumerFilter = wireadmin.context.createFilter(consumerFilterString);
- producerFilter = wireadmin.context.createFilter(producerFilterString);
- } catch (InvalidSyntaxException ex) {
- ex.printStackTrace();//FIXME
- }
-
- ConsumerCustomizer consumerCustomizer = new ConsumerCustomizer(wireadmin.context, this);
- ProducerCustomizer producerCustomizer = new ProducerCustomizer(wireadmin.context, this);
-
- consumerTracker = new ServiceTracker(wireadmin.context, consumerFilter, consumerCustomizer);
- producerTracker = new ServiceTracker(wireadmin.context, producerFilter, producerCustomizer);
-
- valid = true;
- }
-
- /**
- * Return the state of this <tt>Wire</tt> object.
- *
- * <p>A connected <tt>Wire</tt> must always be disconnected before
- * becoming invalid.
- *
- * @return <tt>false</tt> if this <tt>Wire</tt> is invalid because it
- * has been deleted via {@link WireAdmin#deleteWire};
- * <tt>true</tt> otherwise.
- */
- /**
- * Return the state of this <tt>Wire</tt> object.
- *
- * <p>A connected <tt>Wire</tt> must always be disconnected before
- * becoming invalid.
- *
- * @return <tt>false</tt> if this <tt>Wire</tt> is invalid because it
- * has been deleted via {@link WireAdmin#deleteWire};
- * <tt>true</tt> otherwise.
- */
- public boolean isValid() {
- return (valid);
- }
-
- /**
- * Return the connection state of this <tt>Wire</tt> object.
- *
- * <p>A <tt>Wire</tt> is connected after the Wire Admin service receives
- * notification that the <tt>Producer</tt> service and
- * the <tt>Consumer</tt> service for this <tt>Wire</tt> object are both registered.
- * This method will return <tt>true</tt> prior to notifying the <tt>Producer</tt>
- * and <tt>Consumer</tt> services via calls
- * to their respective <tt>consumersConnected</tt> and <tt>producersConnected</tt>
- * methods.
- * <p>A <tt>WireAdminEvent</tt> of type {@link WireAdminEvent#WIRE_CONNECTED}
- * must be broadcast by the Wire Admin service when
- * the <tt>Wire</tt> becomes connected.
- *
- * <p>A <tt>Wire</tt> object
- * is disconnected when either the <tt>Consumer</tt> or <tt>Producer</tt>
- * service is unregistered or the <tt>Wire</tt> object is deleted.
- * <p>A <tt>WireAdminEvent</tt> of type {@link WireAdminEvent#WIRE_DISCONNECTED}
- * must be broadcast by the Wire Admin service when
- * the <tt>Wire</tt> becomes disconnected.
- *
- * @return <tt>true</tt> if both the <tt>Producer</tt> and <tt>Consumer</tt>
- * for this <tt>Wire</tt> object are connected to the <tt>Wire</tt> object;
- * <tt>false</tt> otherwise.
- */
-
- public boolean isConnected() {
- return (connected);
- }
-
- /**
- * Return the list of data types understood by the
- * <tt>Consumer</tt> service connected to this <tt>Wire</tt> object. Note that
- * subclasses of the classes in this list are allowed as well.
- *
- * <p>The list is the value of the {@link Consumer#WIREADMIN_CONSUMER_FLAVORS}
- * service property of the
- * <tt>Consumer</tt> service object connected to this object. If no such
- * property was registered, this method must return null.
- *
- * @return An array containing the list of classes understood by the
- * <tt>Consumer</tt> service or <tt>null</tt> if the <tt>Consumer</tt> object is
- * not currently a registered service, or the <tt>Wire</tt> has been disconnected,
- * or the consumer did not register a {@link #WIREADMIN_CONSUMER_FLAVORS} property.
- */
- public Class[] getFlavors() {
- return (flavors);
- }
-
- protected void setConsumerProperties(ServiceReference consumerReference) {
- if (consumerReference != null) {
- try {
- flavors = (Class[]) consumerReference.getProperty(WireConstants.WIREADMIN_CONSUMER_FLAVORS);
- } catch (ClassCastException ex) {
- // log error???
- }
- }
- }
-
- /**
- * Update the value.
- *
- * <p>This methods is called by the <tt>Producer</tt> service to
- * notify the <tt>Consumer</tt> service connected to this <tt>Wire</tt> object
- * of an updated value.
- * <p>If the properties of this <tt>Wire</tt> object contain a
- * {@link Constants#WIREADMIN_FILTER} property,
- * then filtering is performed on this <tt>Wire</tt>.
- * If the <tt>Producer</tt> service connected to this <tt>Wire</tt>
- * object was registered with the service
- * property {@link Constants#WIREADMIN_PRODUCER_FILTERS}, the
- * <tt>Producer</tt> service will perform the filter the value according to the rules specified
- * for the filter. Otherwise, this <tt>Wire</tt> object
- * will filter the value according to the rules specified for the filter.
- * <p>If no filtering is done, or the filter indicates the updated value should
- * be delivered to the <tt>Consumer</tt> service, then
- * this <tt>Wire</tt> object must call
- * the {@link Consumer#updated} method with the updated value.
- * If this <tt>Wire</tt> object is not connected, then the <tt>Consumer</tt>
- * service must not be called.
- *
- * <p>A <tt>WireAdminEvent</tt> of type {@link WireAdminEvent#WIRE_TRACE}
- * must be broadcast by the Wire Admin service after
- * the <tt>Consumer</tt> service has been successfully called.
- *
- * @param value The updated value. The value should be an instance of
- * one of the types returned by {@link #getFlavors}.
- * @see Constants#WIREADMIN_FILTER
- */
- //FIXME -- wire filter
- public void update(Object value) {
- wireadmin.checkAlive();
- synchronized (this) {
- int length = flavors.length;
- boolean correctFlavors = false;
- for (int i = 0; i < length; i++) {
- if (flavors[i].isInstance(value)) {
- correctFlavors = true;
- break;
- }
- }
- if (!correctFlavors) {
- return;
- }
- if (consumer != null) {
- //if the producer filter property is set, the producer will do the filtering
- //FIXME - check conditions correctly
- if (producerFilterExists || wireFilter == null) {
- try {
- consumer.updated(this, value);
- lastValue = value;
- //lastTime = time;
- wireadmin.eventProducer.generateEvent(WireAdminEvent.WIRE_TRACE, this, null);
- } catch (Exception ex) {
- wireadmin.eventProducer.generateEvent(WireAdminEvent.CONSUMER_EXCEPTION, this, ex);
- }
- } else {
- long time = Calendar.getInstance().getTime().getTime();
- //get object properties
- Hashtable valueProps = new Hashtable(10);
- valueProps.put(WireConstants.WIREVALUE_CURRENT, value);
- valueProps.put(WireConstants.WIREVALUE_PREVIOUS, lastValue);
- valueProps.put(WireConstants.WIREVALUE_ELAPSED, new Long(time - lastTime)); //???LONG???
- try {
- // value-lastValue;
- if (value instanceof Short) {
- int result = ((Short) value).shortValue() - ((Short) lastValue).shortValue();
- valueProps.put(WireConstants.WIREVALUE_DELTA_RELATIVE, new Integer(result));
- if (result < 0) {
- result = result * -1;
- }
- valueProps.put(WireConstants.WIREVALUE_DELTA_ABSOLUTE, new Integer(result));
- }
- if (value instanceof Integer) {
- int result = ((Integer) value).intValue() - ((Integer) lastValue).intValue();
- valueProps.put(WireConstants.WIREVALUE_DELTA_RELATIVE, new Integer(result));
- if (result < 0) {
- result = result * -1;
- }
- valueProps.put(WireConstants.WIREVALUE_DELTA_ABSOLUTE, new Integer(result));
- }
- if (value instanceof Long) {
- long result = ((Long) value).longValue() - ((Long) lastValue).longValue();
- valueProps.put(WireConstants.WIREVALUE_DELTA_RELATIVE, new Long(result));
- if (result < 0) {
- result = result * -1;
- }
- valueProps.put(WireConstants.WIREVALUE_DELTA_ABSOLUTE, new Long(result));
- }
- if (value instanceof Double) {
- long result = ((Long) value).longValue() - ((Long) lastValue).longValue();
- valueProps.put(WireConstants.WIREVALUE_DELTA_RELATIVE, new Long(result));
- if (result < 0) {
- result = result * -1;
- }
- valueProps.put(WireConstants.WIREVALUE_DELTA_ABSOLUTE, new Long(result));
- }
- } catch (NumberFormatException ex) {
- //we don't have two numeric values so do nothing
- }
- }
- }
- }
- }
-
- /**
- * Poll for an updated value.
- *
- * <p>This methods is normally called by the <tt>Consumer</tt> service to
- * request an updated value from the <tt>Producer</tt> service
- * connected to this <tt>Wire</tt> object.
- * This <tt>Wire</tt> object will call
- * the {@link Producer#polled} method to obtain an updated value.
- * If this <tt>Wire</tt> object is not connected, then the <tt>Producer</tt>
- * service must not be called.
- *
- * <p>A <tt>WireAdminEvent</tt> of type {@link WireAdminEvent#WIRE_TRACE}
- * must be broadcast by the Wire Admin service after
- * the <tt>Producer</tt> service has been successfully called.
- *
- * @return An updated value whose type should be one of the types
- * returned by {@link #getFlavors} or <tt>null</tt> if
- * the <tt>Wire</tt> object is not connected,
- * the <tt>Producer</tt> service threw an exception, or
- * the <tt>Producer</tt> service returned a value which is not an instance of
- * one of the types returned by {@link #getFlavors}.
- */
- public synchronized Object poll() {
- wireadmin.checkAlive();
- if (producer != null) {
- try {
- synchronized (this) {
- Object value = producer.polled(this);
- wireadmin.eventProducer.generateEvent(WireAdminEvent.WIRE_TRACE, this, null);
- if (checkFlavor(value)) {
- lastValue = value;
- return (value);
- }
- return (null);
- }
- } catch (Exception ex) {
- wireadmin.eventProducer.generateEvent(WireAdminEvent.PRODUCER_EXCEPTION, this, ex);
- return (null);
- }
- }
- return (null);
-
- }
-
- /**
- * Return the last value sent through this <tt>Wire</tt> object.
- *
- * <p>The returned value is the most recent, valid value passed to the
- * {@link #update} method or returned by the {@link #poll} method
- * of this object. If filtering is applied by the <tt>Wire</tt> object,
- * this is still the value as set by the <tt>Producer</tt> service.
- *
- * @return The last value passed though this <tt>Wire</tt> object
- * or <tt>null</tt> if no valid values have been passed.
- */
-
- public Object getLastValue() {
- return (lastValue);
- }
-
- /**
- * Return the wire properties for this <tt>Wire</tt> object.
- *
- * @return The properties for this <tt>Wire</tt> object.
- * The returned <tt>Dictionary</tt> must be read only.
- */
-
- public Dictionary getProperties() {
- return (new ReadOnlyDictionary(properties));
- }
-
- protected void connect() {
- connected = true;
- wireadmin.notifyConsumer(consumer, consumerPID);
- wireadmin.notifyProducer(producer, producerPID);
-
- //send event
- wireadmin.eventProducer.generateEvent(WireAdminEvent.WIRE_CONNECTED, this, null);
- }
-
- protected void disconnect() {
- connected = false;
- wireadmin.notifyConsumer(consumer, consumerPID);
- wireadmin.notifyProducer(producer, producerPID);
-
- //send event
- wireadmin.eventProducer.generateEvent(WireAdminEvent.WIRE_DISCONNECTED, this, null);
- }
-
- protected void destroy() {
- if (consumer != null) {
- removeConsumer();
- }
- if (producer != null) {
- removeProducer();
- }
- consumerTracker.close();
- producerTracker.close();
- valid = false;
- }
-
- protected void setConsumer(Consumer consumer, ServiceReference reference) {
- this.consumer = consumer;
- setConsumerProperties(reference);
- if (producer != null) {
- connect();
- }
- }
-
- protected void setProducer(Producer producer, ServiceReference reference) {
- this.producer = producer;
- setProducerProperties(reference);
- if (consumer != null) {
- connect();
- }
- }
-
- protected void setProducerProperties(ServiceReference reference) {
- producerFlavors = (Class[]) reference.getProperty(WireConstants.WIREADMIN_PRODUCER_FLAVORS);
- //TODO - this method need to be completed
- //String[] keys = reference.getPropertyKeys();
- //need to find out if WIREADMIN_PRODUCER_FILTERS key exists
- if (reference.getProperty(WireConstants.WIREADMIN_PRODUCER_FILTERS) != null) {
- producerFilterExists = true;
- }
- /*
- for(int i=0;i<keys.length;i++)
- {
- if(keys[i] == (WireConstants.WIREADMIN_PRODUCER_FILTERS))
- {
- producerFilterExists = true;
- return;
- }
- } */
- }
-
- protected void removeProducer() {
- producerFilterExists = false;
- producerFlavors = null;
-
- if (connected) {
- //The consumer is now "not connected" by this wire
- disconnect();
- }
- producer = null;
- }
-
- protected void removeConsumer() {
-
- if (connected) {
- disconnect();
- }
- consumer = null;
- flavors = null;
- }
-
- protected String getPid() {
- return pid;
- }
-
- private boolean checkFlavor(Object value) {
- if (flavors == null) {
- return (true);
- }
- for (int i = 0; i < flavors.length; i++) {
- if (value.getClass().isInstance(flavors[i])) {
- return (true);
- }
- }
- return (false);
- }
-
- /**
- * Return the calculated scope of this <tt>Wire</tt> object.
- *
- * The purpose of the <tt>Wire</tt> object's scope is to allow a Producer
- * and/or Consumer service to produce/consume different types
- * over a single <tt>Wire</tt> object (this was deemed necessary for efficiency
- * reasons). Both the Consumer service and the
- * Producer service must set an array of scope names (their scope) with
- * the service registration property <tt>WIREADMIN_PRODUCER_SCOPE</tt>, or <tt>WIREADMIN_CONSUMER_SCOPE</tt> when they can
- * produce multiple types. If a Producer service can produce different types, it should set this property
- * to the array of scope names it can produce, the Consumer service
- * must set the array of scope names it can consume. The scope of a <tt>Wire</tt>
- * object is defined as the intersection of permitted scope names of the
- * Producer service and Consumer service.
- * <p>If neither the Consumer, or the Producer service registers scope names with its
- * service registration, then the <tt>Wire</tt> object's scope must be <tt>null</tt>.
- * <p>The <tt>Wire</tt> object's scope must not change when a Producer or Consumer services
- * modifies its scope.
- * <p>A scope name is permitted for a Producer service when the registering bundle has
- * <tt>WirePermission[PRODUCE]</tt>, and for a Consumer service when
- * the registering bundle has <tt>WirePermission[CONSUME]</tt>.<p>
- * If either Consumer service or Producer service has not set a <tt>WIREADMIN_*_SCOPE</tt> property, then
- * the returned value must be <tt>null</tt>.<p>
- * If the scope is set, the <tt>Wire</tt> object must enforce the scope names when <tt>Envelope</tt> objects are
- * used as a parameter to update or returned from the <tt>poll</tt> method. The <tt>Wire</tt> object must then
- * remove all <tt>Envelope</tt> objects with a scope name that is not permitted.
- *
- * @return A list of permitted scope names or null if the Produce or Consumer service has set no scope names.
- */
- public String[] getScope() {
- return null;
- }
-
- /**
- * Return true if the given name is in this <tt>Wire</tt> object's scope.
- *
- * @param name The scope name
- * @return true if the name is listed in the permitted scope names
- */
- public boolean hasScope(String name) {
- return false;
- }
-
- protected void setProperties(Dictionary newprops) {
- newprops.put(WireConstants.WIREADMIN_PID, pid);
- newprops.put(WireConstants.WIREADMIN_PRODUCER_PID, producerPID);
- newprops.put(WireConstants.WIREADMIN_CONSUMER_PID, consumerPID);
- properties = newprops;
- }
-
- protected void init() {
- consumerTracker.open();
- producerTracker.open();
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/WireAdmin.java b/bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/WireAdmin.java
deleted file mode 100644
index a16488e46..000000000
--- a/bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/WireAdmin.java
+++ /dev/null
@@ -1,432 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.wireadmin;
-
-import java.util.Dictionary;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Vector;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.Filter;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.log.LogService;
-import org.osgi.service.prefs.PreferencesService;
-import org.osgi.service.wireadmin.Consumer;
-import org.osgi.service.wireadmin.Producer;
-import org.osgi.service.wireadmin.WireAdminEvent;
-import org.osgi.service.wireadmin.WireConstants;
-import org.osgi.util.tracker.ServiceTracker;
-
-public class WireAdmin implements org.osgi.service.wireadmin.WireAdmin {
-
- protected Vector wires;
-
- protected BundleContext context;
-
- protected LogTracker log;
-
- protected WireAdminEventProducer eventProducer;
-
- protected ServiceReference reference;
-
- protected WireAdminStore wireAdminStore;
-
- protected int lastPid;
-
- private boolean alive = false;
-
- protected ServiceTracker producerTracker;
-
- protected ServiceTracker consumerTracker;
-
- protected final String consumerFilter = "(" + WireConstants.WIREADMIN_CONSUMER_PID + "="; //$NON-NLS-1$ //$NON-NLS-2$
-
- protected final String producerFilter = "(" + WireConstants.WIREADMIN_PRODUCER_PID + "="; //$NON-NLS-1$ //$NON-NLS-2$
-
- protected PreferencesService preferencesService;
-
- public WireAdmin(BundleContext context) {
- this.context = context;
- initWireAdmin();
- }
-
- /**
- * Create a new <tt>Wire</tt> object that connects a <tt>Producer</tt>
- * service to a <tt>Consumer</tt> service.
- *
- * The <tt>Producer</tt> service and <tt>Consumer</tt> service do not
- * have to be registered when the the <tt>Wire</tt> object is created.
- *
- * <p>
- * The <tt>Wire</tt> configuration data is persistently stored. All
- * <tt>Wire</tt> connections are reestablished when the <tt>WireAdmin</tt>
- * service is registered. A <tt>Wire</tt> connection can be removed by
- * using the {@link #deleteWire} method.
- *
- * <p>
- * The <tt>Wire</tt> object's properties must have case insensitive
- * <tt>String</tt> objects as keys (like the Framework). However, the case
- * of the key must be preserved. The type of the value of the property must
- * be one of the following:
- *
- * <pre>
- * type = basetype
- * | vector | arrays
- * basetype = String | Integer | Long
- * | Float | Double | Byte
- * | Short | BigInteger
- * | BigDecimal | Character
- * | Boolean
- * primitive = long | int | short
- * | char | byte | double | float
- * arrays = primitive '[]' | basetype '[]'
- * vector = Vector of basetype
- * </pre>
- *
- * <p>
- * The <tt>WireAdmin</tt> service must automatically add the following
- * <tt>Wire</tt> properties:
- * <ul>
- * <li> {@link #WIREADMIN_PID} set to the value of the wire's persistent
- * identity (PID). This value is generated by the <tt>WireAdmin</tt>
- * service when a <tt>Wire</tt> object is created. </li>
- * <li> {@link #WIREADMIN_PRODUCER_PID} set to the value of
- * <tt>Producer</tt> service's PID. </li>
- * <li> {@link #WIREADMIN_CONSUMER_PID} set to the value of
- * <tt>Consumer</tt> service's PID. </li>
- * </ul>
- * If the <tt>properties</tt> argument already contains any of these keys,
- * then the supplied values are replaced with the values assigned by the
- * <tt>WireAdmin</tt> service.
- *
- * <p>
- * The Wire Admin service must generate a {@link #WIREADMIN_CREATED} event
- * after the new <tt>Wire</tt> object becomes available from
- * {@link #getWires}.
- *
- * @param producerPID
- * The &quot;service.pid&quot; of the <tt>Producer</tt> service
- * to be connected to the <tt>Wire</tt>.
- * @param consumerPID
- * The &quot;service.pid&quot; of the <tt>Consumer</tt> service
- * to be connected to the <tt>Wire</tt>.
- * @param properties
- * The <tt>Wire</tt> object's properties. This argument may be
- * <tt>null</tt> if the caller does not wish to define any
- * <tt>Wire</tt> object's properties.
- * @return The <tt>Wire</tt> object for this connection.
- * @throws java.lang.IllegalArgumentException
- * If <tt>properties</tt> contains case variants of the same
- * key name.
- */
- public synchronized org.osgi.service.wireadmin.Wire createWire(
- String producerPID, String consumerPID, Dictionary properties) {
- checkAlive();
- // generate PID
- lastPid++;
- String pid = String.valueOf(lastPid);
- if (consumerPID == null || producerPID == null) {
- throw new IllegalArgumentException();
- }
- if (properties == null) {
- properties = new Hashtable(10);
- } else {
- checkProperties(properties);
- }
- Wire wire = createWire(pid, producerPID, consumerPID, properties);
- try {
- wireAdminStore.addWire(wire, properties);
- } catch (Exception ex) {
- log.log(LogService.LOG_ERROR,
- WireAdminMsg.BACKING_STORE_READ_EXCEPTION, ex);
- }
-
- eventProducer.generateEvent(WireAdminEvent.WIRE_CREATED, wire, null);
- return (wire);
- }
-
- protected Wire createWire(String pid, String producerPID,
- String consumerPID, Dictionary properties) {
- Wire wire = new Wire(pid, producerPID, consumerPID, properties, this);
- wires.addElement(wire);
- wire.init();
- return (wire);
- }
-
- /**
- * Disconnect a <tt>Producer</tt> service from a <tt>Consumer</tt>
- * service.
- *
- * <p>
- * The connection between a <tt>Producer</tt> service and a
- * <tt>Consumer</tt> service is removed. The persistently stored
- * configuration data for the <tt>Wire</tt> object is destroyed. The
- * <tt>Wire</tt> object's method {@link Wire#isValid} will return
- * <tt>false</tt> after it is destroyed.
- *
- * <p>
- * The Wire Admin service must generate a {@link #WIREADMIN_DELETED} event
- * after the <tt>Wire</tt> object becomes invalid.
- *
- * @param wire
- * The <tt>Wire</tt> object which is to be disconnected.
- */
- public void deleteWire(org.osgi.service.wireadmin.Wire wire) {
- checkAlive();
- wires.removeElement(wire);
- ((org.eclipse.equinox.wireadmin.Wire) wire).destroy();
- try {
- wireAdminStore.removeWire((Wire) wire);
- } catch (Exception ex) {
- log.log(LogService.LOG_ERROR, WireAdminMsg.BACKING_STORE_READ_EXCEPTION,
- ex);
- }
- eventProducer.generateEvent(WireAdminEvent.WIRE_DELETED, wire, null);
- }
-
- /**
- * Update the properties of a <tt>Wire</tt> object.
- *
- * The persistently stored configuration data for the <tt>Wire</tt> object
- * is updated with the new properties and then the <tt>Consumer</tt> and
- * <tt>Producer</tt> services will be called with the respective
- * {@link Consumer#producersConnected} and
- * {@link Producer#consumersConnected} methods. methods..
- *
- * <p>
- * The Wire Admin service must generate a {@link #WIREADMIN_UPDATED} event
- * after the new <tt>properties</tt> become available from the
- * <tt>Wire</tt> object.
- *
- * @param wire
- * The <tt>Wire</tt> object which is to be updated.
- * @param properties
- * The new <tt>Wire</tt> object's properties or <tt>null</tt>
- * if no properties are required.
- */
-
- public void updateWire(org.osgi.service.wireadmin.Wire wire,
- Dictionary properties) {
- checkAlive();
- checkProperties(properties);
- if (!wire.isValid()) {
- return;
- }
- ((org.eclipse.equinox.wireadmin.Wire) wire).setProperties(properties);
- try {
- wireAdminStore.updateWire((Wire) wire, properties);
- } catch (Exception ex) {
- log.log(LogService.LOG_ERROR, WireAdminMsg.BACKING_STORE_READ_EXCEPTION,
- ex);
- }
- try {
- Consumer consumer = ((org.eclipse.equinox.wireadmin.Wire) wire).consumer;
- Wire[] wireArray = new Wire[wires.size()];
- wires.copyInto(wireArray);
- if (consumer != null) {
- consumer.producersConnected(wireArray);
- }
- Producer producer = ((org.eclipse.equinox.wireadmin.Wire) wire).producer;
- if (producer != null) {
- producer.consumersConnected(wireArray);
- }
- eventProducer
- .generateEvent(WireAdminEvent.WIRE_UPDATED, wire, null);
- } catch (Exception ex) {
- // ???
- log.log(LogService.LOG_ERROR, WireAdminMsg.BACKING_STORE_READ_EXCEPTION,
- ex);
- }
-
- }
-
- /**
- * Return the <tt>Wire</tt> objects that match the given <tt>filter</tt>.
- *
- * <p>
- * The list of available <tt>Wire</tt> objects is matched against the
- * specified <tt>filter</tt>. <tt>Wire</tt> objects which match the
- * <tt>filter</tt> are returned. These <tt>Wire</tt> objects are not
- * necessarily connected. The Wire Admin service should not return invalid
- * <tt>Wire</tt> objects, but it is possible that a <tt>Wire</tt> object
- * is deleted after it was placed in the list.
- *
- * <p>
- * The filter matches against the <tt>Wire</tt> object's properties
- * including {@link Constants#WIREADMIN_PRODUCER_PID},
- * {@link Constants#WIREADMIN_CONSUMER_PID} and
- * {@link Constants#WIREADMIN_PID}.
- *
- * @param filter
- * Filter string to select <tt>Wire</tt> objects or
- * <tt>null</tt> to select all <tt>Wire</tt> objects.
- * @return An array of <tt>Wire</tt> objects which match the
- * <tt>filter</tt> or <tt>null</tt> if no <tt>Wire</tt>
- * objects match the <tt>filter</tt>.
- * @throws org.osgi.framework.InvalidSyntaxException
- * If the specified <tt>filter</tt> has an invalid syntax.
- * @see "org.osgi.framework.Filter"
- */
- public org.osgi.service.wireadmin.Wire[] getWires(String filterString)
- throws InvalidSyntaxException {
- checkAlive();
- return getWires(filterString, false);
-
- }
-
- protected Wire[] getConnectedWires(String filterString)
- throws InvalidSyntaxException {
- return getWires(filterString, true);
- }
-
- protected Wire[] getWires(String filterString, boolean connected)
- throws InvalidSyntaxException {
- Vector returnedWires;
- synchronized (this) {
- if (filterString == null) {
- returnedWires = wires;
- }
-
- else {
- Filter filter = context.createFilter(filterString); // We do
- // this
- // first so
- // an
- // InvalidSyntaxException will be
- // thrown even if there are no wires
- // present.
- returnedWires = new Vector();
- for (int i = 0; i < wires.size(); i++) {
- Wire wire = (Wire) wires.elementAt(i);
- if (filter.match(wire.properties)) {
- if (!connected || wire.isConnected()) {
- returnedWires.addElement(wire);
- }
- }
- }
- }
- int size = returnedWires.size();
- if (size == 0) {
- return (null);
- }
- Wire[] wireArray = new Wire[size];
- returnedWires.copyInto(wireArray);
- return (wireArray);
- }
- }
-
- protected void setServiceReference(ServiceReference reference) {
- if (this.reference == null) {
- this.reference = reference;
-
- eventProducer = new WireAdminEventProducer(reference, context, log,
- this);
- }
- }
-
- protected void destroy() {
- alive = false;
- wires = null;
- eventProducer.close();
- producerTracker.close();
- consumerTracker.close();
- }
-
- protected void checkAlive() {
- if (!alive) {
- throw (new IllegalStateException(
- WireAdminMsg.WIREADMIN_UNREGISTERED_EXCEPTION));
- }
-
- }
-
- protected void notifyProducer(Producer producer, String pid) {
- org.osgi.service.wireadmin.Wire[] wireArray = null;
- try {
- wireArray = getConnectedWires(producerFilter + pid + ")"); //$NON-NLS-1$
- } catch (InvalidSyntaxException ex) {
- ex.printStackTrace();
- }
-
- try {
- producer.consumersConnected(wireArray);
- } catch (Exception ex) {
- eventProducer.generateEvent(WireAdminEvent.PRODUCER_EXCEPTION,
- null, ex);
- }
-
- }
-
- protected void notifyConsumer(Consumer consumer, String pid) {
- org.osgi.service.wireadmin.Wire[] wireArray = null;
- try {
- wireArray = getConnectedWires(consumerFilter + pid + ")"); //$NON-NLS-1$
- } catch (InvalidSyntaxException ex) {
- ex.printStackTrace();
- }
-
- try {
- consumer.producersConnected(wireArray);
- } catch (Exception ex) {
- eventProducer.generateEvent(WireAdminEvent.CONSUMER_EXCEPTION,
- null, ex);
- }
-
- }
-
- private void checkProperties(Dictionary properties) {
- Enumeration e = properties.keys();
- Vector keys = new Vector(properties.size());
- while (e.hasMoreElements()) {
- String key = null;
- try {
- key = (String) e.nextElement();
- } catch (ClassCastException ex) {
- throw new IllegalArgumentException(
- WireAdminMsg.WIREADMIN_PROP_KEY_MUST_BE_STRING);
- }
- key = key.toUpperCase();
- if (keys.contains(key)) {
- throw new IllegalArgumentException(
- WireAdminMsg.WIREADMIN_KEYS_CASE_INSENSITIVE_MATCH);
- }
- keys.add(key);
- }
- }
-
- private void initWireAdmin() {
- wires = new Vector(10);
-
- log = new LogTracker(context, System.out);
- wireAdminStore = new WireAdminStore(context, this, log,
- preferencesService);
-
- try {
- wireAdminStore.init(preferencesService);
- } catch (Exception ex) {
- log.log(LogService.LOG_ERROR, WireAdminMsg.BACKING_STORE_READ_EXCEPTION,
- ex);
- }
- consumerTracker = new ServiceTracker(context, Consumer.class.getName(),
- new ConsumersCustomizer(context, this));
- consumerTracker.open();
-
- producerTracker = new ServiceTracker(context, Producer.class.getName(),
- new ProducersCustomizer(context, this));
- producerTracker.open();
-
- alive = true;
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/WireAdminEventProducer.java b/bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/WireAdminEventProducer.java
deleted file mode 100644
index a01071bc8..000000000
--- a/bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/WireAdminEventProducer.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.wireadmin;
-
-import java.util.Vector;
-import org.eclipse.osgi.framework.eventmgr.*;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.log.LogService;
-import org.osgi.service.wireadmin.*;
-import org.osgi.service.wireadmin.Wire;
-import org.osgi.util.tracker.ServiceTracker;
-
-/*
- * WireAdminEventProducer is responsible for sending out WireAdminEvents
- * to all WireAdminListeners.
- */
-
-public class WireAdminEventProducer extends ServiceTracker implements EventDispatcher {
-
- protected ServiceReference ref;
- static protected final String wireAdminListenerClass = "org.osgi.service.wireadmin.WireAdminListener"; //$NON-NLS-1$
- protected Vector eventQueue;
- protected LogService log;
- protected BundleContext context;
-
- protected WireAdmin wireAdmin;
-
- /** List of WireAdminListeners */
- protected EventListeners listeners;
- /** EventManager for event delivery. */
- protected EventManager eventManager;
-
- protected WireAdminEventProducer(ServiceReference ref, BundleContext context, LogService log, WireAdmin wireAdmin) {
- super(context, wireAdminListenerClass, null);
- this.ref = ref;
- this.context = context;
- this.log = log;
- this.wireAdmin = wireAdmin;
- eventManager = new EventManager("WireAdmin Event Dispatcher"); //$NON-NLS-1$
- listeners = new EventListeners();
-
- open();
-
- }
-
- public void close() {
- super.close();
- listeners.removeAllListeners();
- eventManager.close();
- wireAdmin = null;
- }
-
- protected void generateEvent(int type, Wire wire, Throwable t) {
- if (wireAdmin != null) {
- WireAdminEvent event = new WireAdminEvent(wireAdmin.reference, type, wire, t);
-
- /* queue to hold set of listeners */
- ListenerQueue queue = new ListenerQueue(eventManager);
-
- /* add set of WireAdminListeners to queue */
- queue.queueListeners(listeners, this);
-
- /* dispatch event to set of listeners */
- queue.dispatchEventAsynchronous(0, event);
- }
- }
-
- /**
- * A service is being added to the <tt>ServiceTracker</tt> object.
- *
- * <p>This method is called before a service which matched
- * the search parameters of the <tt>ServiceTracker</tt> object is
- * added to it. This method should return the
- * service object to be tracked for this <tt>ServiceReference</tt> object.
- * The returned service object is stored in the <tt>ServiceTracker</tt> object
- * and is available from the <tt>getService</tt> and <tt>getServices</tt>
- * methods.
- *
- * @param reference Reference to service being added to the <tt>ServiceTracker</tt> object.
- * @return The service object to be tracked for the
- * <tt>ServiceReference</tt> object or <tt>null</tt> if the <tt>ServiceReference</tt> object should not
- * be tracked.
- */
- public Object addingService(ServiceReference reference) {
-
- Object service = super.addingService(reference);
- setMask(reference, service);
-
- return (service);
- }
-
- /**
- * A service tracked by the <tt>ServiceTracker</tt> object has been removed.
- *
- * <p>This method is called after a service is no longer being tracked
- * by the <tt>ServiceTracker</tt> object.
- *
- * @param reference Reference to service that has been removed.
- * @param service The service object for the removed service.
- */
- public void removedService(ServiceReference reference, Object service) {
- listeners.removeListener(service);
-
- super.removedService(reference, service);
- }
-
- /**
- * This method is the call back that is called once for each listener.
- * This method must cast the EventListener object to the appropriate listener
- * class for the event type and call the appropriate listener method.
- *
- * @param listener This listener must be cast to the appropriate listener
- * class for the events created by this source and the appropriate listener method
- * must then be called.
- * @param listenerObject This is the optional object that was passed to
- * ListenerList.addListener when the listener was added to the ListenerList.
- * @param eventAction This value was passed to the EventQueue object via one of its
- * dispatchEvent* method calls. It can provide information (such
- * as which listener method to call) so that this method
- * can complete the delivery of the event to the listener.
- * @param eventObject This object was passed to the EventQueue object via one of its
- * dispatchEvent* method calls. This object was created by the event source and
- * is passed to this method. It should contain all the necessary information (such
- * as what event object to pass) so that this method
- * can complete the delivery of the event to the listener.
- */
- public void dispatchEvent(Object listener, Object maskObject, int eventAction, Object eventObject) {
- ServiceReference wireAdminRef = wireAdmin.reference;
-
- WireAdminListener wal = (WireAdminListener) listener;
-
- try {
- WireAdminEvent event = (WireAdminEvent) eventObject;
- {
- int mask = ((Integer) maskObject).intValue();
- int type = event.getType();
- if ((type & mask) != type) {
- return;
- }
- }
- wal.wireAdminEvent(event);
-
- } catch (Throwable t) {
- log.log(wireAdminRef, LogService.LOG_WARNING, WireAdminMsg.WIREADMIN_EVENT_DISPATCH_ERROR, t);
- }
-
- }
-
- /**
- * @see org.osgi.util.tracker.ServiceTrackerCustomizer#modifiedService(ServiceReference, Object)
- */
- public void modifiedService(ServiceReference reference, Object service) {
- listeners.removeListener(service);
- setMask(reference, service);
- super.modifiedService(reference, service);
- }
-
- private void setMask(ServiceReference reference, Object service) {
- Integer mask = null;
- try {
- mask = (Integer) reference.getProperty(WireConstants.WIREADMIN_EVENTS);
- } catch (ClassCastException ex) {
- return; //mask was not of type Integer
- }
- listeners.addListener(service, mask);
-
- }
-
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/WireAdminMsg.java b/bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/WireAdminMsg.java
deleted file mode 100644
index 608983018..000000000
--- a/bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/WireAdminMsg.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.wireadmin;
-
-import org.eclipse.osgi.util.NLS;
-
-public class WireAdminMsg extends NLS {
- private static final String BUNDLE_NAME = "org.eclipse.equinox.wireadmin.ExternalMessages"; //$NON-NLS-1$
-
- public static String BACKING_STORE_READ_EXCEPTION;
- public static String WIREADMIN_UNREGISTERED_EXCEPTION;
- public static String WIREADMIN_EVENT_DISPATCH_ERROR;
- public static String WIREADMIN_PROP_KEY_MUST_BE_STRING;
- public static String WIREADMIN_KEYS_CASE_INSENSITIVE_MATCH;
-
- static {
- // initialize resource bundles
- NLS.initializeMessages(BUNDLE_NAME, WireAdminMsg.class);
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/WireAdminStore.java b/bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/WireAdminStore.java
deleted file mode 100644
index eed71a074..000000000
--- a/bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/wireadmin/WireAdminStore.java
+++ /dev/null
@@ -1,242 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2005 IBM Corporation.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.wireadmin;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.security.*;
-import java.util.*;
-import org.osgi.framework.BundleContext;
-import org.osgi.service.log.LogService;
-import org.osgi.service.prefs.*;
-import org.osgi.service.wireadmin.WireConstants;
-
-/*
- * WireAdminStore is responsible for managing the persistence data of the wireadmin
- * service. It uses the PersistenceNode service as its underlying storage.
- */
-
-public class WireAdminStore {
-
- static protected final String persistenceUserName = "WireAdmin"; //$NON-NLS-1$
- static protected final String lastPidString = "lastPid"; //$NON-NLS-1$
- static protected final String defaultLastPid = "1"; //$NON-NLS-1$
-
- protected BundleContext context;
- protected WireAdmin wireadmin;
- protected LogService log;
- protected Preferences rootNode;
- protected PreferencesService preferencesService;
-
- protected WireAdminStore(BundleContext context, WireAdmin wireadmin, LogService log, PreferencesService preferencesService) {
- this.context = context;
- this.wireadmin = wireadmin;
- this.log = log;
- }
-
- protected void init(PreferencesService preferencesService_) throws BackingStoreException {
- this.preferencesService = preferencesService_;
- }
-
- protected void addWire(final Wire wire, final Dictionary properties) throws BackingStoreException {
- try {
- AccessController.doPrivileged(new PrivilegedExceptionAction() {
- public Object run() throws Exception {
- String pid = wire.getPid();
- rootNode.put(lastPidString, pid);
- Preferences node = rootNode.node(pid);
- storeProperties(properties, node);
-
- /* Enumeration enum = properties.keys();
-
- while(enum.hasMoreElements())
- {
- String key = (String)enum.nextElement();
- String value = (String)properties.get(key);
- node.put(key,value);
- }
- */
- rootNode.flush();
- return (null);
- }
- });
- } catch (PrivilegedActionException ex) {
- //log.log(log.LOG_ERROR,Text.BACKING_STORE_WRITE_EXCEPTION,ex);
- throw ((BackingStoreException) ex.getException());
- }
- }
-
- protected void removeWire(final Wire wire) throws BackingStoreException {
- try {
- AccessController.doPrivileged(new PrivilegedExceptionAction() {
- public Object run() throws Exception {
- Preferences node = rootNode.node(wire.getPid());
- node.removeNode();
- rootNode.node("").flush(); //$NON-NLS-1$
- return (null);
- }
- });
- } catch (PrivilegedActionException ex) {
- //log.log(log.LOG_ERROR,Text.BACKING_STORE_WRITE_EXCEPTION,ex);
- throw ((BackingStoreException) ex.getException());
- }
- }
-
- protected void loadWires() throws BackingStoreException {
- synchronized (this) {
- wireadmin.lastPid = Integer.parseInt(rootNode.get(lastPidString, defaultLastPid));
- String[] children = rootNode.node("").childrenNames(); //$NON-NLS-1$
- for (int i = 0; i < children.length; i++) {
- loadWire(rootNode.node(children[i]));
- }
- }
- }
-
- protected void loadWire(Preferences node) throws BackingStoreException {
- String pid = node.name();
- Hashtable properties = loadProperties(node);
- /* String[] keys = node.keys();
- for(int i=0;i<keys.length;i++)
- {
- String value = (String)node.get(keys[i],null);
- properties.put(keys[i],value);
- } */
- String consumerPid = (String) properties.get(WireConstants.WIREADMIN_CONSUMER_PID);
- String producerPid = (String) properties.get(WireConstants.WIREADMIN_PRODUCER_PID);
- wireadmin.createWire(pid, producerPid, consumerPid, properties);
- }
-
- protected void updateWire(final Wire wire, final Dictionary properties) throws BackingStoreException {
- try {
- AccessController.doPrivileged(new PrivilegedExceptionAction() {
- public Object run() throws Exception {
- String pid = wire.getPid();
- Preferences node = rootNode.node(pid);
- node.clear();
- storeProperties(properties, node);
-
- /*Enumeration enum = properties.keys();
- while(enum.hasMoreElements())
- {
- String key = (String)enum.nextElement();
- String value = (String)properties.get(key);
- node.put(key,value);
- }
- */
- node.flush();
- return (null);
- }
- });
- } catch (PrivilegedActionException ex) {
- //log.log(log.LOG_ERROR,Text.BACKING_STORE_WRITE_EXCEPTION,ex);
- throw ((BackingStoreException) ex.getException());
- }
- }
-
- protected void destroy() {
- try {
- rootNode.flush();
- } catch (BackingStoreException ex) {
- //log.log(log.LOG_ERROR,Text.BACKING_STORE_WRITE_EXCEPTION,ex);
- }
- }
-
- protected void storeProperties(Dictionary properties, Preferences node) throws BackingStoreException {
- Enumeration e = properties.keys();
- while (e.hasMoreElements()) {
- String key = (String) e.nextElement();
- Object value = properties.get(key);
- if (value instanceof Vector) {
- storeVector(node.node("Vector/" + key), (Vector) value); //$NON-NLS-1$
- } else {
- Preferences childNode = node.node("basetype/" + value.getClass().getName()); //$NON-NLS-1$
- childNode.put(key, String.valueOf(value));
- }
-
- //node.put(key,value);
- }
- node.flush();
- }
-
- private void storeVector(Preferences node, Vector vector) {
- Enumeration e = vector.elements();
- while (e.hasMoreElements()) {
- Object value = e.nextElement();
- node.put(value.getClass().getName(), String.valueOf(value));
- }
- }
-
- private Hashtable loadProperties(Preferences node) throws BackingStoreException {
- Hashtable props = new Hashtable(15);
- if (node.nodeExists("Vector")) { //$NON-NLS-1$
- loadVectors(node.node("Vector"), props); //$NON-NLS-1$
- }
- if (node.nodeExists("basetype")) { //$NON-NLS-1$
- loadBaseTypes(node.node("basetype"), props); //$NON-NLS-1$
- }
- return props;
- }
-
- private void loadVectors(Preferences node, Hashtable props) throws BackingStoreException {
- String[] children = node.childrenNames();
- for (int j = 0; j < children.length; j++) {
- Preferences vectorNode = node.node(children[j]);
- String keys[] = vectorNode.keys();
- Vector vector = new Vector(keys.length);
- for (int i = 0; i < keys.length; i++) {
- String value = node.get(keys[i], null);
- vector.add(getValue(keys[i], value));
-
- }
- props.put(children[j], vector);
- }
- }
-
- private void loadBaseTypes(Preferences node, Hashtable props) throws BackingStoreException {
- String[] children = node.childrenNames();
- for (int j = 0; j < children.length; j++) {
- Preferences childNode = node.node(children[j]);
- String keys[] = childNode.keys();
- for (int i = 0; i < keys.length; i++) {
- props.put(keys[i], getValue(children[j], childNode.get(keys[i], null)));
- }
- }
- }
-
- private Object getValue(String className, String value) {
- //Float does not have a zero-arguement constructor
- if (className.equals(Float.class.getName())) {
- return Float.valueOf(value);
- } else if (className.equals(Boolean.class.getName())) {
- return Boolean.valueOf(value);
- }
- try {
- Class clazz = Class.forName(className);
- Object object = clazz.newInstance();
- Method method = clazz.getDeclaredMethod("valueOf", new Class[] {Object.class}); //$NON-NLS-1$
- return (method.invoke(object, new Object[] {value}));
-
- } catch (ClassNotFoundException ex) {
- ex.printStackTrace();
- } catch (IllegalAccessException ex1) {
- ex1.printStackTrace();
- } catch (InstantiationException ex2) {
-
- ex2.printStackTrace();
- } catch (NoSuchMethodException ex3) {
- ex3.printStackTrace();
- } catch (InvocationTargetException ex4) {
- ex4.printStackTrace();
- }
- return null;
- }
-
-}

Back to the top