You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by no...@apache.org on 2011/05/15 17:13:47 UTC
svn commit: r1103425 - in /aries/trunk:
jndi/jndi-core/src/main/java/org/apache/aries/jndi/ util/
util/src/main/java/org/apache/aries/util/service/
util/src/main/java/org/apache/aries/util/service/registry/
Author: not
Date: Sun May 15 15:13:44 2011
New Revision: 1103425
URL: http://svn.apache.org/viewvc?rev=1103425&view=rev
Log:
ARIES-649 Move ServicePair from jndi to util
Added:
aries/trunk/util/src/main/java/org/apache/aries/util/service/
aries/trunk/util/src/main/java/org/apache/aries/util/service/registry/
aries/trunk/util/src/main/java/org/apache/aries/util/service/registry/ServicePair.java
aries/trunk/util/src/main/java/org/apache/aries/util/service/registry/packageinfo
Modified:
aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/ContextHelper.java
aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/ObjectFactoryHelper.java
aries/trunk/util/pom.xml
Modified: aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/ContextHelper.java
URL: http://svn.apache.org/viewvc/aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/ContextHelper.java?rev=1103425&r1=1103424&r2=1103425&view=diff
==============================================================================
--- aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/ContextHelper.java (original)
+++ aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/ContextHelper.java Sun May 15 15:13:44 2011
@@ -32,6 +32,7 @@ import javax.naming.spi.ObjectFactory;
import org.apache.aries.jndi.startup.Activator;
import org.apache.aries.jndi.tracker.ServiceTrackerCustomizers;
import org.apache.aries.jndi.urls.URLObjectFactoryFinder;
+import org.apache.aries.util.service.registry.ServicePair;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
Modified: aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/ObjectFactoryHelper.java
URL: http://svn.apache.org/viewvc/aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/ObjectFactoryHelper.java?rev=1103425&r1=1103424&r2=1103425&view=diff
==============================================================================
--- aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/ObjectFactoryHelper.java (original)
+++ aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/ObjectFactoryHelper.java Sun May 15 15:13:44 2011
@@ -34,6 +34,7 @@ import javax.naming.StringRefAddr;
import javax.naming.spi.ObjectFactory;
import javax.naming.spi.ObjectFactoryBuilder;
+import org.apache.aries.util.service.registry.ServicePair;
import org.osgi.framework.BundleContext;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
Modified: aries/trunk/util/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/util/pom.xml?rev=1103425&r1=1103424&r2=1103425&view=diff
==============================================================================
--- aries/trunk/util/pom.xml (original)
+++ aries/trunk/util/pom.xml Sun May 15 15:13:44 2011
@@ -46,6 +46,7 @@
org.apache.aries.util;
org.apache.aries.util.tracker;
org.apache.aries.util.nls;
+ org.apache.aries.util.service.registry;
</aries.osgi.export.pkg>
<aries.osgi.import.pkg>
!org.apache.aries.util*,
Added: aries/trunk/util/src/main/java/org/apache/aries/util/service/registry/ServicePair.java
URL: http://svn.apache.org/viewvc/aries/trunk/util/src/main/java/org/apache/aries/util/service/registry/ServicePair.java?rev=1103425&view=auto
==============================================================================
--- aries/trunk/util/src/main/java/org/apache/aries/util/service/registry/ServicePair.java (added)
+++ aries/trunk/util/src/main/java/org/apache/aries/util/service/registry/ServicePair.java Sun May 15 15:13:44 2011
@@ -0,0 +1,70 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.util.service.registry;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+
+// TODO need to determine if this needs to be thread safe or not
+public class ServicePair<T>
+{
+ private BundleContext ctx;
+ private ServiceReference ref;
+ private T serviceObject;
+
+ public ServicePair(BundleContext context, ServiceReference serviceRef)
+ {
+ ctx = context;
+ ref = serviceRef;
+ }
+
+ public ServicePair(BundleContext context, ServiceReference serviceRef, T service)
+ {
+ ctx = context;
+ ref = serviceRef;
+ serviceObject = service;
+ }
+
+ @SuppressWarnings("unchecked")
+ public T get()
+ {
+ if (serviceObject == null && ref.getBundle() != null) {
+ serviceObject = (T) ctx.getService(ref);
+ }
+
+ return serviceObject;
+ }
+
+ public boolean isValid() {
+ return (ref.getBundle() != null);
+ }
+
+ public void unget()
+ {
+ if (serviceObject != null) {
+ ctx.ungetService(ref);
+ serviceObject = null;
+ }
+ }
+
+ public ServiceReference getReference()
+ {
+ return ref;
+ }
+}
Added: aries/trunk/util/src/main/java/org/apache/aries/util/service/registry/packageinfo
URL: http://svn.apache.org/viewvc/aries/trunk/util/src/main/java/org/apache/aries/util/service/registry/packageinfo?rev=1103425&view=auto
==============================================================================
--- aries/trunk/util/src/main/java/org/apache/aries/util/service/registry/packageinfo (added)
+++ aries/trunk/util/src/main/java/org/apache/aries/util/service/registry/packageinfo Sun May 15 15:13:44 2011
@@ -0,0 +1,19 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+version 0.3.1