cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dani...@apache.org
Subject svn commit: r581604 - in /cocoon/whiteboard/osgi/core/cocoon-spring-osgi/cocoon-spring-osgi-impl/src/main: java/org/apache/cocoon/springosgi/config/ java/org/apache/cocoon/springosgi/service/exporter/ java/org/apache/cocoon/springosgi/service/importer/...
Date Wed, 03 Oct 2007 14:02:32 GMT
Author: danielf
Date: Wed Oct  3 07:02:32 2007
New Revision: 581604

URL: http://svn.apache.org/viewvc?rev=581604&view=rev
Log:
Making it possible to import beans that are exported as factories.

Added:
    cocoon/whiteboard/osgi/core/cocoon-spring-osgi/cocoon-spring-osgi-impl/src/main/java/org/apache/cocoon/springosgi/service/importer/OsgiSingleServiceProxyFactoryBean.java
  (with props)
Modified:
    cocoon/whiteboard/osgi/core/cocoon-spring-osgi/cocoon-spring-osgi-impl/src/main/java/org/apache/cocoon/springosgi/config/OsgiNamespaceHandler.java
    cocoon/whiteboard/osgi/core/cocoon-spring-osgi/cocoon-spring-osgi-impl/src/main/java/org/apache/cocoon/springosgi/config/ReferenceBeanDefinitionParser.java
    cocoon/whiteboard/osgi/core/cocoon-spring-osgi/cocoon-spring-osgi-impl/src/main/java/org/apache/cocoon/springosgi/service/exporter/OsgiServiceFactoryBean.java
    cocoon/whiteboard/osgi/core/cocoon-spring-osgi/cocoon-spring-osgi-impl/src/main/resources/org/apache/cocoon/springosgi/config/spring-osgi.xsd

