diff options
author | slewis | 2008-02-06 08:30:51 +0000 |
---|---|---|
committer | slewis | 2008-02-06 08:30:51 +0000 |
commit | e4eba24d25ed63f4e9b8a389174ada0ba2e23c70 (patch) | |
tree | 313763936231b5ce5d1827581942bef4168a85ba /server-side | |
parent | a1053a30d1e87832828ceb41254319517fc45ab6 (diff) | |
download | org.eclipse.ecf-e4eba24d25ed63f4e9b8a389174ada0ba2e23c70.tar.gz org.eclipse.ecf-e4eba24d25ed63f4e9b8a389174ada0ba2e23c70.tar.xz org.eclipse.ecf-e4eba24d25ed63f4e9b8a389174ada0ba2e23c70.zip |
Added IRemoteEnvironmentinfo service and removed concat service.
Diffstat (limited to 'server-side')
3 files changed, 123 insertions, 30 deletions
diff --git a/server-side/examples/bundles/org.eclipse.ecf.examples.remoteservices.server/src/org/eclipse/ecf/internal/examples/remoteservices/server/Activator.java b/server-side/examples/bundles/org.eclipse.ecf.examples.remoteservices.server/src/org/eclipse/ecf/internal/examples/remoteservices/server/Activator.java index 5f50bd45f..b2e06eb00 100644 --- a/server-side/examples/bundles/org.eclipse.ecf.examples.remoteservices.server/src/org/eclipse/ecf/internal/examples/remoteservices/server/Activator.java +++ b/server-side/examples/bundles/org.eclipse.ecf.examples.remoteservices.server/src/org/eclipse/ecf/internal/examples/remoteservices/server/Activator.java @@ -13,13 +13,14 @@ import org.eclipse.ecf.discovery.ServiceInfo; import org.eclipse.ecf.discovery.ServiceProperties; import org.eclipse.ecf.discovery.identity.ServiceIDFactory; import org.eclipse.ecf.discovery.service.IDiscoveryService; -import org.eclipse.ecf.examples.remoteservices.common.IConcatService; +import org.eclipse.ecf.examples.remoteservices.common.IRemoteEnvironmentInfo; import org.eclipse.ecf.remoteservice.Constants; import org.eclipse.ecf.remoteservice.IRemoteServiceContainerAdapter; import org.eclipse.ecf.remoteservice.IRemoteServiceListener; import org.eclipse.ecf.remoteservice.events.IRemoteServiceEvent; import org.eclipse.ecf.remoteservice.util.DiscoveryProperties; import org.eclipse.ecf.remoteservice.util.RemoteServiceProperties; +import org.eclipse.osgi.service.environment.EnvironmentInfo; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.osgi.util.tracker.ServiceTracker; @@ -51,12 +52,22 @@ public class Activator implements BundleActivator { private IDiscoveryContainerAdapter discovery; + private ServiceTracker environmentInfoTracker; + /** * The constructor */ public Activator() { } + public EnvironmentInfo getEnvironmentInfo() { + if (environmentInfoTracker == null) { + environmentInfoTracker = new ServiceTracker(context, org.eclipse.osgi.service.environment.EnvironmentInfo.class.getName(), null); + environmentInfoTracker.open(); + } + return (EnvironmentInfo) environmentInfoTracker.getService(); + } + private void registerRemoteService(String className, Object service) { try { final IRemoteServiceContainerAdapter containerAdapter = (IRemoteServiceContainerAdapter) serviceHostContainer.getAdapter(IRemoteServiceContainerAdapter.class); @@ -102,7 +113,7 @@ public class Activator implements BundleActivator { this.context = context; setupDiscovery(); createAndConnectServiceHostContainer(); - registerRemoteService(IConcatService.class.getName(), new ConcatServiceImpl()); + registerRemoteService(IRemoteEnvironmentInfo.class.getName(), new RemoteEnvironmentInfoImpl()); } private void createAndConnectServiceHostContainer() { @@ -149,6 +160,10 @@ public class Activator implements BundleActivator { serviceHostContainer.disconnect(); serviceHostContainer = null; } + if (environmentInfoTracker != null) { + environmentInfoTracker.close(); + environmentInfoTracker = null; + } this.context = null; } diff --git a/server-side/examples/bundles/org.eclipse.ecf.examples.remoteservices.server/src/org/eclipse/ecf/internal/examples/remoteservices/server/ConcatServiceImpl.java b/server-side/examples/bundles/org.eclipse.ecf.examples.remoteservices.server/src/org/eclipse/ecf/internal/examples/remoteservices/server/ConcatServiceImpl.java deleted file mode 100644 index 8175f0503..000000000 --- a/server-side/examples/bundles/org.eclipse.ecf.examples.remoteservices.server/src/org/eclipse/ecf/internal/examples/remoteservices/server/ConcatServiceImpl.java +++ /dev/null @@ -1,28 +0,0 @@ -/**************************************************************************** - * Copyright (c) 2008 Composent, Inc. and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Composent, Inc. - initial API and implementation - *****************************************************************************/ - -package org.eclipse.ecf.internal.examples.remoteservices.server; - -import org.eclipse.ecf.examples.remoteservices.common.IConcatService; - -/** - * - */ -public class ConcatServiceImpl implements IConcatService { - - /* (non-Javadoc) - * @see org.eclipse.ecf.examples.remoteservices.common.IConcatService#concat(java.lang.String, java.lang.String) - */ - public String concat(String first, String second) { - return first.concat(second); - } - -} diff --git a/server-side/examples/bundles/org.eclipse.ecf.examples.remoteservices.server/src/org/eclipse/ecf/internal/examples/remoteservices/server/RemoteEnvironmentInfoImpl.java b/server-side/examples/bundles/org.eclipse.ecf.examples.remoteservices.server/src/org/eclipse/ecf/internal/examples/remoteservices/server/RemoteEnvironmentInfoImpl.java new file mode 100644 index 000000000..ec294ea95 --- /dev/null +++ b/server-side/examples/bundles/org.eclipse.ecf.examples.remoteservices.server/src/org/eclipse/ecf/internal/examples/remoteservices/server/RemoteEnvironmentInfoImpl.java @@ -0,0 +1,106 @@ +/**************************************************************************** + * Copyright (c) 2008 Composent, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Composent, Inc. - initial API and implementation + *****************************************************************************/ + +package org.eclipse.ecf.internal.examples.remoteservices.server; + +import org.eclipse.ecf.examples.remoteservices.common.IRemoteEnvironmentInfo; +import org.eclipse.osgi.service.environment.EnvironmentInfo; + +/** + * + */ +public class RemoteEnvironmentInfoImpl implements IRemoteEnvironmentInfo { + + private EnvironmentInfo getEnvironmentInfo() { + return Activator.getDefault().getEnvironmentInfo(); + } + + /* (non-Javadoc) + * @see org.eclipse.ecf.examples.remoteservices.common.IRemoteEnvironmentInfo#getCommandLineArgs() + */ + public String[] getCommandLineArgs() { + final EnvironmentInfo ei = getEnvironmentInfo(); + return (ei == null) ? null : ei.getCommandLineArgs(); + } + + /* (non-Javadoc) + * @see org.eclipse.ecf.examples.remoteservices.common.IRemoteEnvironmentInfo#getFrameworkArgs() + */ + public String[] getFrameworkArgs() { + final EnvironmentInfo ei = getEnvironmentInfo(); + return (ei == null) ? null : ei.getFrameworkArgs(); + } + + /* (non-Javadoc) + * @see org.eclipse.ecf.examples.remoteservices.common.IRemoteEnvironmentInfo#getNL() + */ + public String getNL() { + final EnvironmentInfo ei = getEnvironmentInfo(); + return (ei == null) ? null : ei.getNL(); + } + + /* (non-Javadoc) + * @see org.eclipse.ecf.examples.remoteservices.common.IRemoteEnvironmentInfo#getNonFrameworkArgs() + */ + public String[] getNonFrameworkArgs() { + final EnvironmentInfo ei = getEnvironmentInfo(); + return (ei == null) ? null : ei.getNonFrameworkArgs(); + } + + /* (non-Javadoc) + * @see org.eclipse.ecf.examples.remoteservices.common.IRemoteEnvironmentInfo#getOS() + */ + public String getOS() { + final EnvironmentInfo ei = getEnvironmentInfo(); + return (ei == null) ? null : ei.getOS(); + } + + /* (non-Javadoc) + * @see org.eclipse.ecf.examples.remoteservices.common.IRemoteEnvironmentInfo#getOSArch() + */ + public String getOSArch() { + final EnvironmentInfo ei = getEnvironmentInfo(); + return (ei == null) ? null : ei.getOSArch(); + } + + /* (non-Javadoc) + * @see org.eclipse.ecf.examples.remoteservices.common.IRemoteEnvironmentInfo#getProperty(java.lang.String) + */ + public String getProperty(String key) { + final EnvironmentInfo ei = getEnvironmentInfo(); + return (ei == null) ? null : ei.getProperty(key); + } + + /* (non-Javadoc) + * @see org.eclipse.ecf.examples.remoteservices.common.IRemoteEnvironmentInfo#getWS() + */ + public String getWS() { + final EnvironmentInfo ei = getEnvironmentInfo(); + return (ei == null) ? null : ei.getWS(); + } + + /* (non-Javadoc) + * @see org.eclipse.ecf.examples.remoteservices.common.IRemoteEnvironmentInfo#inDebugMode() + */ + public Boolean inDebugMode() { + final EnvironmentInfo ei = getEnvironmentInfo(); + return (ei == null) ? null : new Boolean(ei.inDebugMode()); + } + + /* (non-Javadoc) + * @see org.eclipse.ecf.examples.remoteservices.common.IRemoteEnvironmentInfo#inDevelopmentMode() + */ + public Boolean inDevelopmentMode() { + final EnvironmentInfo ei = getEnvironmentInfo(); + return (ei == null) ? null : new Boolean(ei.inDevelopmentMode()); + } + +} |