hivemind-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject cvs commit: jakarta-hivemind/library/src/documentation/content/xdocs/hivemind-lib SpringLookupFactory.xml
Date Tue, 01 Jun 2004 14:17:31 GMT
hlship      2004/06/01 07:17:31

  Modified:    library/src/descriptor/META-INF hivemodule.sdl
               library  build.xml
  Added:       library/src/java/org/apache/hivemind/lib/impl
                        SpringBeanParameter.java
                        SpringBeanFactoryHolderImpl.java
                        SpringLookupFactory.java
               library/src/java/org/apache/hivemind/lib
                        SpringBeanFactoryHolder.java
                        SpringBeanFactorySource.java
               library/src/documentation/content/xdocs/hivemind-lib
                        SpringLookupFactory.xml
  Log:
  Add simple Spring framework integration.
  
  Revision  Changes    Path
  1.1                  jakarta-hivemind/library/src/java/org/apache/hivemind/lib/impl/SpringBeanParameter.java
  
  Index: SpringBeanParameter.java
  ===================================================================
  //  Copyright 2004 The Apache Software Foundation
  //
  // 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.hivemind.lib.impl;
  
  import org.apache.hivemind.impl.BaseLocatable;
  import org.apache.hivemind.lib.SpringBeanFactorySource;
  
  /**
   * Parameter to {@link org.apache.hivemind.lib.impl.SpringLookupFactory}, 
   * containing a (required) bean name to
   * obtain, and an (optional) bean factory source.
   *
   * @author Howard Lewis Ship
   * @version $Id: SpringBeanParameter.java,v 1.1 2004/06/01 14:17:30 hlship Exp $
   */
  public class SpringBeanParameter extends BaseLocatable
  {
      private String _name;
      private SpringBeanFactorySource _beanFactorySource;
  
      public SpringBeanFactorySource getBeanFactorySource()
      {
          return _beanFactorySource;
      }
  
      public String getName()
      {
          return _name;
      }
  
      public void setBeanFactorySource(SpringBeanFactorySource source)
      {
          _beanFactorySource = source;
      }
  
      public void setName(String string)
      {
          _name = string;
      }
  
  }
  
  
  
  1.1                  jakarta-hivemind/library/src/java/org/apache/hivemind/lib/impl/SpringBeanFactoryHolderImpl.java
  
  Index: SpringBeanFactoryHolderImpl.java
  ===================================================================
  //  Copyright 2004 The Apache Software Foundation
  //
  // 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.hivemind.lib.impl;
  
  import org.apache.hivemind.impl.BaseLocatable;
  import org.apache.hivemind.lib.SpringBeanFactoryHolder;
  import org.springframework.beans.factory.BeanFactory;
  
  /**
   * Simple holder of a {@link org.springframework.beans.factory.BeanFactory}.
   *
   * @author Howard Lewis Ship
   * @version $Id: SpringBeanFactoryHolderImpl.java,v 1.1 2004/06/01 14:17:30 hlship Exp $
   */
  public class SpringBeanFactoryHolderImpl extends BaseLocatable implements SpringBeanFactoryHolder
  {
      private BeanFactory _factory;
  
      public void setBeanFactory(BeanFactory factory)
      {
          _factory = factory;
      }
  
      public BeanFactory getBeanFactory()
      {
          return _factory;
      }
  
  }
  
  
  
  1.1                  jakarta-hivemind/library/src/java/org/apache/hivemind/lib/impl/SpringLookupFactory.java
  
  Index: SpringLookupFactory.java
  ===================================================================
  //  Copyright 2004 The Apache Software Foundation
  //
  // 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.hivemind.lib.impl;
  
  import java.util.List;
  
  import org.apache.hivemind.HiveMind;
  import org.apache.hivemind.ServiceImplementationFactory;
  import org.apache.hivemind.impl.BaseLocatable;
  import org.apache.hivemind.internal.Module;
  import org.apache.hivemind.lib.SpringBeanFactorySource;
  import org.springframework.beans.factory.BeanFactory;
  
  /**
   * Implementation of {@link org.apache.hivemind.ServiceImplementationFactory}
   * that doesn't create beans ... it looks them up inside a Spring 
   * {@link org.springframework.beans.factory.BeanFactory}.
   *
   * @author Howard Lewis Ship
   * @version $Id: SpringLookupFactory.java,v 1.1 2004/06/01 14:17:30 hlship Exp $
   */
  public class SpringLookupFactory extends BaseLocatable implements ServiceImplementationFactory
  {
      private String _pointId;
      private SpringBeanFactorySource _defaultBeanFactorySource;
  
      public Object createCoreServiceImplementation(
          String serviceId,
          Class serviceInterface,
          Module invokingModule,
          List parameters)
      {
          HiveMind.checkFactoryParameterCount(_pointId, parameters, 1);
  
          SpringBeanParameter p = (SpringBeanParameter) parameters.get(0);
  
          String beanName = p.getName();
          SpringBeanFactorySource s = p.getBeanFactorySource();
  
          if (s == null)
              s = _defaultBeanFactorySource;
  
          BeanFactory f = s.getBeanFactory();
  
          return f.getBean(beanName, serviceInterface);
      }
  
      public void setDefaultBeanFactorySource(SpringBeanFactorySource source)
      {
          _defaultBeanFactorySource = source;
      }
  
      public void setPointId(String string)
      {
          _pointId = string;
      }
  
  }
  
  
  
  1.1                  jakarta-hivemind/library/src/java/org/apache/hivemind/lib/SpringBeanFactoryHolder.java
  
  Index: SpringBeanFactoryHolder.java
  ===================================================================
  //  Copyright 2004 The Apache Software Foundation
  //
  // 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.hivemind.lib;
  
  import org.springframework.beans.factory.BeanFactory;
  
  /**
   * Service which simply holds a bean factory (provided externally).  This
   * is used in the case where HiveMind and Spring are initialized in
   * parallel, and then informed of each other.
   *
   * @author Howard Lewis Ship
   * @version $Id: SpringBeanFactoryHolder.java,v 1.1 2004/06/01 14:17:30 hlship Exp $
   */
  public interface SpringBeanFactoryHolder extends SpringBeanFactorySource
  {
      public void setBeanFactory(BeanFactory factory);
  }
  
  
  
  1.1                  jakarta-hivemind/library/src/java/org/apache/hivemind/lib/SpringBeanFactorySource.java
  
  Index: SpringBeanFactorySource.java
  ===================================================================
  //  Copyright 2004 The Apache Software Foundation
  //
  // 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.hivemind.lib;
  
  import org.springframework.beans.factory.BeanFactory;
  
  /**
   * A service which can acts as a source for a 
   * {@link org.springframework.beans.factory.BeanFactory} (from which
   * the different kinds of Spring application contexts derive).
   *
   * @author Howard Lewis Ship
   * @version $Id: SpringBeanFactorySource.java,v 1.1 2004/06/01 14:17:30 hlship Exp $
   */
  public interface SpringBeanFactorySource
  {
  	public BeanFactory getBeanFactory();
  }
  
  
  
  1.5       +55 -1     jakarta-hivemind/library/src/descriptor/META-INF/hivemodule.sdl
  
  Index: hivemodule.sdl
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/library/src/descriptor/META-INF/hivemodule.sdl,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- hivemodule.sdl	19 May 2004 15:08:47 -0000	1.4
  +++ hivemodule.sdl	1 Jun 2004 14:17:30 -0000	1.5
  @@ -114,4 +114,58 @@
   		  	}
   		}
   	}
  +	
  +	service-point (id=SpringLookupFactory interface=org.apache.hivemind.ServiceImplementationFactory)
  +	{
  +	  description
  +	  {
  +	    "A service implementation factory that obtains service implementations from a "
  +	    "Spring BeanFactory."
  +	  }
  +	  parameters-schema
  +	  {
  +	    description
  +	    {
  +	      "Parameters are used to specify the bean name and, optionally, a non-default "
  +	      "BeanFactory source from which to obtain the Spring BeanFactory."
  +	    }
  +	    
  +	    element (name=lookup-bean)
  +	    {
  +	      attribute (name=name required=true)
  +	      {
  +	        description { "The name of the Spring bean to obtain." }
  +	      }
  +	      
  +	      attribute (name=source-service-id translator=service)
  +	      {
  +	        description { "An optional service implementing the SpringBeanFactorySource interface."
}
  +	      }
  +	      
  +	      conversion (class=org.apache.hivemind.lib.impl.SpringBeanParameter)
  +	      {
  +	        map (property=beanFactorySource attribute=source-service-id)
  +	      }
  +	    }
  +	  }
  +	  
  +	  invoke-factory (service-id=hivemind.BuilderFactory)
  +	  {
  +	    construct (class=org.apache.hivemind.lib.impl.SpringLookupFactory service-id-property=pointId)
  +	    {
  +	      set-service (property=defaultBeanFactorySource service-id=DefaultSpringBeanFactoryHolder)
  +	    }
  +	  }
  +	}
  +	
  +	service-point (id=DefaultSpringBeanFactoryHolder interface=org.apache.hivemind.lib.SpringBeanFactoryHolder)
  +	{
  +	  description
  +	  {
  +	    "Default source for Spring BeanFactories.  External code can inject a BeanFactory
here, where it is "
  +	    "available to the SpringLookupFactory service."
  +	  }
  +	  
  +	  create-instance (class=org.apache.hivemind.lib.impl.SpringBeanFactoryHolderImpl)
  +	}
   }
  
  
  
  1.5       +3 -2      jakarta-hivemind/library/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/library/build.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- build.xml	28 May 2004 16:44:39 -0000	1.4
  +++ build.xml	1 Jun 2004 14:17:30 -0000	1.5
  @@ -26,7 +26,8 @@
   	<import file="${common.dir}/clover-report.xml"/>
   		
   	<target name="compile">
  -		<ibiblio-dependency jar="jboss-j2ee-3.2.1.jar" group-id="jboss"/>
  +		<ibiblio-dependency jar="geronimo-spec-ejb-1.0-M1.jar" group-id="geronimo-spec"/>
  +		<ibiblio-dependency jar="spring-full-1.0.1.jar" group-id="springframework"/>
   		
   		<ibiblio-dependency jar="commons-logging-1.0.3.jar" group-id="commons-logging" use="test"/>
   		<ibiblio-dependency jar="javassist-2.6.jar" group-id="jboss" use="test"/>
  
  
  
  1.1                  jakarta-hivemind/library/src/documentation/content/xdocs/hivemind-lib/SpringLookupFactory.xml
  
  Index: SpringLookupFactory.xml
  ===================================================================
  <?xml version="1.0"?>
  <!-- $Id: SpringLookupFactory.xml,v 1.1 2004/06/01 14:17:30 hlship Exp $ -->
  <!-- 
     Copyright 2004 The Apache Software Foundation
  
     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.
  -->
  <!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V1.2//EN"
  	"./dtd/document-v12.dtd" [
  	<!ENTITY projectroot '../'>
  	<!ENTITY % common-links SYSTEM "../links.ent">
  	%common-links;
  	]>
  <document>
  	<header>
  		<title>hivemind.lib.SpringLookupFactory Service</title>
  	</header>
  	<body>
  		<p>The <link href="&hivedoc;/service/hivemind.lib.SpringLookupFactory.html">
  			SpringLookupFactory</link> supports integration with the <link
  			href="site:spring">Spring</link> framework, another open-source
  			lightweight container. SpringLookupFactory is a service constructor that
  			obtains a core service implementation from a Spring <code>BeanFactory</code>
  			.</p>
  		<p>By default, the <code>BeanFactory</code> is obtained from the <link
  			href="&hivedoc;/service/hivemind.lib.DefaultSpringBeanFactoryHolder.html">
  			DefaultSpringBeanFactoryHolder</link>. Part of your application startup
  			code requires that you start a Spring instance and inform the <link
  			href="&apiroot-lib;/SpringBeanFactoryHolder.html#setBeanFactory(org.springframework.beans.factory.BeanFactory)"
  			>DefaultSpringBeanFactoryHolder</link> about it.</p>
  		<p>The SpringLookupFactory expects exactly <em>one</em> parameter element:</p>
  		<source><![CDATA[
    lookup-bean (name=... source-service-id=...)
  ]]> </source>
  		<p>The <code>name</code> attribute is the name of the bean to look for
  			inside the Spring BeanFactory.</p>
  		<p>The optional <code>source-service-id</code> attribute allows an alternate
  			service to be used to obtain the BeanFactory. The identified service must
  			implement the <link href="&apiroot-lib;/SpringBeanFactorySource.html">
  			SpringBeanFactorySource</link> interface.</p>
  	</body>
  </document>
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-cvs-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-cvs-help@jakarta.apache.org


Mime
View raw message