Modified: cocoon/whiteboard/osgi/core/cocoon-spring-osgi/cocoon-spring-osgi-impl/src/main/java/org/apache/cocoon/springosgi/config/OsgiNamespaceHandler.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/osgi/core/cocoon-spring-osgi/cocoon-spring-osgi-impl/src/main/java/org/apache/cocoon/springosgi/config/OsgiNamespaceHandler.java?rev=581604&r1=581603&r2=581604&view=diff
==============================================================================
--- cocoon/whiteboard/osgi/core/cocoon-spring-osgi/cocoon-spring-osgi-impl/src/main/java/org/apache/cocoon/springosgi/config/OsgiNamespaceHandler.java
(original)
+++ cocoon/whiteboard/osgi/core/cocoon-spring-osgi/cocoon-spring-osgi-impl/src/main/java/org/apache/cocoon/springosgi/config/OsgiNamespaceHandler.java
Wed Oct  3 07:02:32 2007
@@ -30,6 +30,8 @@
 	 * @see org.springframework.beans.factory.xml.NamespaceHandler#init()
 	 */
 	public void init() {
+        registerBeanDefinitionParser("reference", new ReferenceBeanDefinitionParser());
+
         registerBeanDefinitionParser("map", new MapBeanDefinitionParser());
 
         registerBeanDefinitionParser("service", new ServiceBeanDefinitionParser());

Modified: cocoon/whiteboard/osgi/core/cocoon-spring-osgi/cocoon-spring-osgi-impl/src/main/java/org/apache/cocoon/springosgi/config/ReferenceBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/osgi/core/cocoon-spring-osgi/cocoon-spring-osgi-impl/src/main/java/org/apache/cocoon/springosgi/config/ReferenceBeanDefinitionParser.java?rev=581604&r1=581603&r2=581604&view=diff
==============================================================================
--- cocoon/whiteboard/osgi/core/cocoon-spring-osgi/cocoon-spring-osgi-impl/src/main/java/org/apache/cocoon/springosgi/config/ReferenceBeanDefinitionParser.java
(original)
+++ cocoon/whiteboard/osgi/core/cocoon-spring-osgi/cocoon-spring-osgi-impl/src/main/java/org/apache/cocoon/springosgi/config/ReferenceBeanDefinitionParser.java
Wed Oct  3 07:02:32 2007
@@ -19,6 +19,7 @@
 import java.util.Iterator;
 import java.util.List;
 
+import org.apache.cocoon.springosgi.service.importer.OsgiSingleServiceProxyFactoryBean;
 import org.springframework.beans.MutablePropertyValues;
 import org.springframework.beans.factory.config.ConstructorArgumentValues;
 import org.springframework.beans.factory.config.RuntimeBeanReference;
@@ -31,7 +32,6 @@
 import org.springframework.osgi.config.ParserUtils;
 import org.springframework.osgi.config.TargetSourceLifecycleListenerWrapper;
 import org.springframework.osgi.config.ParserUtils.AttributeCallback;
-import org.springframework.osgi.service.importer.OsgiSingleServiceProxyFactoryBean;
 import org.springframework.util.StringUtils;
 import org.springframework.util.xml.DomUtils;
 import org.w3c.dom.Attr;

Modified: cocoon/whiteboard/osgi/core/cocoon-spring-osgi/cocoon-spring-osgi-impl/src/main/java/org/apache/cocoon/springosgi/service/exporter/OsgiServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/osgi/core/cocoon-spring-osgi/cocoon-spring-osgi-impl/src/main/java/org/apache/cocoon/springosgi/service/exporter/OsgiServiceFactoryBean.java?rev=581604&r1=581603&r2=581604&view=diff
==============================================================================
--- cocoon/whiteboard/osgi/core/cocoon-spring-osgi/cocoon-spring-osgi-impl/src/main/java/org/apache/cocoon/springosgi/service/exporter/OsgiServiceFactoryBean.java
(original)
+++ cocoon/whiteboard/osgi/core/cocoon-spring-osgi/cocoon-spring-osgi-impl/src/main/java/org/apache/cocoon/springosgi/service/exporter/OsgiServiceFactoryBean.java
Wed Oct  3 07:02:32 2007
@@ -210,7 +210,7 @@
 
     private static final Constants EXPORTING_OPTIONS = new Constants(OsgiServiceFactoryBean.class);
 
-    public static final Object BEAN_CLASSES_PROPERTY_KEY = "org.springframework.osgi.beanclasses";
+    public static final String BEAN_CLASSES_PROPERTY_KEY = "org.springframework.osgi.beanclasses";
     
     private BundleContext bundleContext;
 

Added: cocoon/whiteboard/osgi/core/cocoon-spring-osgi/cocoon-spring-osgi-impl/src/main/java/org/apache/cocoon/springosgi/service/importer/OsgiSingleServiceProxyFactoryBean.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/osgi/core/cocoon-spring-osgi/cocoon-spring-osgi-impl/src/main/java/org/apache/cocoon/springosgi/service/importer/OsgiSingleServiceProxyFactoryBean.java?rev=581604&view=auto
==============================================================================
--- cocoon/whiteboard/osgi/core/cocoon-spring-osgi/cocoon-spring-osgi-impl/src/main/java/org/apache/cocoon/springosgi/service/importer/OsgiSingleServiceProxyFactoryBean.java
(added)
+++ cocoon/whiteboard/osgi/core/cocoon-spring-osgi/cocoon-spring-osgi-impl/src/main/java/org/apache/cocoon/springosgi/service/importer/OsgiSingleServiceProxyFactoryBean.java
Wed Oct  3 07:02:32 2007
@@ -0,0 +1,106 @@
+/*
+ * Copyright 2002-2007 the original author or authors.
+ * 
+ * Licensed 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.cocoon.springosgi.service.importer;
+
+import org.apache.cocoon.springosgi.service.exporter.OsgiServiceFactoryBean;
+import org.springframework.beans.factory.SmartFactoryBean;
+import org.springframework.osgi.util.ClassUtils;
+import org.springframework.osgi.util.OsgiFilterUtils;
+
+/**
+ * Extend the original OsgiSingleServiceProxyFactoryBean with the possibility to import bean
factories
+ * from other bundles in the current Spring context.
+ * @version $Id$
+ */
+public class OsgiSingleServiceProxyFactoryBean
+        extends org.springframework.osgi.service.importer.OsgiSingleServiceProxyFactoryBean
{
+
+    private boolean factoryExport;
+
+    /* (non-Javadoc)
+     * @see org.springframework.osgi.service.importer.AbstractOsgiServiceProxyFactoryBean#afterPropertiesSet()
+     */
+    public void afterPropertiesSet() {
+        if (factoryExport) {
+            filter = OsgiFilterUtils.unifyFilter(OsgiServiceFactoryBean.BEAN_CLASSES_PROPERTY_KEY,
+                    ClassUtils.toStringArray(serviceTypes), filter);
+            serviceTypes = new Class[] { SmartFactoryBean.class };
+        }
+        super.afterPropertiesSet();
+    }
+
+    /* (non-Javadoc)
+     * @see org.springframework.osgi.service.importer.OsgiSingleServiceProxyFactoryBean#getObject()
+     */
+    // Why doesn't org.springframework.osgi.service.importer.OsgiSingleServiceProxyFactoryBean
throw an Exception?
+    // TODO: Add a ServiceReferenceAwareAdvice
+    public Object getObject() {
+        if (!factoryExport)
+            return super.getObject();
+        else {
+            try {
+                Object bean = ((SmartFactoryBean)super.getObject()).getObject();
+                return bean;
+            } catch (Exception e) {
+                return null;
+            }
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.springframework.osgi.service.importer.OsgiSingleServiceProxyFactoryBean#getObjectType()
+     */
+    public Class getObjectType() {
+        if (!factoryExport)
+            return super.getObjectType();
+        else 
+            return ((SmartFactoryBean)super.getObject()).getObjectType();
+    }
+
+    /* (non-Javadoc)
+     * @see org.springframework.osgi.service.importer.AbstractOsgiServiceProxyFactoryBean#isEagerInit()
+     */
+    public boolean isEagerInit() {
+        if (!factoryExport)
+            return super.isEagerInit();
+        else 
+            return ((SmartFactoryBean)super.getObject()).isEagerInit();
+    }
+
+    /* (non-Javadoc)
+     * @see org.springframework.osgi.service.importer.AbstractOsgiServiceProxyFactoryBean#isPrototype()
+     */
+    public boolean isPrototype() {
+        if (!factoryExport)
+            return super.isPrototype();
+        else 
+            return ((SmartFactoryBean)super.getObject()).isPrototype();
+    }
+    
+    /* (non-Javadoc)
+     * @see org.springframework.osgi.service.importer.AbstractOsgiServiceProxyFactoryBean#isSingleton()
+     */
+    public boolean isSingleton() {
+        if (!factoryExport)
+            return super.isSingleton();
+        else 
+            return ((SmartFactoryBean)super.getObject()).isSingleton();
+    }
+
+    public void setFactoryExport(boolean factoryExport) {
+        this.factoryExport = factoryExport;
+    }
+}

Propchange: cocoon/whiteboard/osgi/core/cocoon-spring-osgi/cocoon-spring-osgi-impl/src/main/java/org/apache/cocoon/springosgi/service/importer/OsgiSingleServiceProxyFactoryBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/whiteboard/osgi/core/cocoon-spring-osgi/cocoon-spring-osgi-impl/src/main/java/org/apache/cocoon/springosgi/service/importer/OsgiSingleServiceProxyFactoryBean.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: cocoon/whiteboard/osgi/core/cocoon-spring-osgi/cocoon-spring-osgi-impl/src/main/resources/org/apache/cocoon/springosgi/config/spring-osgi.xsd
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/osgi/core/cocoon-spring-osgi/cocoon-spring-osgi-impl/src/main/resources/org/apache/cocoon/springosgi/config/spring-osgi.xsd?rev=581604&r1=581603&r2=581604&view=diff
==============================================================================
--- cocoon/whiteboard/osgi/core/cocoon-spring-osgi/cocoon-spring-osgi-impl/src/main/resources/org/apache/cocoon/springosgi/config/spring-osgi.xsd
(original)
+++ cocoon/whiteboard/osgi/core/cocoon-spring-osgi/cocoon-spring-osgi-impl/src/main/resources/org/apache/cocoon/springosgi/config/spring-osgi.xsd
Wed Oct  3 07:02:32 2007
@@ -32,6 +32,16 @@
         </xsd:documentation>
     </xsd:annotation>
 
+    <xsd:element name="reference" type="Treference"/>
+
+    <xsd:complexType name="Treference">
+        <xsd:complexContent>
+            <xsd:extension base="springosgi:Treference">
+                <xsd:attribute name="factory-export" type="xsd:boolean" use="optional"
default="false"/>
+            </xsd:extension>
+        </xsd:complexContent>
+    </xsd:complexType>
+
 	<xsd:element name="map" type="Tmap">
 		<xsd:annotation>
 			<xsd:documentation source="java:org.apache.cocoon.springosgi.map.OsgiServiceMap">



Mime
View raw message