You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2007/09/14 23:40:52 UTC
svn commit: r575799 [10/12] - in /incubator/tuscany/java/sca: itest/
itest/osgi-contribution/ itest/osgi-contribution/contribution-classes-v2/
itest/osgi-contribution/contribution-classes-v2/src/
itest/osgi-contribution/contribution-classes-v2/src/main...
Added: incubator/tuscany/java/sca/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiBundleProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiBundleProcessor.java?rev=575799&view=auto
==============================================================================
--- incubator/tuscany/java/sca/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiBundleProcessor.java (added)
+++ incubator/tuscany/java/sca/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiBundleProcessor.java Fri Sep 14 14:40:35 2007
@@ -0,0 +1,140 @@
+/*
+ * 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.tuscany.sca.contribution.osgi.impl;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.List;
+import java.util.jar.Attributes;
+import java.util.jar.JarInputStream;
+import java.util.jar.Manifest;
+
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.DeployedArtifact;
+import org.apache.tuscany.sca.contribution.osgi.BundleReference;
+import org.apache.tuscany.sca.osgi.runtime.OSGiRuntime;
+
+/**
+ * OSGi bundle processor
+ *
+ */
+public class OSGiBundleProcessor {
+
+ private boolean initializedOSGi;
+ private OSGiRuntime osgiRuntime;
+
+ public OSGiBundleProcessor() {
+ }
+
+ public Object installContributionBundle(Contribution contribution) {
+
+ JarInputStream jar = null;
+ Object bundle = null;
+
+ try {
+
+ URL contribURL = new URL(contribution.getLocation());
+ jar = new JarInputStream(contribURL.openStream());
+
+ Manifest manifest = jar.getManifest();
+ if (manifest != null && manifest.getMainAttributes()
+ .containsKey(new Attributes.Name("Bundle-SymbolicName"))) {
+
+ initialize();
+ if (osgiRuntime != null)
+ bundle = osgiRuntime.installBundle(contribURL.toString(), null);
+ }
+ } catch (Exception e) {
+ // If OSGi cannot process the jar, treat the bundle as a plain jar file.
+ } finally {
+
+ try {
+ if (jar != null)
+ jar.close();
+ } catch (IOException e) {
+ }
+ }
+
+ return bundle;
+ }
+
+ public BundleReference installNestedBundle(Contribution contribution,
+ String bundleSymbolicName,
+ String bundleVersion) {
+
+ BundleReference bundleReference = null;
+
+ initialize();
+ if (osgiRuntime == null)
+ return null;
+
+ List<DeployedArtifact> artifacts = contribution.getArtifacts();
+ for (DeployedArtifact a : artifacts) {
+ if (a.getURI().endsWith(".jar")) {
+
+ InputStream stream;
+ JarInputStream jar = null;
+ Object name;
+ Object version;
+ try {
+
+ URL artifactURL = new URL(a.getLocation());
+ stream = artifactURL.openStream();
+ jar = new JarInputStream(artifactURL.openStream());
+ Manifest manifest = jar.getManifest();
+ name = manifest.getMainAttributes().get(new Attributes.Name("Bundle-SymbolicName"));
+ version = manifest.getMainAttributes().get(new Attributes.Name("Bundle-Version"));
+
+ if (bundleSymbolicName.equals(name) && (bundleVersion == null || version == null || bundleVersion
+ .equals(version))) {
+
+ Object bundle = osgiRuntime.installBundle(a.getLocation(), stream);
+
+ bundleReference = new BundleReference(bundle, bundleSymbolicName, bundleVersion, a.getURI());
+
+ break;
+ }
+
+ } catch (Exception e) {
+
+ // If OSGi cannot process the jar, treat the bundle as a plain jar file.
+ } finally {
+ try {
+ if (jar != null)
+ jar.close();
+ } catch (IOException e) {
+ }
+ }
+ }
+ }
+ return bundleReference;
+ }
+
+ private void initialize() {
+ try {
+ if (!initializedOSGi) {
+ initializedOSGi = true;
+ osgiRuntime = OSGiRuntime.getRuntime();
+ }
+ } catch (Exception e) {
+ }
+ }
+}
Propchange: incubator/tuscany/java/sca/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiBundleProcessor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiBundleProcessor.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiBundleReferenceModelResolver.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiBundleReferenceModelResolver.java?rev=575799&view=auto
==============================================================================
--- incubator/tuscany/java/sca/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiBundleReferenceModelResolver.java (added)
+++ incubator/tuscany/java/sca/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiBundleReferenceModelResolver.java Fri Sep 14 14:40:35 2007
@@ -0,0 +1,152 @@
+/*
+ * 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.tuscany.sca.contribution.osgi.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.Import;
+import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
+import org.apache.tuscany.sca.contribution.osgi.BundleReference;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.osgi.runtime.OSGiRuntime;
+import org.osgi.framework.Bundle;
+
+/**
+ * A Model Resolver for BundleReferences.
+ *
+ * @version $Rev$ $Date$
+ */
+public class OSGiBundleReferenceModelResolver implements ModelResolver {
+ private Contribution contribution;
+ private Map<String, BundleReference> map = new HashMap<String, BundleReference>();
+
+ OSGiRuntime osgiRuntime;
+ private OSGiBundleProcessor bundleProcessor;
+
+ public OSGiBundleReferenceModelResolver(Contribution contribution, ModelFactoryExtensionPoint modelFactories) {
+ this.contribution = contribution;
+ this.bundleProcessor = new OSGiBundleProcessor();
+ }
+
+ public void addModel(Object resolved) {
+ BundleReference bundleRef = (BundleReference)resolved;
+ map.put(bundleRef.getBundleUniqueName(), bundleRef);
+ }
+
+ public Object removeModel(Object resolved) {
+ return map.remove(((BundleReference)resolved).getBundleUniqueName());
+ }
+
+ /**
+ * Handle artifact resolution when the specific class reference is imported from another contribution
+ * @param unresolved
+ * @return
+ */
+ private BundleReference resolveImportedModel(BundleReference unresolved) {
+ BundleReference resolved = unresolved;
+
+ if( this.contribution != null) {
+ for (Import import_ : this.contribution.getImports()) {
+
+ resolved = import_.getModelResolver().resolveModel(BundleReference.class, unresolved);
+ if (resolved != unresolved)
+ break;
+ }
+
+ }
+ return resolved;
+ }
+
+
+ public <T> T resolveModel(Class<T> modelClass, T unresolved) {
+ Object resolved = map.get(unresolved);
+
+ if (resolved != null ){
+ return modelClass.cast(resolved);
+ }
+
+ try {
+ if (osgiRuntime == null)
+ osgiRuntime = OSGiRuntime.getRuntime();
+ } catch (Exception e) {
+ }
+ if (osgiRuntime == null)
+ return unresolved;
+
+ //Load a class on demand
+ Object bundle = null;
+ String bundleName = ((BundleReference)unresolved).getBundleName();
+ String bundleVersion = ((BundleReference)unresolved).getBundleVersion();
+
+ bundle = osgiRuntime.findBundle(bundleName, bundleVersion);
+ BundleReference bundleReference;
+
+ if (bundle == null)
+ bundleReference = bundleProcessor.installNestedBundle(contribution, bundleName, bundleVersion);
+ else {
+ bundleReference = new BundleReference(bundle,
+ ((BundleReference)unresolved).getBundleName(),
+ bundleVersion,
+ getBundleFileName(bundle)
+ );
+ }
+
+
+ if (bundleReference != null) {
+ //if we load the class
+
+ map.put(((BundleReference)unresolved).getBundleUniqueName(), bundleReference);
+
+ // Return the resolved BundleReference
+ return modelClass.cast(bundleReference);
+ } else {
+ //delegate resolution of the class
+ resolved = this.resolveImportedModel((BundleReference)unresolved);
+ return modelClass.cast(resolved);
+ }
+
+
+ }
+
+
+ private String getBundleFileName(Object bundle) {
+ if (bundle instanceof Bundle) {
+ String path = ((Bundle)bundle).getLocation();
+ if (path.startsWith(contribution.getLocation())) {
+ if (path.equals(contribution.getLocation())) {
+ int index = path.lastIndexOf('/');
+ if (index > 0 && index < path.length()-1)
+ path = path.substring(index+1);
+ } else {
+ path = path.substring(contribution.getLocation().length());
+ if (path.startsWith("/"))
+ path = path.substring(1);
+ }
+ } else if (path.lastIndexOf('/') > 0)
+ path = path.substring(path.lastIndexOf('/')+1);
+ return path;
+ }
+ return null;
+
+ }
+
+}
Propchange: incubator/tuscany/java/sca/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiBundleReferenceModelResolver.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiBundleReferenceModelResolver.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiClassReferenceModelResolver.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiClassReferenceModelResolver.java?rev=575799&view=auto
==============================================================================
--- incubator/tuscany/java/sca/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiClassReferenceModelResolver.java (added)
+++ incubator/tuscany/java/sca/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiClassReferenceModelResolver.java Fri Sep 14 14:40:35 2007
@@ -0,0 +1,136 @@
+/*
+ * 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.tuscany.sca.contribution.osgi.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.Import;
+import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
+import org.apache.tuscany.sca.contribution.resolver.ClassReference;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.osgi.runtime.OSGiRuntime;
+import org.osgi.framework.Bundle;
+
+/**
+ * A Model Resolver for ClassReferences.
+ *
+ * @version $Rev$ $Date$
+ */
+public class OSGiClassReferenceModelResolver implements ModelResolver {
+ private Contribution contribution;
+ private Map<String, ClassReference> map = new HashMap<String, ClassReference>();
+ private Bundle bundle;
+ private boolean initialized;
+
+
+ public OSGiClassReferenceModelResolver(Contribution contribution, ModelFactoryExtensionPoint modelFactories) {
+ this.contribution = contribution;
+ }
+
+ public void addModel(Object resolved) {
+ ClassReference clazz = (ClassReference)resolved;
+ map.put(clazz.getClassName(), clazz);
+ }
+
+ public Object removeModel(Object resolved) {
+ return map.remove(((ClassReference)resolved).getClassName());
+ }
+
+ /**
+ * Handle artifact resolution when the specific class reference is imported from another contribution
+ * @param unresolved
+ * @return
+ */
+ private ClassReference resolveImportedModel(ClassReference unresolved) {
+ ClassReference resolved = unresolved;
+
+ if( this.contribution != null) {
+ for (Import import_ : this.contribution.getImports()) {
+
+ if (resolved == unresolved && bundle != null) {
+ resolved = import_.getModelResolver().resolveModel(ClassReference.class, unresolved);
+ if (resolved != unresolved)
+ break;
+ }
+ }
+
+ }
+ return resolved;
+ }
+
+
+ public <T> T resolveModel(Class<T> modelClass, T unresolved) {
+ Object resolved = map.get(unresolved);
+
+ if (resolved != null ){
+ return modelClass.cast(resolved);
+ }
+ initialize();
+
+ //Load a class on demand
+ Class clazz = null;
+ if (bundle != null) {
+ try {
+ clazz = bundle.loadClass(((ClassReference)unresolved).getClassName());
+ } catch (Exception e) {
+ // we will later try to delegate to imported model resolvers
+ }
+ }
+
+
+ if (clazz != null) {
+ //if we load the class
+ // Store a new ClassReference wrappering the loaded class
+ ClassReference classReference = new ClassReference(clazz);
+ map.put(getPackageName(classReference), classReference);
+
+ // Return the resolved ClassReference
+ return modelClass.cast(classReference);
+ } else {
+ //delegate resolution of the class
+ resolved = this.resolveImportedModel((ClassReference)unresolved);
+ return modelClass.cast(resolved);
+ }
+
+
+ }
+
+ /***************
+ * Helper methods
+ ***************/
+
+ private String getPackageName(ClassReference clazz) {
+ int pos = clazz.getClassName().lastIndexOf(".");
+ return clazz.getClassName().substring(0, pos - 1 );
+ }
+
+ private void initialize() {
+ if (initialized)
+ return;
+
+ initialized = true;
+ try {
+ bundle = OSGiRuntime.getRuntime().findBundle(contribution.getLocation());
+ } catch (Exception e) {
+ }
+ }
+}
Propchange: incubator/tuscany/java/sca/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiClassReferenceModelResolver.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiClassReferenceModelResolver.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiImportExportListener.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiImportExportListener.java?rev=575799&view=auto
==============================================================================
--- incubator/tuscany/java/sca/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiImportExportListener.java (added)
+++ incubator/tuscany/java/sca/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiImportExportListener.java Fri Sep 14 14:40:35 2007
@@ -0,0 +1,203 @@
+/*
+ * 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.tuscany.sca.contribution.osgi.impl;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.HashSet;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+import java.util.zip.ZipEntry;
+
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.Export;
+import org.apache.tuscany.sca.contribution.Import;
+import org.apache.tuscany.sca.contribution.java.JavaExport;
+import org.apache.tuscany.sca.contribution.java.JavaImport;
+import org.apache.tuscany.sca.contribution.service.ContributionListener;
+import org.apache.tuscany.sca.contribution.service.ContributionRepository;
+import org.apache.tuscany.sca.osgi.runtime.OSGiRuntime;
+
+/**
+ * Namespace Import/Export contribution listener
+ * The listener would process all import/export from a given contribution
+ * and initialize the model resolvers properly
+ *
+ * @version $Rev$ $Date$
+ */
+public class OSGiImportExportListener implements ContributionListener {
+
+ private OSGiBundleProcessor bundleProcessor;
+
+ public OSGiImportExportListener() {
+ bundleProcessor = new OSGiBundleProcessor();
+ }
+
+ /**
+ * Initialize the import/export model resolvers
+ * Export model resolvers are same as Contribution model resolver
+ * Import model resolvers are matched to a specific contribution if a location uri is specified,
+ * otherwise it try to resolve agains all the other contributions
+ */
+ public void contributionAdded(ContributionRepository repository, Contribution contribution) {
+
+ OSGiRuntime osgiRuntime;
+
+ try {
+ osgiRuntime = OSGiRuntime.getRuntime();
+
+ if (bundleProcessor.installContributionBundle(contribution) == null)
+ return;
+ } catch (Exception e) {
+ return;
+ }
+
+
+ HashSet<Contribution> bundlesToInstall = new HashSet<Contribution>();
+ // Initialize the contribution imports
+ for (Import import_: contribution.getImports()) {
+ boolean initialized = false;
+
+
+ if(import_ instanceof JavaImport) {
+ JavaImport javaImport = (JavaImport) import_;
+ String packageName = javaImport.getPackage();
+
+ //Find a matching contribution
+ if(javaImport.getLocation() != null) {
+ Contribution targetContribution = repository.getContribution(javaImport.getLocation());
+ if (targetContribution != null) {
+
+ // Find a matching contribution export
+ for (Export export: targetContribution.getExports()) {
+ if (export instanceof JavaExport) {
+ JavaExport javaExport = (JavaExport)export;
+ if (packageName.equals(javaExport.getPackage())) {
+
+ if (osgiRuntime.findBundle(targetContribution.getLocation()) == null)
+ bundlesToInstall.add(targetContribution);
+
+ initialized = true;
+
+ }
+ }
+ if (initialized)
+ break;
+ }
+ }
+ }
+ }
+ if (!initialized) {
+ for (Contribution c : repository.getContributions()) {
+
+ // Go over all exports in the contribution
+ for (Export export : c.getExports()) {
+ // If the export matches our namespace, try to the resolve the model object
+ if (import_.match(export) && osgiRuntime.findBundle(c.getLocation()) == null) {
+ bundlesToInstall.add(c);
+ }
+ }
+ }
+ }
+ }
+ for (Contribution c : bundlesToInstall) {
+ try {
+ installDummyBundle(osgiRuntime, c);
+ } catch (Exception e) {
+ }
+ }
+
+ }
+
+ public void contributionRemoved(ContributionRepository repository, Contribution contribution) {
+
+ }
+
+ public void contributionUpdated(ContributionRepository repository, Contribution oldContribution, Contribution contribution) {
+
+ }
+
+ private void installDummyBundle(OSGiRuntime osgiRuntime, Contribution contribution) throws Exception {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+
+ String EOL = System.getProperty("line.separator");
+
+ String bundleName = contribution.getURI();
+ String uri = contribution.getURI();
+
+ StringBuffer exportPackageNames = new StringBuffer();
+ for (Export export : contribution.getExports()) {
+ if (export instanceof JavaExport) {
+ if (exportPackageNames.length() > 0) exportPackageNames.append(",");
+ exportPackageNames.append(((JavaExport)export).getPackage());
+ }
+ }
+ StringBuffer importPackageNames = new StringBuffer();
+ for (Import import_ : contribution.getImports()) {
+ if (import_ instanceof JavaImport) {
+ if (importPackageNames.length() > 0) importPackageNames.append(",");
+ importPackageNames.append(((JavaImport)import_).getPackage());
+ }
+ }
+
+ String manifestStr = "Manifest-Version: 1.0" + EOL
+ + "Bundle-ManifestVersion: 2" + EOL + "Bundle-Name: "
+ + bundleName + EOL + "Bundle-SymbolicName: " + bundleName + EOL
+ + "Bundle-Version: " + "1.0.0" + EOL
+ + "Bundle-Localization: plugin" + EOL;
+
+
+ StringBuilder manifestBuf = new StringBuilder();
+ manifestBuf.append(manifestStr);
+ manifestBuf.append("Export-Package: " + exportPackageNames + EOL);
+ manifestBuf.append("Import-Package: " + importPackageNames + EOL);
+ manifestBuf.append("Bundle-ClassPath: .," + uri + EOL);
+
+
+ ByteArrayInputStream manifestStream = new ByteArrayInputStream(
+ manifestBuf.toString().getBytes());
+ Manifest manifest = new Manifest();
+ manifest.read(manifestStream);
+
+ JarOutputStream jarOut = new JarOutputStream(out, manifest);
+
+ ZipEntry ze = new ZipEntry(uri);
+ jarOut.putNextEntry(ze);
+ URL url = new URL(contribution.getLocation());
+ InputStream stream = url.openStream();
+
+ byte[] bytes = new byte[stream.available()];
+ stream.read(bytes);
+ jarOut.write(bytes);
+ stream.close();
+
+ jarOut.close();
+ out.close();
+
+
+ ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
+
+ osgiRuntime.installBundle("file://" + bundleName + ".jar", in);
+
+ }
+
+}
Propchange: incubator/tuscany/java/sca/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiImportExportListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiImportExportListener.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiModelResolverImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiModelResolverImpl.java?rev=575799&view=auto
==============================================================================
--- incubator/tuscany/java/sca/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiModelResolverImpl.java (added)
+++ incubator/tuscany/java/sca/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiModelResolverImpl.java Fri Sep 14 14:40:35 2007
@@ -0,0 +1,118 @@
+/*
+ * 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.tuscany.sca.contribution.osgi.impl;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Map;
+
+import org.apache.tuscany.sca.contribution.osgi.BundleReference;
+import org.apache.tuscany.sca.contribution.resolver.ClassReference;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.osgi.framework.Bundle;
+
+/**
+ * An implementation of an artifact resolver for OSGi bundles.
+ *
+ */
+public class OSGiModelResolverImpl implements ModelResolver {
+ private static final long serialVersionUID = -7826976465762296634L;
+
+ private Map<Object, Object> map = new HashMap<Object, Object>();
+
+ private Hashtable<String, Bundle> bundles;
+ public OSGiModelResolverImpl(Hashtable<String, Bundle> bundles) {
+ this.bundles = bundles;
+ }
+
+
+ public <T> T resolveModel(Class<T> modelClass, T unresolved) {
+ Object resolved = map.get(unresolved);
+ if (resolved != null) {
+
+ // Return the resolved object
+ return modelClass.cast(resolved);
+
+ } else if (unresolved instanceof ClassReference) {
+
+ // Load a class on demand
+ ClassReference classReference = (ClassReference)unresolved;
+ Class clazz = null;
+ for (Bundle bundle : bundles.values()) {
+ try {
+ clazz = bundle.loadClass(classReference.getClassName());
+ } catch (ClassNotFoundException e) {
+ continue;
+ }
+ break;
+ }
+ if (clazz == null) {
+
+ // Return the unresolved object
+ return unresolved;
+ }
+
+ // Store a new ClassReference wrappering the loaded class
+ resolved = new ClassReference(clazz);
+ map.put(resolved, resolved);
+
+ // Return the resolved ClassReference
+ return modelClass.cast(resolved);
+
+ } else if (unresolved instanceof BundleReference) {
+ for (String bundlePath: bundles.keySet()) {
+ Bundle bundle = bundles.get(bundlePath);
+ BundleReference bundleRef = (BundleReference)unresolved;
+ String bundleVersion = (String)bundle.getHeaders().get("Bundle-Version");
+ if (bundle.getSymbolicName().equals(bundleRef.getBundleName())&&
+ (bundleVersion == null || bundleRef.getBundleVersion() == null ||
+ bundleVersion.equals(bundleRef.getBundleVersion()))) {
+
+ resolved = new BundleReference(bundle,
+ bundle.getSymbolicName(),
+ bundleVersion,
+ bundlePath);
+ map.put(resolved, resolved);
+
+ // Return the resolved BundleReference
+ return modelClass.cast(resolved);
+
+ }
+ }
+ }
+
+ // Return the unresolved object
+ return unresolved;
+ }
+
+ public void addModel(Object resolved) {
+ map.put(resolved, resolved);
+ }
+
+ public Object removeModel(Object resolved) {
+ return map.remove(resolved);
+ }
+
+ public Collection<Object> getModels() {
+ return map.values();
+ }
+
+}
Propchange: incubator/tuscany/java/sca/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiModelResolverImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiModelResolverImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/contribution-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/contribution-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver?rev=575799&view=auto
==============================================================================
--- incubator/tuscany/java/sca/modules/contribution-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver (added)
+++ incubator/tuscany/java/sca/modules/contribution-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver Fri Sep 14 14:40:35 2007
@@ -0,0 +1,18 @@
+# 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.
+
+org.apache.tuscany.sca.contribution.osgi.impl.OSGiBundleReferenceModelResolver;model=org.apache.tuscany.sca.contribution.osgi.BundleReference
Added: incubator/tuscany/java/sca/modules/contribution-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.service.ContributionListener
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/contribution-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.service.ContributionListener?rev=575799&view=auto
==============================================================================
--- incubator/tuscany/java/sca/modules/contribution-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.service.ContributionListener (added)
+++ incubator/tuscany/java/sca/modules/contribution-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.service.ContributionListener Fri Sep 14 14:40:35 2007
@@ -0,0 +1,18 @@
+# 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.
+
+org.apache.tuscany.sca.contribution.osgi.impl.OSGiImportExportListener
Modified: incubator/tuscany/java/sca/modules/implementation-osgi/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-osgi/pom.xml?rev=575799&r1=575798&r2=575799&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-osgi/pom.xml (original)
+++ incubator/tuscany/java/sca/modules/implementation-osgi/pom.xml Fri Sep 14 14:40:35 2007
@@ -77,6 +77,24 @@
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java</artifactId>
+ <version>1.1-incubating-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>1.1-incubating-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-xml</artifactId>
+ <version>1.1-incubating-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-assembly-xml</artifactId>
<version>1.1-incubating-SNAPSHOT</version>
</dependency>
@@ -88,9 +106,21 @@
</dependency>
<dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution-osgi</artifactId>
+ <version>1.1-incubating-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-osgi-runtime</artifactId>
+ <version>1.1-incubating-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>3.8.1</version>
+ <version>4.2</version>
<scope>test</scope>
</dependency>
Modified: incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementationInterface.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementationInterface.java?rev=575799&r1=575798&r2=575799&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementationInterface.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementationInterface.java Fri Sep 14 14:40:35 2007
@@ -23,7 +23,6 @@
import org.apache.tuscany.sca.assembly.ComponentProperty;
import org.apache.tuscany.sca.assembly.Extensible;
import org.apache.tuscany.sca.assembly.Implementation;
-import org.apache.tuscany.sca.core.scope.Scope;
/**
*
@@ -32,13 +31,11 @@
*/
public interface OSGiImplementationInterface extends Implementation, Extensible {
- public String getBundleName();
+ public String getBundleSymbolicName();
- public String getBundleLocation();
+ public String getBundleVersion();
public String[] getImports();
-
- public Scope getScope();
public List<ComponentProperty> getReferenceProperties(String referenceName);
Modified: incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiImplementationProvider.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiImplementationProvider.java?rev=575799&r1=575798&r2=575799&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiImplementationProvider.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiImplementationProvider.java Fri Sep 14 14:40:35 2007
@@ -18,14 +18,10 @@
*/
package org.apache.tuscany.sca.implementation.osgi.invocation;
-
-import java.beans.Introspector;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
-import java.lang.reflect.Field;
import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Dictionary;
import java.util.HashSet;
@@ -44,21 +40,29 @@
import org.apache.tuscany.sca.assembly.Property;
import org.apache.tuscany.sca.assembly.Reference;
import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.context.RequestContextFactory;
import org.apache.tuscany.sca.core.context.InstanceWrapper;
import org.apache.tuscany.sca.core.factory.ObjectCreationException;
import org.apache.tuscany.sca.core.factory.ObjectFactory;
import org.apache.tuscany.sca.core.invocation.JDKProxyFactory;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
import org.apache.tuscany.sca.core.scope.Scope;
+import org.apache.tuscany.sca.core.scope.ScopeContainer;
+import org.apache.tuscany.sca.core.scope.ScopeRegistry;
import org.apache.tuscany.sca.core.scope.ScopedImplementationProvider;
+import org.apache.tuscany.sca.core.scope.ScopedRuntimeComponent;
import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
+import org.apache.tuscany.sca.databinding.impl.SimpleTypeMapperImpl;
+import org.apache.tuscany.sca.osgi.runtime.OSGiRuntime;
import org.apache.tuscany.sca.runtime.EndpointReference;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
import org.apache.tuscany.sca.runtime.RuntimeComponentService;
import org.apache.tuscany.sca.runtime.RuntimeWire;
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+import org.apache.tuscany.sca.implementation.java.injection.JavaPropertyValueObjectFactory;
import org.apache.tuscany.sca.implementation.osgi.OSGiImplementationInterface;
-import org.apache.tuscany.sca.implementation.osgi.context.OSGiPropertyValueObjectFactory;
-import org.apache.tuscany.sca.implementation.osgi.runtime.OSGiRuntime;
+import org.apache.tuscany.sca.implementation.osgi.context.OSGiAnnotations;
import org.apache.tuscany.sca.implementation.osgi.xml.OSGiImplementation;
import org.apache.tuscany.sca.interfacedef.Interface;
import org.apache.tuscany.sca.interfacedef.Operation;
@@ -66,7 +70,9 @@
import org.apache.tuscany.sca.invocation.Invoker;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleEvent;
import org.osgi.framework.BundleException;
+import org.osgi.framework.BundleListener;
import org.osgi.framework.Constants;
import org.osgi.framework.FrameworkEvent;
import org.osgi.framework.FrameworkListener;
@@ -80,11 +86,14 @@
* The runtime instantiation of OSGi component implementations
*
*/
-public class OSGiImplementationProvider implements ScopedImplementationProvider, FrameworkListener {
+public class OSGiImplementationProvider implements ScopedImplementationProvider,
+ FrameworkListener,
+ BundleListener {
private static final String COMPONENT_SERVICE_NAME = "component.service.name";
private OSGiImplementation implementation;
+ private OSGiAnnotations osgiAnnotations;
private BundleContext bundleContext;
private Hashtable<RuntimeWire, Reference> referenceWires = new Hashtable<RuntimeWire,Reference>();
@@ -92,7 +101,12 @@
= new Hashtable<RuntimeWire,ComponentReference>();
private HashSet<RuntimeWire> resolvedWires = new HashSet<RuntimeWire>();
private boolean wiresResolved;
- private OSGiPropertyValueObjectFactory propertyValueFactory = new OSGiPropertyValueObjectFactory();
+
+ private boolean bundleStarted;
+
+ private boolean processedResolvedBundle, processingResolvedBundle;
+
+ private JavaPropertyValueObjectFactory propertyValueFactory;
private Hashtable<String, Object> componentProperties = new Hashtable<String, Object>();
@@ -105,7 +119,7 @@
private OSGiRuntime osgiRuntime;
-
+ private ScopeRegistry scopeRegistry;
private DataBindingExtensionPoint dataBindingRegistry;
private boolean packagesRefreshed;
@@ -113,15 +127,25 @@
public OSGiImplementationProvider(RuntimeComponent definition,
OSGiImplementationInterface impl,
- DataBindingExtensionPoint dataBindingRegistry) throws BundleException {
+ DataBindingExtensionPoint dataBindingRegistry,
+ JavaPropertyValueObjectFactory propertyValueFactory,
+ ProxyFactory proxyFactory,
+ ScopeRegistry scopeRegistry,
+ RequestContextFactory requestContextFactory) throws BundleException {
this.implementation = (OSGiImplementation)impl;
this.runtimeComponent = definition;
this.dataBindingRegistry = dataBindingRegistry;
-
+ this.propertyValueFactory = propertyValueFactory;
+ this.scopeRegistry = scopeRegistry;
+
+
bundleContext = getBundleContext();
- osgiBundle = installBundle();
+ osgiBundle = (Bundle)implementation.getOSGiBundle();
+ bundleContext.addBundleListener(this);
+ osgiServiceListener = new OSGiServiceListener(osgiBundle);
+ bundleContext.addServiceListener(osgiServiceListener);
// Install and start all dependent bundles
String[] imports = implementation.getImports();
@@ -133,6 +157,17 @@
}
}
+
+ this.osgiAnnotations = new OSGiAnnotations(
+ implementation.getModelFactories(),
+ implementation.getClassList(),
+ runtimeComponent,
+ propertyValueFactory,
+ proxyFactory,
+ requestContextFactory,
+ osgiBundle,
+ dependentBundles);
+
// PackageAdmin is used to resolve bundles
org.osgi.framework.ServiceReference packageAdminReference =
@@ -162,8 +197,9 @@
for (Object p : props) {
Property prop = (Property)p;
- ObjectFactory<?> objFactory = propertyValueFactory.createValueFactory(prop, prop.getValue());
- Object value = objFactory.getInstance();
+ Class javaType = SimpleTypeMapperImpl.getJavaType(prop.getXSDType());
+ ObjectFactory<?> objFactory = propertyValueFactory.createValueFactory(prop, prop.getValue(), javaType);
+ Object value = objFactory.getInstance();
propsTable.put(prop.getName(), value);
}
@@ -173,50 +209,21 @@
private BundleContext getBundleContext() throws BundleException {
- if (bundleContext == null) {
- osgiRuntime = OSGiRuntime.getRuntime();
- bundleContext = osgiRuntime .getBundleContext();
+ try {
+ if (bundleContext == null) {
+ osgiRuntime = OSGiRuntime.getRuntime();
+ bundleContext = osgiRuntime .getBundleContext();
+ }
+ } catch (BundleException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new BundleException("Could not start OSGi runtime", e);
}
- return bundleContext;
- }
-
- private Bundle getBundle() throws Exception {
- Bundle[] bundles = bundleContext.getBundles();
- for (Bundle b : bundles) {
- if (b.getLocation().equals(implementation.getBundleName())) {
- return b;
- }
- }
- return null;
+ return bundleContext;
}
-
- // Install the bundle corresponding to this component.
- private Bundle installBundle() throws ObjectCreationException {
- try {
-
- Bundle bundle = null;
-
- if ((bundle = getBundle()) == null) {
-
- String bundleName = implementation.getBundleLocation();
-
- bundle = bundleContext.installBundle(bundleName);
-
- }
-
- osgiServiceListener = new OSGiServiceListener(bundle);
-
- bundleContext.addServiceListener(osgiServiceListener);
-
- return bundle;
-
- } catch (Exception e) {
- throw new ObjectCreationException(e);
- }
- }
private String getOSGiFilter(Hashtable<String, Object> props) {
@@ -318,13 +325,18 @@
protected Bundle startBundle() throws ObjectCreationException {
try {
-
- if (osgiBundle.getState() != Bundle.ACTIVE && osgiBundle.getState() != Bundle.STARTING) {
-
+
+ if (!bundleStarted) {
+
+ bundleStarted = true;
+
configurePropertiesUsingConfigAdmin();
-
+
resolveBundle();
+ processAnnotations();
+
+
for (Bundle bundle : dependentBundles) {
try {
if (bundle.getState() != Bundle.ACTIVE && bundle.getState() != Bundle.STARTING) {
@@ -335,8 +347,11 @@
throw e;
}
}
-
- if (osgiBundle.getState() != Bundle.ACTIVE && osgiBundle.getState() != Bundle.STARTING) {
+
+ }
+
+ if (osgiBundle.getState() != Bundle.ACTIVE && osgiBundle.getState() != Bundle.STARTING) {
+
int retry = 0;
@@ -353,8 +368,7 @@
throw e;
}
}
- }
- }
+ }
} catch (Exception e) {
throw new ObjectCreationException(e);
@@ -363,11 +377,17 @@
}
+ // This method is called by OSGiInstanceWrapper.getInstance to obtain the OSGI service reference
+ // corresponding to the specified service. The properties used to filter the service should
+ // be chosen based on whether this is a normal service or a callback.
protected org.osgi.framework.ServiceReference getOSGiServiceReference(ComponentService service)
throws ObjectCreationException {
Hashtable<String, Object> props = new Hashtable<String, Object>();
- processProperties(implementation.getServiceProperties(service.getName()), props);
+ if (!service.isCallback())
+ processProperties(implementation.getServiceProperties(service.getName()), props);
+ else
+ processProperties(implementation.getServiceCallbackProperties(service.getName()), props);
String filter = getOSGiFilter(props);
Interface serviceInterface = service.getInterfaceContract().getInterface();
@@ -643,7 +663,7 @@
public InstanceWrapper<?> createInstanceWrapper() throws ObjectCreationException {
- return new OSGiInstanceWrapper<Object>(this, bundleContext);
+ return new OSGiInstanceWrapper<Object>(this, osgiAnnotations, bundleContext);
}
@@ -689,7 +709,12 @@
private boolean resolveWireResolveReferences(Bundle bundle, Class interfaceClass, RuntimeWire wire,
boolean isOSGiToOSGiWire) throws Exception {
- boolean createProxy = false;
+
+ // FIXME: At the moment injection of values into instances require an instance to be obtained
+ // throught the instance wrapper, and hence requires a proxy. When we do this processing here,
+ // we dont yet know whether the target requires any property or callback injection. So it is
+ // safer to create a proxy all the time.
+ boolean createProxy = true;
ComponentReference scaRef = componentReferenceWires.get(wire);
Hashtable<String, Object> targetProperties = new Hashtable<String, Object>();
@@ -810,6 +835,11 @@
if (!wiresResolved) {
wiresResolved = true;
+
+ if (!setReferencesAndProperties()) {
+ wiresResolved = false;
+ return;
+ }
int refPlusServices = referenceWires.size() + runtimeComponent.getServices().size();
boolean[] createProxyService = new boolean[refPlusServices];
@@ -892,7 +922,7 @@
}
-
+ @SuppressWarnings("unchecked")
private void configurePropertiesUsingConfigAdmin() {
try {
@@ -925,7 +955,8 @@
if (serviceProps != null) {
for (ComponentProperty prop : serviceProps) {
if (prop.getName().equals("service.pid")) {
- ObjectFactory objFactory = propertyValueFactory.createValueFactory(prop, prop.getValue());
+ ObjectFactory objFactory = propertyValueFactory.createValueFactory(prop,
+ prop.getValue(), String.class);
pid = (String)objFactory.getInstance();
}
}
@@ -958,152 +989,32 @@
}
- protected void injectProperties(Object instance) {
-
- if (!implementation.needsPropertyInjection())
- return;
-
- Class implClass = instance.getClass();
- List<ComponentProperty> compProps = runtimeComponent.getProperties();
-
- for (ComponentProperty prop : compProps) {
-
- boolean hasSetProp = false;
- String propName = prop.getName();
- ObjectFactory objFactory = propertyValueFactory.createValueFactory(prop, prop.getValue());
-
- try {
- Field field = implClass.getDeclaredField(propName);
- org.osoa.sca.annotations.Property propAnn;
-
- if ((propAnn = field.getAnnotation(org.osoa.sca.annotations.Property.class)) != null
- || Modifier.isPublic(field.getModifiers())) {
-
- try {
- if (!field.isAccessible())
- field.setAccessible(true);
-
- field.set(instance, objFactory.getInstance());
- hasSetProp = true;
- } catch (IllegalAccessException e) {
- if (propAnn.required())
- throw new RuntimeException(e);
- }
-
- }
- } catch (NoSuchFieldException e) {
- // Ignore exception
- }
-
- if (!hasSetProp) {
- Method[] methods = implClass.getDeclaredMethods();
- org.osoa.sca.annotations.Property propAnn = null;
-
- for (Method method : methods) {
-
- if (!method.getName().startsWith("set"))
- continue;
- if ((propAnn = method.getAnnotation(org.osoa.sca.annotations.Property.class)) != null
- || Modifier.isPublic(method.getModifiers())) {
-
- String methodPropName = Introspector.decapitalize(method.getName().substring(3));
- if (!propName.equals(methodPropName))
- continue;
- }
- try {
- if (!method.isAccessible())
- method.setAccessible(true);
-
- method.invoke(instance, objFactory.getInstance());
- hasSetProp = true;
- } catch (Exception e) {
- if (propAnn != null && propAnn.required())
- throw new RuntimeException(e);
- }
- }
- }
-
- }
-
- }
- protected void injectPropertiesWithoutAnnotations(Object instance) {
-
- if (!implementation.needsPropertyInjection())
- return;
-
- Class implClass = instance.getClass();
- List<ComponentProperty> compProps = runtimeComponent.getProperties();
-
- for (ComponentProperty prop : compProps) {
-
- boolean hasSetProp = false;
- String propName = prop.getName();
- ObjectFactory objFactory = propertyValueFactory.createValueFactory(prop, prop.getValue());
-
- try {
- Field field = implClass.getDeclaredField(propName);
-
- if (Modifier.isPublic(field.getModifiers())) {
-
- try {
- field.set(instance, objFactory.getInstance());
- hasSetProp = true;
-
- } catch (Exception e) {
- // Ignore
- }
- }
- } catch (NoSuchFieldException e) {
- // Ignore exception
- }
-
- if (!hasSetProp) {
- Method[] methods = implClass.getDeclaredMethods();
- for (Method method : methods) {
-
- if (!method.getName().startsWith("set"))
- continue;
- if (Modifier.isPublic(method.getModifiers())) {
-
- String methodPropName = Introspector.decapitalize(method.getName().substring(3));
- if (!propName.equals(methodPropName))
- continue;
- }
- try {
- method.invoke(instance, objFactory.getInstance());
- } catch (Exception e) {
- // Ignore
- }
- }
- }
-
- }
-
- }
-
-
public boolean isOptimizable() {
return false;
}
public Scope getScope() {
- return implementation.getScope();
+ return osgiAnnotations.getScope();
}
public boolean isEagerInit() {
- return implementation.isEagerInit();
+ return osgiAnnotations.isEagerInit();
}
public long getMaxAge() {
- return implementation.getMaxAge();
+ return osgiAnnotations.getMaxAge();
}
public long getMaxIdleTime() {
- return implementation.getMaxIdleTime();
+ return osgiAnnotations.getMaxIdleTime();
}
+ protected ScopeContainer<?> getScopeContainer() {
+ startBundle();
+ return ((ScopedRuntimeComponent)runtimeComponent).getScopeContainer();
+ }
public Invoker createTargetInvoker(RuntimeComponentService service, Operation operation) {
@@ -1112,9 +1023,9 @@
boolean isRemotable = serviceInterface.isRemotable();
- Invoker invoker = new OSGiTargetInvoker(operation, runtimeComponent, service);
+ Invoker invoker = new OSGiTargetInvoker(operation, this, service);
if (isRemotable) {
- return new OSGiRemotableInvoker(implementation, dataBindingRegistry, operation, runtimeComponent, service);
+ return new OSGiRemotableInvoker(osgiAnnotations, dataBindingRegistry, operation, this, service);
} else {
return invoker;
}
@@ -1131,14 +1042,16 @@
return createTargetInvoker(service, operation);
}
- public void start() {
-
+ private boolean setReferencesAndProperties() {
+
for (Reference ref: implementation.getReferences()) {
List<RuntimeWire> wireList = null;
ComponentReference compRef = null;
for (ComponentReference cRef : runtimeComponent.getReferences()) {
if (cRef.getName().equals(ref.getName())) {
+
wireList = ((RuntimeComponentReference)cRef).getRuntimeWires();
+
compRef = cRef;
break;
}
@@ -1166,12 +1079,71 @@
processProperties(runtimeComponent.getProperties(), componentProperties);
+ return true;
+
}
+ public void start() {
+ setReferencesAndProperties();
+ }
+
+ public void processAnnotations() throws IntrospectionException {
+
+ synchronized (this) {
+ if (processedResolvedBundle || processingResolvedBundle)
+ return;
+ processingResolvedBundle = true;
+ }
+
+ osgiAnnotations.processAnnotations();
+
+ Scope scope = osgiAnnotations.getScope();
+ if (scope.equals(Scope.SYSTEM) || scope.equals(Scope.COMPOSITE)) {
+ // Nothing
+ } else {
+
+ if (runtimeComponent instanceof ScopedRuntimeComponent) {
+
+ ScopedRuntimeComponent component = (ScopedRuntimeComponent) runtimeComponent;
+
+ ScopeContainer oldScopeContainer = component.getScopeContainer();
+ component.setScopeContainer(null);
+ ScopeContainer scopeContainer = scopeRegistry.getScopeContainer(runtimeComponent);
+
+ if (oldScopeContainer.getLifecycleState() == ScopeContainer.RUNNING)
+ scopeContainer.start();
+
+ component.setScopeContainer(scopeContainer);
+ }
+
+ // Check for conversational contract if conversational scope
+// if (scope.equals(Scope.CONVERSATION)) {
+// boolean hasConversationalContract = false;
+// for (Service serviceDef : implementation.getServices()) {
+// if (serviceDef.getInterfaceContract().getInterface()
+// .isConversational()) {
+// hasConversationalContract = true;
+// break;
+// }
+// }
+// if (!hasConversationalContract) {
+// Exception e = new NoConversationalContractException(
+// runtimeComponent.getName() + ":" + osgiBundle);
+// throw new RuntimeException(e);
+// }
+// }
+ }
+
+ synchronized (this) {
+ processedResolvedBundle = true;
+ this.notifyAll();
+ }
+ }
public void stop() {
- bundleContext.removeServiceListener(osgiServiceListener);
+ if (osgiServiceListener != null)
+ bundleContext.removeServiceListener(osgiServiceListener);
}
@@ -1185,8 +1157,16 @@
}
}
-
-
+
+ public void bundleChanged(BundleEvent event) {
+ if (event.getType() == BundleEvent.RESOLVED && event.getBundle() == osgiBundle) {
+ try {
+ processAnnotations();
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ }
+ }
private class OSGiServiceListener implements ServiceListener {
Modified: incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiImplementationProviderFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiImplementationProviderFactory.java?rev=575799&r1=575798&r2=575799&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiImplementationProviderFactory.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiImplementationProviderFactory.java Fri Sep 14 14:40:35 2007
@@ -19,8 +19,16 @@
package org.apache.tuscany.sca.implementation.osgi.invocation;
+import org.apache.tuscany.sca.context.ContextFactoryExtensionPoint;
+import org.apache.tuscany.sca.context.RequestContextFactory;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.core.invocation.ProxyFactoryExtensionPoint;
+import org.apache.tuscany.sca.core.scope.ScopeRegistry;
import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
+import org.apache.tuscany.sca.databinding.TransformerExtensionPoint;
+import org.apache.tuscany.sca.databinding.impl.MediatorImpl;
+import org.apache.tuscany.sca.implementation.java.injection.JavaPropertyValueObjectFactory;
import org.apache.tuscany.sca.implementation.osgi.OSGiImplementationInterface;
import org.apache.tuscany.sca.provider.ImplementationProvider;
import org.apache.tuscany.sca.provider.ImplementationProviderFactory;
@@ -34,17 +42,30 @@
*/
public class OSGiImplementationProviderFactory implements ImplementationProviderFactory<OSGiImplementationInterface> {
- DataBindingExtensionPoint dataBindings;
+ private DataBindingExtensionPoint dataBindings;
+ private JavaPropertyValueObjectFactory propertyFactory;
+ private ProxyFactory proxyFactory;
+ private ScopeRegistry scopeRegistry;
- public OSGiImplementationProviderFactory(ExtensionPointRegistry extensionPoints) {
+ private RequestContextFactory requestContextFactory;
+
+ public OSGiImplementationProviderFactory(ExtensionPointRegistry extensionPoints ) {
dataBindings = extensionPoints.getExtensionPoint(DataBindingExtensionPoint.class);
- //FIXME transformers is never used
- //TransformerExtensionPoint transformers = extensionPoints.getExtensionPoint(TransformerExtensionPoint.class);
- //FIXME mediator is never used
- //MediatorImpl mediator =new MediatorImpl(dataBindings, transformers);
- //FIXME factory is never used
- //OSGiPropertyValueObjectFactory factory = new OSGiPropertyValueObjectFactory(mediator);
+ proxyFactory = extensionPoints.getExtensionPoint(ProxyFactoryExtensionPoint.class);
+ ContextFactoryExtensionPoint contextFactories = extensionPoints.getExtensionPoint(ContextFactoryExtensionPoint.class);
+ requestContextFactory = contextFactories.getFactory(RequestContextFactory.class);
+
+
+ // FIXME: Scope registry is not an extension point, and this usage is specific
+ // to implementation.osgi since it needs to change scope after the component is
+ // created. Do we need to find a better way?
+ scopeRegistry = extensionPoints.getExtensionPoint(ScopeRegistry.class);
+
+ TransformerExtensionPoint transformers = extensionPoints.getExtensionPoint(TransformerExtensionPoint.class);
+ MediatorImpl mediator = new MediatorImpl(dataBindings, transformers);
+ propertyFactory = new JavaPropertyValueObjectFactory(mediator);
+
}
public ImplementationProvider createImplementationProvider(RuntimeComponent component,
@@ -52,7 +73,14 @@
try {
- return new OSGiImplementationProvider(component, implementation, dataBindings);
+ return new OSGiImplementationProvider(component,
+ implementation,
+ dataBindings,
+ propertyFactory,
+ proxyFactory,
+ scopeRegistry,
+ requestContextFactory
+ );
} catch (BundleException e) {
throw new RuntimeException(e);
Modified: incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiInstanceWrapper.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiInstanceWrapper.java?rev=575799&r1=575798&r2=575799&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiInstanceWrapper.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiInstanceWrapper.java Fri Sep 14 14:40:35 2007
@@ -20,6 +20,8 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
import java.util.Hashtable;
import java.util.List;
import java.util.Random;
@@ -30,11 +32,15 @@
import org.apache.tuscany.sca.core.scope.Scope;
import org.apache.tuscany.sca.core.scope.TargetDestructionException;
import org.apache.tuscany.sca.core.scope.TargetInitializationException;
+import org.apache.tuscany.sca.implementation.osgi.context.OSGiAnnotations;
import org.apache.tuscany.sca.interfacedef.Interface;
import org.apache.tuscany.sca.runtime.EndpointReference;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
import org.osgi.framework.ServiceReference;
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Init;
/**
@@ -49,16 +55,22 @@
*/
public class OSGiInstanceWrapper<T> implements InstanceWrapper<T> {
+ private OSGiAnnotations annotationProcessor;
private OSGiImplementationProvider provider;
private BundleContext bundleContext;
private Hashtable<Object,InstanceInfo<T>> instanceInfoList =
new Hashtable<Object,InstanceInfo<T>>();
+
+ // Dummy bundles are used to create a new service object for scopes other than COMPOSITE
+ private Bundle dummyReferenceBundle;
public OSGiInstanceWrapper(OSGiImplementationProvider provider,
+ OSGiAnnotations annotationProcessor,
BundleContext bundleContext) {
this.provider = provider;
+ this.annotationProcessor = annotationProcessor;
this.bundleContext = bundleContext;
}
@@ -69,19 +81,32 @@
Bundle refBundle = provider.startBundle();
- if (!provider.getImplementation().getScope().equals(Scope.COMPOSITE)) {
+ if (!annotationProcessor.getScope().equals(Scope.COMPOSITE)) {
refBundle = getDummyReferenceBundle();
}
InstanceInfo<T> instanceInfo = new InstanceInfo<T>();
- instanceInfoList.put(service, instanceInfo);
-
- instanceInfo.osgiServiceReference = provider.getOSGiServiceReference(service);
+ instanceInfo.osgiServiceReference = provider.getOSGiServiceReference(service);
instanceInfo.refBundleContext = refBundle.getBundleContext();
- instanceInfo.osgiInstance = (T)instanceInfo.refBundleContext.getService(instanceInfo.osgiServiceReference);
+
+ instanceInfo.osgiInstance = getInstanceObject(instanceInfo);
- provider.injectProperties(instanceInfo.osgiInstance);
+ try {
+
+ if (!isInitialized(instanceInfo.osgiInstance)) {
+
+ annotationProcessor.injectProperties(instanceInfo.osgiInstance);
+ callLifecycleMethod(instanceInfo.osgiInstance, Init.class);
+
+ instanceInfo.isFirstInstance = true;
+ }
+
+ instanceInfoList.put(service, instanceInfo);
+
+ } catch (Exception e) {
+ throw new TargetInitializationException(e);
+ }
return instanceInfo.osgiInstance;
}
@@ -94,18 +119,33 @@
Bundle refBundle = provider.startBundle();
- if (!provider.getImplementation().getScope().equals(Scope.COMPOSITE)) {
+ if (!annotationProcessor.getScope().equals(Scope.COMPOSITE)) {
refBundle = getDummyReferenceBundle();
}
InstanceInfo<T> instanceInfo = new InstanceInfo<T>();
- instanceInfoList.put(callbackInterface, instanceInfo);
instanceInfo.osgiServiceReference = provider.getOSGiServiceReference(from, callbackInterface);
instanceInfo.refBundleContext = refBundle.getBundleContext();
- instanceInfo.osgiInstance = (T)instanceInfo.refBundleContext.getService(instanceInfo.osgiServiceReference);
+ instanceInfo.osgiInstance = getInstanceObject(instanceInfo);
+
+
+ try {
+
+ if (!isInitialized(instanceInfo.osgiInstance)) {
+
+ annotationProcessor.injectProperties(instanceInfo.osgiInstance);
+ callLifecycleMethod(instanceInfo.osgiInstance, Init.class);
+ instanceInfo.isFirstInstance = true;
+ }
+
+ instanceInfoList.put(callbackInterface, instanceInfo);
+
+ } catch (Exception e) {
+ throw new TargetInitializationException(e);
+ }
return instanceInfo.osgiInstance;
}
@@ -129,28 +169,44 @@
public synchronized void stop() throws TargetDestructionException {
for (InstanceInfo<T> instanceInfo : instanceInfoList.values()) {
- if (instanceInfo.osgiInstance != null && instanceInfo.osgiServiceReference != null) {
+ if (instanceInfo.osgiInstance != null && instanceInfo.osgiServiceReference != null) {
+
+ try {
+
+ if (instanceInfo.isFirstInstance)
+ callLifecycleMethod(instanceInfo.osgiInstance, Destroy.class);
- instanceInfo.refBundleContext.ungetService(instanceInfo.osgiServiceReference);
+ instanceInfo.refBundleContext.ungetService(instanceInfo.osgiServiceReference);
- instanceInfo.osgiInstance = null;
- instanceInfo.osgiServiceReference = null;
+ instanceInfo.osgiInstance = null;
+ instanceInfo.osgiServiceReference = null;
- try {
- if (instanceInfo.dummyBundle != null) {
- instanceInfo.dummyBundle.uninstall();
- }
} catch (Exception e) {
throw new TargetDestructionException(e);
}
}
}
instanceInfoList.clear();
+ if (dummyReferenceBundle != null) {
+ try {
+ dummyReferenceBundle.uninstall();
+ } catch (BundleException e) {
+ throw new TargetDestructionException(e);
+ }
+ dummyReferenceBundle = null;
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private T getInstanceObject(InstanceInfo<T> instanceInfo) {
+ return (T)instanceInfo.refBundleContext.getService(instanceInfo.osgiServiceReference);
}
private Bundle getDummyReferenceBundle() throws TargetInitializationException {
- Bundle dummyBundle = null;
+ if (dummyReferenceBundle != null)
+ return dummyReferenceBundle;
+
ByteArrayOutputStream out = new ByteArrayOutputStream();
String EOL = System.getProperty("line.separator");
@@ -182,23 +238,47 @@
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
- dummyBundle = bundleContext.installBundle("file://" + bundleName + ".jar", in);
+ dummyReferenceBundle = bundleContext.installBundle("file://" + bundleName + ".jar", in);
- dummyBundle.start();
+ dummyReferenceBundle.start();
} catch (Exception e) {
throw new TargetInitializationException(e);
}
- return dummyBundle;
+ return dummyReferenceBundle;
}
+ private void callLifecycleMethod(Object instance,
+ Class<? extends Annotation> annotationClass) throws Exception {
+
+ Method method = null;
+ if (annotationClass == Init.class) {
+ method = annotationProcessor.getInitMethod(instance);
+ } else if (annotationClass == Destroy.class) {
+ method = annotationProcessor.getDestroyMethod(instance);
+ }
+
+ if (method != null) {
+ method.setAccessible(true);
+ method.invoke(instance);
+ }
+ }
+
+ private boolean isInitialized(Object instance) {
+ for (InstanceInfo<?> info : instanceInfoList.values()) {
+ if (info.osgiInstance == instance)
+ return true;
+ }
+ return false;
+ }
+
private static class InstanceInfo<T> {
private T osgiInstance;
private ServiceReference osgiServiceReference;
- private Bundle dummyBundle;
private BundleContext refBundleContext;
+ private boolean isFirstInstance;
}
Modified: incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiRemotableInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiRemotableInvoker.java?rev=575799&r1=575798&r2=575799&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiRemotableInvoker.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiRemotableInvoker.java Fri Sep 14 14:40:35 2007
@@ -26,11 +26,10 @@
import org.apache.tuscany.sca.databinding.DataBinding;
import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
-import org.apache.tuscany.sca.implementation.osgi.xml.OSGiImplementation;
+import org.apache.tuscany.sca.implementation.osgi.context.OSGiAnnotations;
import org.apache.tuscany.sca.interfacedef.DataType;
import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.invocation.Message;
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
import org.apache.tuscany.sca.runtime.RuntimeComponentService;
/**
@@ -41,7 +40,7 @@
private DataBindingExtensionPoint registry;
private Operation operation;
- private OSGiImplementation osgiImplementation;
+ private OSGiAnnotations osgiAnnotations;
/**
* @param registry
@@ -49,13 +48,13 @@
* @param method
* @param component
*/
- public OSGiRemotableInvoker(OSGiImplementation osgiImplementation,
+ public OSGiRemotableInvoker(OSGiAnnotations osgiAnnotations,
DataBindingExtensionPoint registry,
Operation operation,
- RuntimeComponent component,
+ OSGiImplementationProvider provider,
RuntimeComponentService service) {
- super(operation, component, service);
- this.osgiImplementation = osgiImplementation;
+ super(operation, provider, service);
+ this.osgiAnnotations = osgiAnnotations;
this.registry = registry;
this.operation = operation;
}
@@ -65,7 +64,7 @@
throws InvocationTargetException {
Object result;
- if (osgiImplementation.isAllowsPassByReference(m)) {
+ if (osgiAnnotations.isAllowsPassByReference(targetObject, m)) {
result = super.invokeMethod(targetObject, m, msg);
}
else {
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org