Beispiel für Springframework / Hibernate / Equinox / OSGi / Eclipse / ExtensionPoints

Thomas Darimont

Erfahrenes Mitglied
Hallo!

Hier mal ein Beispiel für die Realisierung einer auf Springframework / Hibernate
basierenden Anwendung die OSGi-Bundles als Modularisierungs- und Eclipse ExtensionPoints
als flexiblen Erweiterungsmechanismus verwendet und auf der Equinox OSGi-Runtime von Eclipse läuft.


Das Springframework bietet mit Spring-OSGi ( http://www.springframework.org/osgi ) eine Alternative OSGi Integration an auf die ich hier nicht näher eingehe.

Aufgrund der statischen Natur dieses Ansatzes wird das dynamische starten/stoppen von Anwendungsmodulen (Bundles) nicht unterstützt.

In unserem Szenario haben wir 3 Bundles (Eclipse Plugins):
  • de.tutorials.framework
  • de.tutorials.framework.libraries
  • de.tutorials.masterdata
Das framework Plugin stellt die grundlegende Systeminfrastruktur für die
Anwendung bereit. Beispielsweise enthält das framework Bundle die Konfiguration der
Hibernate-Laufzeit, die Definition der Hibernate SessionFactory, die Definiton der
DataSource und eines TransactionManagers.

Das framework.libraries Plugin stellt die vom Framework benötigten Bilbiotheken bereit.

Das masterdata Plugin beinhaltet in unserem Beispiel einen einfachen Dienst zum
anlegen und auffinden von Personen der die Anfragen an ein entsprechendes DAO übergibt welches von HibernateDAOSupport abgeleitet ist und an ein HibernateTemplate delegiert. Dieser Dienst ist in einem eigenen Application-Context Konfigurationsfile konfiguriert.

In diesem Beispiel werden mehrere AplicationContext-Definitonen (aus unterschiedlichen Bundles) zur Laufzeit zu einem zentralen Spring-ApplicationContext zusammengefasst. Die einzelnen ApplicationContext-Konfigurationsfiles werden über einen eigenen Eclipse ExtensionPoint de.tutorials.framework.applicationContexts bereitgestellt und beim Start des framework-Bundles zur Erzeugung eines neuen ApplicationContexts verwendet.
So ist es möglich Bundle-übergreifend BeanDefinition aus anderen ApplicationContext-Konfigurationsdateien zu verwenden.
(In diesem Beispiel greife ich beispielsweise in der masterdata ApplicationContext Definition auf die SessionFactory und den TransactionManager zurück der im framework Bundle definiert ist.)

Soweit so gut, nun haben wir bei der Erzeugung unseres zentralen ApplicationContexts alle ApplicationContext-Konfigurationsfiles der entsprechenden Bundles vorliegen. Nun ist die Frage wie bekommen wir die Hibernate-MappingLocations, die wir für die Konfiguration der Sessionfactory benötigen, über alle Bundles zum Zeitpunkt der ApplicationContext Erzeugung?
Ganz einfach :) Wir verwenden auch hier den ExtensionPoint Mechanismus von Eclipse
und stellen die HibernateMappingDirectoryLocations zu Verfügung. Dazu definieren wir
nun den ExtensionPoint de.tutorials.framework.hibernateMappingLocations.
So haben wir nun auch die HibernateMapingLocations über alle Bundles zum Zeitpunkt der ApplicationContext Erzeugung verfügbar.
Wie können wir es nun schaffen die HibernateMappingLocations für das im framework-context konfigurierte LocalSessionFactoryBean in das Property mappingDirectoryLocations zu stecken?
Eine Möglichkeit wäre beispielsweise auszunutzen, dass das mappingDirectoryLocations
Property eine <list> Element entgegennimmt. D.h. wir könnten ein eigenes Bean definieren dass das List Interface implementiert und dieses dann per ref-Attribut in das mappingDirectoryLocations Property schieben.

In meinem Beispiel schaut das Teil dann wie folgt aus:
Java:
  /**
   * 
   */
  package de.tutorials.framework.util.hibernate;
   
  import java.util.ArrayList;
  import java.util.Collections;
   
  import de.tutorials.framework.osgi.Activator;
   
  /**
   * @author Tom
   * 
   */
  public class HibernateMappingLocationProvider extends ArrayList<String> {
              /**
               * 
               */
              private static final long serialVersionUID = 2740757538764255296L;
   
              public HibernateMappingLocationProvider() {
                          Collections.addAll(this, Activator.getDefault()
                                                  .getContributedHibernateMappingLocations());
              }
  }

Mein framework-context.xml im de.tutorials.framework Bundle:
XML:
  <?xml version="1.0" encoding="UTF-8"?>
   
  <!--
    - Application context definition for JPetStore's business layer.
    - Contains bean references to the transaction manager and to the DAOs in
    - dataAccessContext-local/jta.xml (see web.xml's "contextConfigLocation").
    -->
  <beans xmlns="http://www.springframework.org/schema/beans"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xmlns:aop="http://www.springframework.org/schema/aop"
              xmlns:tx="http://www.springframework.org/schema/tx"
              xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
             http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
             http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
              
              <bean id="propertyConfigurer"
                          class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
                          <property name="location" value="config/jdbc.properties"/>
              </bean>
              
              <bean id="transactionManager"
                          class="org.springframework.orm.hibernate3.HibernateTransactionManager">
                          <property name="sessionFactory">
                                      <ref bean="sessionFactory"/>
                          </property>
              </bean>
              
              <bean id="sessionFactory"
                          class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
                          <property name="dataSource" ref="dataSource"/>
                          <property name="mappingDirectoryLocations">
                                      <bean class="de.tutorials.framework.util.hibernate.HibernateMappingLocationProvider"/>
                          </property>
                          <property name="hibernateProperties">
                                      <props>
                                                  <prop key="hibernate.dialect">${hibernate.dialect}</prop>
                                                  <prop key="hibernate.show_sql">true</prop>
                                                  <prop key="hibernate.generate_statistics">true</prop>
                                      </props>
                          </property>
              </bean>
              
              <bean id="dataSource"
                          class="org.springframework.jdbc.datasource.DriverManagerDataSource">
                          <property name="driverClassName" value="${jdbc.driverClassName}"/>
                          <property name="url" value="${jdbc.url}"/>
                          <property name="username" value="${jdbc.username}"/>
                          <property name="password" value="${jdbc.password}"/>
              </bean>
  </beans>

Damit triggert die Erzeugung des ApplicationContexts durch das starten des Framework-Plugins implizit das ermitteln der über den de.tutorials.framework.hibernateMappingLocations bereitgestellten HibernateMappingLocations an. Somit sind die Bundle-übergreifenden Hibernate-MappingLocations nun auch in der
Springkonfiguraton verfügbar.


Mein masterdata-context.xml im de.tutorials.masterdata Bundle
XML:
<?xml version="1.0" encoding="UTF-8"?>

<!--
  - Application context definition for JPetStore's business layer.
  - Contains bean references to the transaction manager and to the DAOs in
  - dataAccessContext-local/jta.xml (see web.xml's "contextConfigLocation").
  -->
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:tx="http://www.springframework.org/schema/tx"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"
	default-lazy-init="true">
	
	<bean name="personService"
		class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
		<property name="transactionManager">
			<ref bean="transactionManager"/>
		</property>
		<property name="target">
			<bean class="de.tutorials.masterdata.services.internal.PersonService">
				<property name="personDAO">
					<ref bean="personDAO"/>
				</property>
			</bean>
		</property>
		<property name="proxyInterfaces">
			<list>
				<value>de.tutorials.masterdata.services.IPersonService</value>
			</list>
		</property>
		<property name="transactionAttributes">
			<props>
				<prop key="save*">PROPAGATION_REQUIRED</prop>
				<prop key="delete*">PROPAGATION_REQUIRED</prop>
			</props>
		</property>
	</bean>
	
	<bean name="personDAO" class="de.tutorials.masterdata.dao.internal.PersonDAO">
		<property name="sessionFactory">
			<ref bean="sessionFactory"/>
		</property>
	</bean>
</beans>

Im Anhang finden sich die Beispiel Projekte zu den entsprechenden Bundles.
Aus dem framework.libraries Bundle habe ich Third-Party jars herausgenommen um die maximale Uploadgrenze nicht zu überschreiten. Die benötigten jars sollten über die Classpath einträge und dem Screenshot ersichtlich sein.

Die detaillierte Konfiguration des BuddyClassLoadings / der Plugin Abhängigkeiten, die Definition der Extension-Points und der exportieren packages kann man den Beispielen entnehmen.

Um das Beispiel auszuführen muss man die Verbindungsinformationen im de.tutorials.framework Bundle unter config/jdbc.properties entsprechend anpassen und folgende Tabelle anlegen:
SQL:
create table person(id int null auto_increment, firstname varchar(255), lastname varchar(255), primary key(id));

Gruß Tom
 

Anhänge

  • 27224attachment.jpg
    27224attachment.jpg
    45,2 KB · Aufrufe: 1.324
  • 27226attachment.zip
    27226attachment.zip
    69,1 KB · Aufrufe: 587
Zuletzt bearbeitet von einem Moderator:
Hallo!

Das de.tutorials.masterdata Bundle verwendet in unserem Beispiel im Activator unseren PersonService um eine neue Person zu speichern und anschließend die vorhandenen Personen aufzulisten.

Der Activator von de.tutorials.masterdata:
Java:
package de.tutorials.masterdata.osgi;

import org.eclipse.core.runtime.Plugin;
import org.osgi.framework.BundleContext;

import de.tutorials.masterdata.domain.Person;
import de.tutorials.masterdata.services.IPersonService;

/**
 * The activator class controls the plug-in life cycle
 */
public class Activator extends Plugin {

	// The plug-in ID
	public static final String PLUGIN_ID = "de.tutorials.masterdata";
	
	// The shared instance
	private static Activator plugin;
	
	/**
	 * The constructor
	 */
	public Activator() {
	}

	/*
	 * (non-Javadoc)
	 * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
	 */
	public void start(BundleContext context) throws Exception {
		super.start(context);
		plugin = this;
		
		IPersonService personService = (IPersonService) de.tutorials.framework.osgi.Activator.getDefault().getApplicationContext().getBean("personService");
		Person person = new Person("Thomas"+System.currentTimeMillis(),"Darimont"+System.currentTimeMillis());
		personService.save(person);
		
		for(Person persistentPerson : personService.findAll()){
			System.out.println(persistentPerson);
		}
	}

	/*
	 * (non-Javadoc)
	 * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
	 */
	public void stop(BundleContext context) throws Exception {
		plugin = null;
		super.stop(context);
		
	}

	/**
	 * Returns the shared instance
	 *
	 * @return the shared instance
	 */
	public static Activator getDefault() {
		return plugin;
	}

}

Die plugin.xml unseres de.tutorials.masterdata Bundles:
XML:
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.2"?>
<plugin>
   <extension
         point="de.tutorials.framework.applicationContexts">
      <applicationContext
            path="config/masterdata-context.xml">
      </applicationContext>
   </extension>
   <extension
         point="de.tutorials.framework.hibernateMappingLocations">
      <hibernateMappingLocation
            path="/de/tutorials/masterdata/domain">
      </hibernateMappingLocation>
   </extension>
</plugin>

Hier mal eine Beispielsession:
Code:
osgi> !SESSION 2006-12-03 19:09:20.812 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.6.0-rc
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=de_DE
Command-line arguments:  -dev file:E:/eclipse/3.3M3/eclipse/workspace/.metadata/.plugins/org.eclipse.pde.core/de.tutorials.framework/dev.properties -os win32 -ws win32 -arch x86 -console -consoleLog

!ENTRY de.tutorials.framework 2006-12-03 19:09:21.703
!MESSAGE Registering: config/framework-context.xml defined by: de.tutorials.framework location: file:/E:/eclipse/3.3M3/eclipse/workspace/de.tutorials.framework/config/framework-context.xml

!ENTRY de.tutorials.framework 2006-12-03 19:09:21.703
!MESSAGE Registering: config/masterdata-context.xml defined by: de.tutorials.masterdata location: file:/E:/eclipse/3.3M3/eclipse/workspace/de.tutorials.masterdata/config/masterdata-context.xml
03.12.2006 19:09:21 org.springframework.core.CollectionFactory <clinit>
INFO: JDK 1.4+ collections available
03.12.2006 19:09:21 org.springframework.core.CollectionFactory <clinit>
INFO: Commons Collections 3.x available
03.12.2006 19:09:21 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from URL [file:/E:/eclipse/3.3M3/eclipse/workspace/de.tutorials.masterdata/config/masterdata-context.xml]
03.12.2006 19:09:23 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from URL [file:/E:/eclipse/3.3M3/eclipse/workspace/de.tutorials.framework/config/framework-context.xml]
03.12.2006 19:09:23 org.springframework.context.support.AbstractRefreshableApplicationContext refreshBeanFactory
INFO: Bean factory for application context [org.springframework.context.support.ClassPathXmlApplicationContext;hashCode=19461870]: org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [personService,personDAO,propertyConfigurer,transactionManager,sessionFactory,dataSource]; root of BeanFactory hierarchy
03.12.2006 19:09:23 org.springframework.context.support.AbstractApplicationContext refresh
INFO: 6 beans defined in application context [org.springframework.context.support.ClassPathXmlApplicationContext;hashCode=19461870]
03.12.2006 19:09:23 org.springframework.core.io.support.PropertiesLoaderSupport loadProperties
INFO: Loading properties file from class path resource [config/jdbc.properties]
03.12.2006 19:09:23 org.springframework.context.support.AbstractApplicationContext initMessageSource
INFO: Unable to locate MessageSource with name 'messageSource': using default [org.springframework.context.support.DelegatingMessageSource@105691e]
03.12.2006 19:09:23 org.springframework.context.support.AbstractApplicationContext initApplicationEventMulticaster
INFO: Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticaster': using default [org.springframework.context.event.SimpleApplicationEventMulticaster@2d189c]
03.12.2006 19:09:23 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in factory [org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [personService,personDAO,propertyConfigurer,transactionManager,sessionFactory,dataSource]; root of BeanFactory hierarchy]
03.12.2006 19:09:23 org.springframework.jdbc.datasource.DriverManagerDataSource setDriverClassName
INFO: Loaded JDBC driver: com.mysql.jdbc.Driver

!ENTRY de.tutorials.framework 2006-12-03 19:09:23.937
!MESSAGE Registering: /de/tutorials/masterdata/domain defined by: de.tutorials.masterdata location: file:/E:/eclipse/3.3M3/eclipse/workspace/de.tutorials.masterdata/bin/de/tutorials/masterdata/domain/
03.12.2006 19:09:23 org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.2 cr4
03.12.2006 19:09:23 org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
03.12.2006 19:09:23 org.hibernate.cfg.Environment buildBytecodeProvider
INFO: Bytecode provider name : cglib
03.12.2006 19:09:23 org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
03.12.2006 19:09:24 org.hibernate.cfg.Configuration addFile
INFO: Reading mappings from file: E:\eclipse\3.3M3\eclipse\workspace\de.tutorials.masterdata\bin\de\tutorials\masterdata\domain\Person.hbm.xml
03.12.2006 19:09:24 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: de.tutorials.masterdata.domain.Person -> person
03.12.2006 19:09:24 org.springframework.orm.hibernate3.LocalSessionFactoryBean buildSessionFactory
INFO: Building new Hibernate SessionFactory
03.12.2006 19:09:24 org.hibernate.connection.ConnectionProviderFactory newConnectionProvider
INFO: Initializing connection provider: org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider
03.12.2006 19:09:24 org.hibernate.cfg.SettingsFactory buildSettings
INFO: RDBMS: MySQL, version: 5.0.22-community-nt
03.12.2006 19:09:24 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-3.1.13 ( $Date: 2005-11-17 15:53:48 +0100 (Thu, 17 Nov 2005) $, $Revision$ )
03.12.2006 19:09:24 org.hibernate.dialect.Dialect <init>
INFO: Using dialect: org.hibernate.dialect.MySQLDialect
03.12.2006 19:09:24 org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
INFO: Using default transaction strategy (direct JDBC transactions)
03.12.2006 19:09:24 org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
03.12.2006 19:09:24 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic flush during beforeCompletion(): disabled
03.12.2006 19:09:24 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic session close at end of transaction: disabled
03.12.2006 19:09:24 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch size: 15
03.12.2006 19:09:24 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch updates for versioned data: disabled
03.12.2006 19:09:24 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Scrollable result sets: enabled
03.12.2006 19:09:24 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC3 getGeneratedKeys(): enabled
03.12.2006 19:09:24 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Connection release mode: on_close
03.12.2006 19:09:24 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Maximum outer join fetch depth: 2
03.12.2006 19:09:24 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default batch fetch size: 1
03.12.2006 19:09:24 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Generate SQL with comments: disabled
03.12.2006 19:09:24 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL updates by primary key: disabled
03.12.2006 19:09:24 org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory
INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
03.12.2006 19:09:24 org.hibernate.hql.ast.ASTQueryTranslatorFactory <init>
INFO: Using ASTQueryTranslatorFactory
03.12.2006 19:09:24 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {}
03.12.2006 19:09:24 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JPA-QL strict compliance: disabled
03.12.2006 19:09:24 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Second-level cache: enabled
03.12.2006 19:09:24 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query cache: disabled
03.12.2006 19:09:24 org.hibernate.cfg.SettingsFactory createCacheProvider
INFO: Cache provider: org.hibernate.cache.NoCacheProvider
03.12.2006 19:09:24 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Optimize cache for minimal puts: disabled
03.12.2006 19:09:24 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Structured second-level cache entries: disabled
03.12.2006 19:09:24 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Echoing all SQL to stdout
03.12.2006 19:09:24 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Statistics: enabled
03.12.2006 19:09:24 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Deleted entity synthetic identifier rollback: disabled
03.12.2006 19:09:24 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default entity-mode: pojo
03.12.2006 19:09:24 org.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
03.12.2006 19:09:24 org.hibernate.impl.SessionFactoryObjectFactory addInstance
INFO: Not binding factory to JNDI, no JNDI name configured
03.12.2006 19:09:24 org.springframework.orm.hibernate3.HibernateTransactionManager afterPropertiesSet
INFO: Using DataSource [org.springframework.jdbc.datasource.DriverManagerDataSource@c5122f] of Hibernate SessionFactory for HibernateTransactionManager
STARTED de.tutorials.framework
03.12.2006 19:09:24 org.springframework.aop.framework.DefaultAopProxyFactory <clinit>
INFO: CGLIB2 available: proxyTargetClass feature enabled
03.12.2006 19:09:25 org.springframework.jdbc.datasource.JdbcTransactionObjectSupport <clinit>
INFO: JDBC 3.0 Savepoint class is available
Hibernate: insert into person (firstname, lastname) values (?, ?)
Hibernate: select person0_.id as id0_, person0_.firstname as firstname0_, person0_.lastname as lastname0_ from person person0_
de.tutorials.masterdata.domain.Person@1f95165[id=16,firstName=Thomas1165163179187,lastName=Darimont1165163179187]
de.tutorials.masterdata.domain.Person@182a70[id=11,firstName=Thomas1165150986437,lastName=Darimont1165150986437]
de.tutorials.masterdata.domain.Person@9770a3[id=7,firstName=Thomas1165101752781,lastName=Darimont1165101752781]
de.tutorials.masterdata.domain.Person@a09e41[id=18,firstName=Thomas1165167013312,lastName=Darimont1165167013312]
de.tutorials.masterdata.domain.Person@1a3aa2c[id=15,firstName=Thomas1165162076031,lastName=Darimont1165162076031]
de.tutorials.masterdata.domain.Person@21447f[id=10,firstName=Thomas1165147240062,lastName=Darimont1165147240062]
de.tutorials.masterdata.domain.Person@b113c7[id=1,firstName=Thomas,lastName=Darimont]
de.tutorials.masterdata.domain.Person@e3fda4[id=9,firstName=Thomas1165107321828,lastName=Darimont1165107321828]
de.tutorials.masterdata.domain.Person@1cfd3b2[id=5,firstName=Thomas1165097855109,lastName=Darimont1165097855109]
de.tutorials.masterdata.domain.Person@8a2023[id=12,firstName=Thomas1165151129562,lastName=Darimont1165151129562]
de.tutorials.masterdata.domain.Person@37165f[id=20,firstName=Thomas1165169365015,lastName=Darimont1165169365015]
de.tutorials.masterdata.domain.Person@f5d030[id=19,firstName=Thomas1165168919328,lastName=Darimont1165168919328]
de.tutorials.masterdata.domain.Person@1a1ff9[id=14,firstName=Thomas1165160057109,lastName=Darimont1165160057109]
de.tutorials.masterdata.domain.Person@14ed577[id=17,firstName=Thomas1165166139140,lastName=Darimont1165166139140]
de.tutorials.masterdata.domain.Person@19ccba[id=4,firstName=Thomas1165097807796,lastName=Darimont1165097807796]
de.tutorials.masterdata.domain.Person@43da1b[id=13,firstName=Thomas1165159744703,lastName=Darimont1165159744703]
de.tutorials.masterdata.domain.Person@1536eec[id=6,firstName=Thomas1165099883218,lastName=Darimont1165099883218]
de.tutorials.masterdata.domain.Person@64160e[id=8,firstName=Thomas1165102347390,lastName=Darimont1165102347390]
STARTED de.tutorials.masterdata
close

STOPPED de.tutorials.masterdata
03.12.2006 19:09:29 org.springframework.context.support.AbstractApplicationContext doClose
INFO: Closing application context [org.springframework.context.support.ClassPathXmlApplicationContext;hashCode=19461870]
03.12.2006 19:09:29 org.springframework.beans.factory.support.DefaultSingletonBeanRegistry destroySingletons
INFO: Destroying singletons in {org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [personService,personDAO,propertyConfigurer,transactionManager,sessionFactory,dataSource]; root of BeanFactory hierarchy}
03.12.2006 19:09:29 org.springframework.orm.hibernate3.AbstractSessionFactoryBean destroy
INFO: Closing Hibernate SessionFactory
03.12.2006 19:09:29 org.hibernate.impl.SessionFactoryImpl close
INFO: closing

Gruß Tom
 
Zuletzt bearbeitet von einem Moderator:
Hallo!

Hier noch der Activator des de.tutorials.framework Bundles der für die Erzeugung des zentralen ApplicationContexts verantwortlich ist:
Java:
package de.tutorials.framework.osgi;

import java.io.IOException;
import java.net.URL;
import java.util.Set;

import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleEvent;
import org.osgi.framework.BundleListener;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.AbstractXmlApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import de.tutorials.framework.FrameworkLog;
import de.tutorials.framework.IFrameworkExtensionPoints;
import de.tutorials.framework.util.ExtensionRegistryUtil;
import de.tutorials.framework.util.IExtensionRegistryCallback;
import de.tutorials.framework.util.OSGIUtil;

/**
 * The activator class controls the plug-in life cycle
 */
public class Activator extends Plugin implements BundleListener {

	private static final String REGISTERING_0_DEFINED_BY_1_LOCATION_2 = "Registering: {0} defined by: {1} location: {2}";

	// The plug-in ID
	public static final String PLUGIN_ID = "de.tutorials.framework";

	// The shared instance
	private static Activator plugin;

	private AbstractXmlApplicationContext applicationContext;

	/**
	 * The constructor
	 */
	public Activator() {
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
	 */
	@Override
	public void start(final BundleContext context) throws Exception {
		super.start(context);
		Activator.plugin = this;
		this.createApplicationContext();
		context.addBundleListener(this);
	}

	/**
	 * 
	 * @return
	 */
	public ApplicationContext getApplicationContext() {
		return this.applicationContext;
	}

	/**
	 * 
	 */
	private void createApplicationContext() {
		Thread.currentThread().setContextClassLoader(
				Activator.class.getClassLoader());
		this.applicationContext = new ClassPathXmlApplicationContext(this
				.getContributedApplicationContextLocations());
	}

	/**
	 * 
	 * @return
	 */
	public String[] getContributedHibernateMappingLocations() {
		final Set<String> hibernateMappingLocations = ExtensionRegistryUtil
				.queryExtensionRegistryFor(
						IFrameworkExtensionPoints.HibernateMappingLocations.ID,
						this.createUrlFromPathExtractorExtensionCallback());
		return hibernateMappingLocations
				.toArray(new String[hibernateMappingLocations.size()]);
	}

	/**
	 * 
	 */
	public String[] getContributedApplicationContextLocations() {
		final Set<String> applicationContextLocations = ExtensionRegistryUtil
				.<String> queryExtensionRegistryFor(
						IFrameworkExtensionPoints.ApplicationContextsExtension.ID,
						this.createUrlFromPathExtractorExtensionCallback());
		return applicationContextLocations
				.toArray(new String[applicationContextLocations.size()]);
	}

	/**
	 * 
	 * @return
	 */
	private IExtensionRegistryCallback<String> createUrlFromPathExtractorExtensionCallback() {
		return new IExtensionRegistryCallback<String>() {
			public String configureElement(
					final IConfigurationElement configurationElement) {
				final URL bundleUrl = Platform
						.getBundle(
								configurationElement.getDeclaringExtension()
										.getNamespaceIdentifier())
						.getResource(
								configurationElement
										.getAttribute(IFrameworkExtensionPoints.PATH_ATTRIBUTE));
				try {
					FrameworkLog
							.logInfo(
									REGISTERING_0_DEFINED_BY_1_LOCATION_2,
									configurationElement
											.getAttribute(IFrameworkExtensionPoints.PATH_ATTRIBUTE),
									configurationElement
											.getDeclaringExtension()
											.getNamespaceIdentifier(),
									FileLocator.toFileURL(bundleUrl));
					return FileLocator.toFileURL(bundleUrl).toString();
				} catch (final IOException e) {
					e.printStackTrace();
				}
				throw new Error("XXX");
			}
		};
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
	 */
	@Override
	public void stop(final BundleContext context) throws Exception {
		Activator.plugin = null;
		this.applicationContext.close();
		this.applicationContext = null;
		super.stop(context);
		context.removeBundleListener(this);
	}

	/**
	 * Returns the shared instance
	 * 
	 * @return the shared instance
	 */
	public static Activator getDefault() {
		return Activator.plugin;
	}

	/**
	 * 
	 */
	public void bundleChanged(final BundleEvent event) {
		System.out.println(OSGIUtil.getEventNameForBundleEventId(event
				.getType())
				+ " " + event.getBundle().getSymbolicName());
	}

}

Hier das plugin.xml des de.tutorials.framework Bundles:
XML:
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.2"?>
<plugin>
   <extension-point id="de.tutorials.framework.applicationContexts" name="applicationContexts" schema="schema/applicationContexts.exsd"/>
   <extension-point id="de.tutorials.framework.hibernateMappingLocations" name="hibernateMappingLocations" schema="schema/hibernateMappingLocations.exsd"/>
   <extension
         point="de.tutorials.framework.applicationContexts">
      <applicationContext
            path="config/framework-context.xml">
      </applicationContext>
   </extension>


</plugin>

Gruß Tom
 
Zuletzt bearbeitet von einem Moderator:
Hallo!

Mit dem OSGi Bridge Servlet: http://www.eclipse.org/equinox/server/http_in_container.php

Läuft das ganze sogar im Tomcat :D
Code:
Listening for transport dt_socket at address: 8000
03.12.2006 19:13:14 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Programme\Java\jdk1.6.0\bin;.;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;e:\sapdb\programs\bin;e:\sapdb\pro
mme\MySQL\MySQL Server 4.1\bin;F:\oracle\product\10.1.0\Db_1\BIN;C:\Programme\Java\jdk1.6.0\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Programme\ATI Technologies\ATI Control Panel;E:\ant\1.6.5\apache-ant-1.6.5\bin;C:\Programme\Microsoft SQL
\bin;C:\Python24;C:\Programme\Subversion\bin;C:\Programme\QuickTime\QTSystem\;C:\Programme\Gemeinsame Dateien\eDrawings2006\;C:\Programme\cvsnt;E:\maven\2.0.4\maven-2.0.4\bin;E:\jikes\bin;C:\Programme\MySQL\MySQL Server 5.0\bin;C:\Programme\Microsoft SQL Server
T\Framework\v2.0.50727;E:\SAP\NW\JP1\SYS\exe\run;E:\SAP\NW\JP1\SYS\exe\run\sapjvm_5\bin;e:\Subversion\bin;E:\jwsdp\jwsdp-shared\bin;C:\Programme\Microsoft Visual Studio\Common\Tools\WinNT;C:\Programme\Microsoft Visual Studio\Common\MSDev98\Bin;C:\Programme\Micr
gramme\Microsoft Visual Studio\VC98\bin;C:\Programme\OpenVPN\bin
03.12.2006 19:13:14 org.apache.coyote.http11.Http11BaseProtocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
03.12.2006 19:13:14 org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 671 ms
03.12.2006 19:13:14 org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
03.12.2006 19:13:14 org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/5.5.20
03.12.2006 19:13:14 org.apache.catalina.core.StandardHost start
INFO: XML validation disabled
[DevLoader] Starting DevLoader
[DevLoader] projectdir=E:\eclipse\3.2.1\eclipse\workspace\de.tutorials.training.spring.web\root
[DevLoader] added file:/E:/eclipse/3.2.1/eclipse/workspace/de.tutorials.training.spring.web/root/WEB-INF/classes/
[DevLoader] added file:/C:/Programme/Java/jdk1.5.0_06/jre/lib/rt.jar
[DevLoader] added file:/C:/Programme/Java/jdk1.5.0_06/jre/lib/jsse.jar
[DevLoader] added file:/C:/Programme/Java/jdk1.5.0_06/jre/lib/jce.jar
[DevLoader] added file:/C:/Programme/Java/jdk1.5.0_06/jre/lib/charsets.jar
[DevLoader] added file:/C:/Programme/Java/jdk1.5.0_06/jre/lib/ext/dnsns.jar
[DevLoader] added file:/C:/Programme/Java/jdk1.5.0_06/jre/lib/ext/localedata.jar
[DevLoader] added file:/C:/Programme/Java/jdk1.5.0_06/jre/lib/ext/sunjce_provider.jar
[DevLoader] added file:/C:/Programme/Java/jdk1.5.0_06/jre/lib/ext/sunpkcs11.jar
[DevLoader] added file:/E:/eclipse/3.2.1/eclipse/workspace/de.tutorials.training.spring.web/root/WEB-INF/lib/cglib-nodep-2.1_3.jar
[DevLoader] added file:/E:/eclipse/3.2.1/eclipse/workspace/de.tutorials.training.spring.web/root/WEB-INF/lib/commons-dbcp.jar
[DevLoader] added file:/E:/eclipse/3.2.1/eclipse/workspace/de.tutorials.training.spring.web/root/WEB-INF/lib/commons-logging.jar
[DevLoader] added file:/E:/eclipse/3.2.1/eclipse/workspace/de.tutorials.training.spring.web/root/WEB-INF/lib/commons-pool.jar
[DevLoader] added file:/E:/eclipse/3.2.1/eclipse/workspace/de.tutorials.training.spring.web/root/WEB-INF/lib/dom4j-1.6.1.jar
[DevLoader] added file:/E:/eclipse/3.2.1/eclipse/workspace/de.tutorials.training.spring.web/root/WEB-INF/lib/mysql-connector-java-3.1.13-bin.jar
[DevLoader] added file:/E:/eclipse/3.2.1/eclipse/workspace/de.tutorials.training.spring.web/root/WEB-INF/lib/spring.jar
[DevLoader] added file:/E:/eclipse/3.2.1/eclipse/workspace/de.tutorials.training.spring.web/root/WEB-INF/lib/commons-lang.jar
[DevLoader] JSPCompiler Classpath = E:\eclipse\3.2.1\eclipse\workspace\de.tutorials.training.spring.web\root\WEB-INF\classes;C:\Programme\Java\jdk1.5.0_06\jre\lib\rt.jar;C:\Programme\Java\jdk1.5.0_06\jre\lib\jsse.jar;C:\Programme\Java\jdk1.5.0_06\jre\lib\jce.ja
\charsets.jar;C:\Programme\Java\jdk1.5.0_06\jre\lib\ext\dnsns.jar;C:\Programme\Java\jdk1.5.0_06\jre\lib\ext\localedata.jar;C:\Programme\Java\jdk1.5.0_06\jre\lib\ext\sunjce_provider.jar;C:\Programme\Java\jdk1.5.0_06\jre\lib\ext\sunpkcs11.jar;E:\eclipse\3.2.1\ecl
ring.web\root\WEB-INF\lib\cglib-nodep-2.1_3.jar;E:\eclipse\3.2.1\eclipse\workspace\de.tutorials.training.spring.web\root\WEB-INF\lib\commons-dbcp.jar;E:\eclipse\3.2.1\eclipse\workspace\de.tutorials.training.spring.web\root\WEB-INF\lib\commons-logging.jar;E:\ecl
ls.training.spring.web\root\WEB-INF\lib\commons-pool.jar;E:\eclipse\3.2.1\eclipse\workspace\de.tutorials.training.spring.web\root\WEB-INF\lib\dom4j-1.6.1.jar;E:\eclipse\3.2.1\eclipse\workspace\de.tutorials.training.spring.web\root\WEB-INF\lib\mysql-connector-ja
pse\workspace\de.tutorials.training.spring.web\root\WEB-INF\lib\spring.jar;E:\eclipse\3.2.1\eclipse\workspace\de.tutorials.training.spring.web\root\WEB-INF\lib\commons-lang.jar;E:/eclipse/3.2.1/eclipse/workspace/de.tutorials.training.spring.web/root/WEB-INF/cla
e/de.tutorials.training.spring.web/root/WEB-INF/lib/cglib-nodep-2.1_3.jar;E:/eclipse/3.2.1/eclipse/workspace/de.tutorials.training.spring.web/root/WEB-INF/lib/commons-dbcp.jar;E:/eclipse/3.2.1/eclipse/workspace/de.tutorials.training.spring.web/root/WEB-INF/lib/
se/workspace/de.tutorials.training.spring.web/root/WEB-INF/lib/commons-logging.jar;E:/eclipse/3.2.1/eclipse/workspace/de.tutorials.training.spring.web/root/WEB-INF/lib/commons-pool.jar;E:/eclipse/3.2.1/eclipse/workspace/de.tutorials.training.spring.web/root/WEB
.1/eclipse/workspace/de.tutorials.training.spring.web/root/WEB-INF/lib/jstl.jar;E:/eclipse/3.2.1/eclipse/workspace/de.tutorials.training.spring.web/root/WEB-INF/lib/mysql-connector-java-3.1.13-bin.jar;E:/eclipse/3.2.1/eclipse/workspace/de.tutorials.training.spr
eclipse/3.2.1/eclipse/workspace/de.tutorials.training.spring.web/root/WEB-INF/lib/standard.jar;E:/tomcat/5.5.20/apache-tomcat-5.5.20/shared/classes/;E:/tomcat/5.5.20/apache-tomcat-5.5.20/common/classes/;E:/tomcat/5.5.20/apache-tomcat-5.5.20/common/i18n/tomcat-i
at-5.5.20/common/i18n/tomcat-i18n-es.jar;E:/tomcat/5.5.20/apache-tomcat-5.5.20/common/i18n/tomcat-i18n-fr.jar;E:/tomcat/5.5.20/apache-tomcat-5.5.20/common/i18n/tomcat-i18n-ja.jar;E:/tomcat/5.5.20/apache-tomcat-5.5.20/common/lib/commons-el.jar;E:/tomcat/5.5.20/a
ompiler-jdt.jar;E:/tomcat/5.5.20/apache-tomcat-5.5.20/common/lib/jasper-compiler.jar;E:/tomcat/5.5.20/apache-tomcat-5.5.20/common/lib/jasper-runtime.jar;E:/tomcat/5.5.20/apache-tomcat-5.5.20/common/lib/jsp-api.jar;E:/tomcat/5.5.20/apache-tomcat-5.5.20/common/li
.20/apache-tomcat-5.5.20/common/lib/naming-factory.jar;E:/tomcat/5.5.20/apache-tomcat-5.5.20/common/lib/naming-resources.jar;E:/tomcat/5.5.20/apache-tomcat-5.5.20/common/lib/servlet-api.jar;C:/Programme/Java/jdk1.6.0/lib/tools.jar;E:/tomcat/5.5.20/apache-tomcat
Java/jdk1.6.0/jre/lib/ext/dnsns.jar;C:/Programme/Java/jdk1.6.0/jre/lib/ext/j3daudio.jar;C:/Programme/Java/jdk1.6.0/jre/lib/ext/j3dcore.jar;C:/Programme/Java/jdk1.6.0/jre/lib/ext/j3dutils.jar;C:/Programme/Java/jdk1.6.0/jre/lib/ext/jsk-policy.jar;C:/Programme/Jav
:/Programme/Java/jdk1.6.0/jre/lib/ext/sunjce_provider.jar;C:/Programme/Java/jdk1.6.0/jre/lib/ext/sunmscapi.jar;C:/Programme/Java/jdk1.6.0/jre/lib/ext/sunpkcs11.jar;C:/Programme/Java/jdk1.6.0/jre/lib/ext/vecmath.jar;
03.12.2006 19:13:14 org.springframework.web.context.ContextLoader initWebApplicationContext
INFO: Root WebApplicationContext: initialization started
03.12.2006 19:13:15 org.springframework.core.CollectionFactory <clinit>
INFO: JDK 1.4+ collections available
03.12.2006 19:13:15 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext.xml]
03.12.2006 19:13:15 org.springframework.context.support.AbstractRefreshableApplicationContext refreshBeanFactory
INFO: Bean factory for application context [Root WebApplicationContext]: org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [propertyConfigurer,dataSource,transactionManager,jdbcTemplate,customerDAO,customerAdmnistrationServiceT
ot of BeanFactory hierarchy
03.12.2006 19:13:15 org.springframework.context.support.AbstractApplicationContext refresh
INFO: 7 beans defined in application context [Root WebApplicationContext]
03.12.2006 19:13:15 org.springframework.core.io.support.PropertiesLoaderSupport loadProperties
INFO: Loading properties file from ServletContext resource [/WEB-INF/jdbc.properties]
03.12.2006 19:13:15 org.springframework.context.support.AbstractApplicationContext initMessageSource
INFO: Unable to locate MessageSource with name 'messageSource': using default [org.springframework.context.support.DelegatingMessageSource@8deb8a]
03.12.2006 19:13:15 org.springframework.context.support.AbstractApplicationContext initApplicationEventMulticaster
INFO: Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticaster': using default [org.springframework.context.event.SimpleApplicationEventMulticaster@bd93cd]
03.12.2006 19:13:15 org.springframework.ui.context.support.UiApplicationContextUtils initThemeSource
INFO: Unable to locate ThemeSource with name 'themeSource': using default [org.springframework.ui.context.support.ResourceBundleThemeSource@ad7d80]
03.12.2006 19:13:15 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in factory [org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [propertyConfigurer,dataSource,transactionManager,jdbcTemplate,customerDAO,customerAdmnistrationServiceTarget,customerAdmnistratio
y]
03.12.2006 19:13:15 org.springframework.aop.framework.DefaultAopProxyFactory <clinit>
INFO: CGLIB2 available: proxyTargetClass feature enabled
03.12.2006 19:13:15 org.springframework.web.context.ContextLoader initWebApplicationContext
INFO: Using context class [org.springframework.web.context.support.XmlWebApplicationContext] for root WebApplicationContext
03.12.2006 19:13:15 org.springframework.web.context.ContextLoader initWebApplicationContext
INFO: Root WebApplicationContext: initialization completed in 688 ms
03.12.2006 19:13:15 org.springframework.web.servlet.HttpServletBean init
INFO: Initializing servlet 'customerAdministration'
03.12.2006 19:13:15 org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: FrameworkServlet 'customerAdministration': initialization started
03.12.2006 19:13:15 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/customerAdministration-servlet.xml]
03.12.2006 19:13:15 org.springframework.context.support.AbstractRefreshableApplicationContext refreshBeanFactory
INFO: Bean factory for application context [WebApplicationContext for namespace 'customerAdministration-servlet']: org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [viewResolver,urlMapping,customerControllerResolver,customerAd
ringframework.beans.factory.support.DefaultListableBeanFactory defining beans [propertyConfigurer,dataSource,transactionManager,jdbcTemplate,customerDAO,customerAdmnistrationServiceTarget,customerAdmnistrationService]; root of BeanFactory hierarchy
03.12.2006 19:13:15 org.springframework.context.support.AbstractApplicationContext refresh
INFO: 4 beans defined in application context [WebApplicationContext for namespace 'customerAdministration-servlet']
03.12.2006 19:13:15 org.springframework.context.support.AbstractApplicationContext initMessageSource
INFO: Unable to locate MessageSource with name 'messageSource': using default [org.springframework.context.support.DelegatingMessageSource@166aab6]
03.12.2006 19:13:15 org.springframework.context.support.AbstractApplicationContext initApplicationEventMulticaster
INFO: Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticaster': using default [org.springframework.context.event.SimpleApplicationEventMulticaster@151ac10]
03.12.2006 19:13:15 org.springframework.ui.context.support.UiApplicationContextUtils initThemeSource
INFO: Unable to locate ThemeSource with name 'themeSource': using default [org.springframework.ui.context.support.DelegatingThemeSource@9f3e95]
03.12.2006 19:13:15 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in factory [org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [viewResolver,urlMapping,customerControllerResolver,customerAdministrationController]; parent: org.springframework.beans.factory.s
ing beans [propertyConfigurer,dataSource,transactionManager,jdbcTemplate,customerDAO,customerAdmnistrationServiceTarget,customerAdmnistrationService]; root of BeanFactory hierarchy]
03.12.2006 19:13:15 org.springframework.web.servlet.FrameworkServlet initWebApplicationContext
INFO: Using context class [org.springframework.web.context.support.XmlWebApplicationContext] for servlet 'customerAdministration'
03.12.2006 19:13:15 org.springframework.web.servlet.DispatcherServlet initMultipartResolver
INFO: Unable to locate MultipartResolver with name 'multipartResolver': no multipart request handling provided
03.12.2006 19:13:15 org.springframework.web.servlet.DispatcherServlet initLocaleResolver
INFO: Unable to locate LocaleResolver with name 'localeResolver': using default [org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver@113e8f3]
03.12.2006 19:13:15 org.springframework.web.servlet.DispatcherServlet initThemeResolver
INFO: Unable to locate ThemeResolver with name 'themeResolver': using default [org.springframework.web.servlet.theme.FixedThemeResolver@14124d6]
03.12.2006 19:13:15 org.springframework.web.servlet.DispatcherServlet initHandlerAdapters
INFO: No HandlerAdapters found in servlet 'customerAdministration': using default
03.12.2006 19:13:15 org.springframework.web.servlet.DispatcherServlet initRequestToViewNameTranslator
INFO: Unable to locate RequestToViewNameTranslator with name 'viewNameTranslator': using default [org.springframework.web.servlet.view.DefaultRequestToViewNameTranslator@16fdcc1]
03.12.2006 19:13:15 org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: FrameworkServlet 'customerAdministration': initialization completed in 172 ms
03.12.2006 19:13:15 org.springframework.web.servlet.HttpServletBean init
INFO: Servlet 'customerAdministration' configured successfully
[DevLoader] Starting DevLoader
[DevLoader] projectdir=E:\eclipse\3.3M3\eclipse\workspace\de.tutorials.web.upload.example\WebContent
[DevLoader] added file:/E:/eclipse/3.3M3/eclipse/workspace/de.tutorials.web.upload.example/WebContent/WEB-INF/classes/
[DevLoader] added file:/E:/eclipse/3.3M3/eclipse/workspace/de.tutorials.web.upload.example/WebContent/WEB-INF/lib/commons-io.jar
[DevLoader] added file:/E:/eclipse/3.3M3/eclipse/workspace/de.tutorials.web.upload.example/WebContent/WEB-INF/lib/commons-fileupload-1.1.1.jar
[DevLoader] JSPCompiler Classpath = E:\eclipse\3.3M3\eclipse\workspace\de.tutorials.web.upload.example\WebContent\WEB-INF\classes;E:\eclipse\3.3M3\eclipse\workspace\de.tutorials.web.upload.example\WebContent\WEB-INF\lib\commons-io.jar;E:\eclipse\3.3M3\eclipse\w
e\WebContent\WEB-INF\lib\commons-fileupload-1.1.1.jar;E:/eclipse/3.3M3/eclipse/workspace/de.tutorials.web.upload.example/WebContent/WEB-INF/classes/;E:/eclipse/3.3M3/eclipse/workspace/de.tutorials.web.upload.example/WebContent/WEB-INF/lib/commons-fileupload-1.1
ce/de.tutorials.web.upload.example/WebContent/WEB-INF/lib/commons-io.jar;E:/tomcat/5.5.20/apache-tomcat-5.5.20/shared/classes/;E:/tomcat/5.5.20/apache-tomcat-5.5.20/common/classes/;E:/tomcat/5.5.20/apache-tomcat-5.5.20/common/i18n/tomcat-i18n-en.jar;E:/tomcat/5
tomcat-i18n-es.jar;E:/tomcat/5.5.20/apache-tomcat-5.5.20/common/i18n/tomcat-i18n-fr.jar;E:/tomcat/5.5.20/apache-tomcat-5.5.20/common/i18n/tomcat-i18n-ja.jar;E:/tomcat/5.5.20/apache-tomcat-5.5.20/common/lib/commons-el.jar;E:/tomcat/5.5.20/apache-tomcat-5.5.20/co
cat/5.5.20/apache-tomcat-5.5.20/common/lib/jasper-compiler.jar;E:/tomcat/5.5.20/apache-tomcat-5.5.20/common/lib/jasper-runtime.jar;E:/tomcat/5.5.20/apache-tomcat-5.5.20/common/lib/jsp-api.jar;E:/tomcat/5.5.20/apache-tomcat-5.5.20/common/lib/naming-factory-dbcp.
20/common/lib/naming-factory.jar;E:/tomcat/5.5.20/apache-tomcat-5.5.20/common/lib/naming-resources.jar;E:/tomcat/5.5.20/apache-tomcat-5.5.20/common/lib/servlet-api.jar;C:/Programme/Java/jdk1.6.0/lib/tools.jar;E:/tomcat/5.5.20/apache-tomcat-5.5.20/bin/bootstrap.
ext/dnsns.jar;C:/Programme/Java/jdk1.6.0/jre/lib/ext/j3daudio.jar;C:/Programme/Java/jdk1.6.0/jre/lib/ext/j3dcore.jar;C:/Programme/Java/jdk1.6.0/jre/lib/ext/j3dutils.jar;C:/Programme/Java/jdk1.6.0/jre/lib/ext/jsk-policy.jar;C:/Programme/Java/jdk1.6.0/jre/lib/ext
6.0/jre/lib/ext/sunjce_provider.jar;C:/Programme/Java/jdk1.6.0/jre/lib/ext/sunmscapi.jar;C:/Programme/Java/jdk1.6.0/jre/lib/ext/sunpkcs11.jar;C:/Programme/Java/jdk1.6.0/jre/lib/ext/vecmath.jar;
03.12.2006 19:13:16 org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive bridge.war

osgi> !SESSION 2006-12-03 19:13:17.078 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.6.0-rc
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=de_DE
Command-line arguments:  -console -consoleLog

!ENTRY org.eclipse.osgi 4 0 2006-12-03 19:13:17.078
!MESSAGE Bundle javax.servlet not found.

!ENTRY org.eclipse.osgi 4 0 2006-12-03 19:13:17.093
!MESSAGE Bundle org.eclipse.equinox.servletbridge not found.
03.12.2006 19:13:17 org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive countries.war
03.12.2006 19:13:17 org.springframework.web.context.ContextLoader initWebApplicationContext
INFO: Root WebApplicationContext: initialization started
03.12.2006 19:13:17 org.springframework.core.CollectionFactory <clinit>
INFO: JDK 1.4+ collections available
03.12.2006 19:13:17 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext.xml]
03.12.2006 19:13:18 org.springframework.context.support.AbstractRefreshableApplicationContext refreshBeanFactory
INFO: Bean factory for application context [Root WebApplicationContext]: org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [messageSource,countryService]; root of BeanFactory hierarchy
03.12.2006 19:13:18 org.springframework.context.support.AbstractApplicationContext refresh
INFO: 2 beans defined in application context [Root WebApplicationContext]
03.12.2006 19:13:18 org.springframework.context.support.AbstractApplicationContext initMessageSource
INFO: Using MessageSource [org.springframework.context.support.ResourceBundleMessageSource: basenames=[messages]]
03.12.2006 19:13:18 org.springframework.context.support.AbstractApplicationContext initApplicationEventMulticaster
INFO: Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticaster': using default [org.springframework.context.event.SimpleApplicationEventMulticaster@2bae98]
03.12.2006 19:13:18 org.springframework.ui.context.support.UiApplicationContextUtils initThemeSource
INFO: Unable to locate ThemeSource with name 'themeSource': using default [org.springframework.ui.context.support.ResourceBundleThemeSource@117ee94]
03.12.2006 19:13:18 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in factory [org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [messageSource,countryService]; root of BeanFactory hierarchy]
03.12.2006 19:13:18 org.springframework.web.context.ContextLoader initWebApplicationContext
INFO: Using context class [org.springframework.web.context.support.XmlWebApplicationContext] for root WebApplicationContext
03.12.2006 19:13:18 org.springframework.web.context.ContextLoader initWebApplicationContext
INFO: Root WebApplicationContext: initialization completed in 453 ms
03.12.2006 19:13:18 org.springframework.web.servlet.HttpServletBean init
INFO: Initializing servlet 'countries'
03.12.2006 19:13:18 org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: FrameworkServlet 'countries': initialization started
03.12.2006 19:13:18 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/countries-servlet.xml]
03.12.2006 19:13:18 org.springframework.context.support.AbstractRefreshableApplicationContext refreshBeanFactory
INFO: Bean factory for application context [WebApplicationContext for namespace 'countries-servlet']: org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [viewResolver,localeResolver,themeResolver,urlMapping,localeChangeIntercept
ler,countriesController]; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [messageSource,countryService]; root of BeanFactory hierarchy
03.12.2006 19:13:18 org.springframework.context.support.AbstractApplicationContext refresh
INFO: 8 beans defined in application context [WebApplicationContext for namespace 'countries-servlet']
03.12.2006 19:13:18 org.springframework.context.support.AbstractApplicationContext initMessageSource
INFO: Unable to locate MessageSource with name 'messageSource': using default [org.springframework.context.support.DelegatingMessageSource@8af0b0]
03.12.2006 19:13:18 org.springframework.context.support.AbstractApplicationContext initApplicationEventMulticaster
INFO: Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticaster': using default [org.springframework.context.event.SimpleApplicationEventMulticaster@1bfeb82]
03.12.2006 19:13:18 org.springframework.ui.context.support.UiApplicationContextUtils initThemeSource
INFO: Unable to locate ThemeSource with name 'themeSource': using default [org.springframework.ui.context.support.DelegatingThemeSource@fed6f7]
03.12.2006 19:13:18 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in factory [org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [viewResolver,localeResolver,themeResolver,urlMapping,localeChangeInterceptor,themeChangeInterceptor,errorsController,countriesCon
eans.factory.support.DefaultListableBeanFactory defining beans [messageSource,countryService]; root of BeanFactory hierarchy]
03.12.2006 19:13:18 org.springframework.web.servlet.FrameworkServlet initWebApplicationContext
INFO: Using context class [org.springframework.web.context.support.XmlWebApplicationContext] for servlet 'countries'
03.12.2006 19:13:18 org.springframework.web.servlet.DispatcherServlet initMultipartResolver
INFO: Unable to locate MultipartResolver with name 'multipartResolver': no multipart request handling provided
03.12.2006 19:13:18 org.springframework.web.servlet.DispatcherServlet initLocaleResolver
INFO: Using LocaleResolver [org.springframework.web.servlet.i18n.CookieLocaleResolver@1c8f59c]
03.12.2006 19:13:18 org.springframework.web.servlet.DispatcherServlet initThemeResolver
INFO: Using ThemeResolver [org.springframework.web.servlet.theme.CookieThemeResolver@74f160]
03.12.2006 19:13:18 org.springframework.web.servlet.DispatcherServlet initHandlerAdapters
INFO: No HandlerAdapters found in servlet 'countries': using default
03.12.2006 19:13:18 org.springframework.web.servlet.DispatcherServlet initRequestToViewNameTranslator
INFO: Unable to locate RequestToViewNameTranslator with name 'viewNameTranslator': using default [org.springframework.web.servlet.view.DefaultRequestToViewNameTranslator@14300c8]
03.12.2006 19:13:18 org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: FrameworkServlet 'countries': initialization completed in 265 ms
03.12.2006 19:13:18 org.springframework.web.servlet.HttpServletBean init
INFO: Servlet 'countries' configured successfully
03.12.2006 19:13:19 org.apache.coyote.http11.Http11BaseProtocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
03.12.2006 19:13:19 org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
03.12.2006 19:13:19 org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/31  config=null
03.12.2006 19:13:19 org.apache.catalina.storeconfig.StoreLoader load
INFO: Find registry server-registry.xml at classpath resource
03.12.2006 19:13:19 org.apache.catalina.startup.Catalina start
INFO: Server startup in 4969 ms


osgi> start de.tutorials.masterdata

!ENTRY de.tutorials.framework 2006-12-03 19:13:29.906
!MESSAGE Registering: config/framework-context.xml defined by: de.tutorials.framework location: file:/E:/tomcat/5.5.20/apache-tomcat-5.5.20/work/Catalina/localhost/bridge/eclipse/configuration/org.eclipse.osgi/bundles/5/1/.cp/config/framework-context.xml

!ENTRY de.tutorials.framework 2006-12-03 19:13:29.921
!MESSAGE Registering: config/masterdata-context.xml defined by: de.tutorials.masterdata location: file:/E:/tomcat/5.5.20/apache-tomcat-5.5.20/work/Catalina/localhost/bridge/eclipse/configuration/org.eclipse.osgi/bundles/7/1/.cp/config/masterdata-context.xml

!ENTRY de.tutorials.framework 2006-12-03 19:13:32.328
!MESSAGE Registering: /de/tutorials/masterdata/domain defined by: de.tutorials.masterdata location: file:/E:/tomcat/5.5.20/apache-tomcat-5.5.20/work/Catalina/localhost/bridge/eclipse/configuration/org.eclipse.osgi/bundles/7/1/.cp/de/tutorials/masterdata/domain/
STARTED de.tutorials.framework
Hibernate: insert into person (firstname, lastname) values (?, ?)
Hibernate: select person0_.id as id0_, person0_.firstname as firstname0_, person0_.lastname as lastname0_ from person person0_
de.tutorials.masterdata.domain.Person@192d8d6[id=16,firstName=Thomas1165163179187,lastName=Darimont1165163179187]
de.tutorials.masterdata.domain.Person@1a13f3d[id=11,firstName=Thomas1165150986437,lastName=Darimont1165150986437]
de.tutorials.masterdata.domain.Person@1a4536d[id=7,firstName=Thomas1165101752781,lastName=Darimont1165101752781]
de.tutorials.masterdata.domain.Person@e31ec5[id=18,firstName=Thomas1165167013312,lastName=Darimont1165167013312]
de.tutorials.masterdata.domain.Person@1095c6c[id=15,firstName=Thomas1165162076031,lastName=Darimont1165162076031]
de.tutorials.masterdata.domain.Person@6abd0b[id=10,firstName=Thomas1165147240062,lastName=Darimont1165147240062]
de.tutorials.masterdata.domain.Person@8920dc[id=1,firstName=Thomas,lastName=Darimont]
de.tutorials.masterdata.domain.Person@1aa5f9b[id=9,firstName=Thomas1165107321828,lastName=Darimont1165107321828]
de.tutorials.masterdata.domain.Person@d68b39[id=5,firstName=Thomas1165097855109,lastName=Darimont1165097855109]
de.tutorials.masterdata.domain.Person@13ef605[id=12,firstName=Thomas1165151129562,lastName=Darimont1165151129562]
de.tutorials.masterdata.domain.Person@3525a2[id=20,firstName=Thomas1165169365015,lastName=Darimont1165169365015]
de.tutorials.masterdata.domain.Person@f94934[id=19,firstName=Thomas1165168919328,lastName=Darimont1165168919328]
de.tutorials.masterdata.domain.Person@19cd6b6[id=14,firstName=Thomas1165160057109,lastName=Darimont1165160057109]
de.tutorials.masterdata.domain.Person@1d9d7be[id=17,firstName=Thomas1165166139140,lastName=Darimont1165166139140]
de.tutorials.masterdata.domain.Person@1eb84f[id=4,firstName=Thomas1165097807796,lastName=Darimont1165097807796]
de.tutorials.masterdata.domain.Person@89fe65[id=13,firstName=Thomas1165159744703,lastName=Darimont1165159744703]
de.tutorials.masterdata.domain.Person@14e54d8[id=6,firstName=Thomas1165099883218,lastName=Darimont1165099883218]
de.tutorials.masterdata.domain.Person@139cf9c[id=21,firstName=Thomas1165169613609,lastName=Darimont1165169613609]
de.tutorials.masterdata.domain.Person@1613fe7[id=8,firstName=Thomas1165102347390,lastName=Darimont1165102347390]

osgi> STARTED de.tutorials.masterdata


osgi> ss

Framework is launched.

id      State       Bundle
0       ACTIVE      system.bundle_3.2.1.R32x_v20060919
                    Fragments=34
1       ACTIVE      org.eclipse.equinox.common_3.3.0.v20061023
2       ACTIVE      org.eclipse.update.configurator_3.2.1.v20092006
3       ACTIVE      org.eclipse.equinox.http.servletbridge_1.0.0.200610120150
4       ACTIVE      org.eclipse.equinox.http.registry_1.0.0.200610120150
5       ACTIVE      de.tutorials.framework_1.0.0
6       RESOLVED    de.tutorials.framework.libraries_1.0.0
7       ACTIVE      de.tutorials.masterdata_1.0.0
8       RESOLVED    org.apache.xerces_2.8.0.v200606131651
9       RESOLVED    org.eclipse.core.contenttype_3.2.100.v20060808
10      ACTIVE      org.eclipse.core.jobs_3.3.0.v20061027
11      ACTIVE      org.eclipse.core.runtime_3.2.100.v20061030
12      ACTIVE      org.eclipse.core.runtime.compatibility.auth_3.2.0.v20061030
13      RESOLVED    org.eclipse.core.runtime.compatibility.registry_3.2.100.v20060828
                    Master=16
14      ACTIVE      org.eclipse.equinox.http.servlet_1.0.0.200610120150
15      ACTIVE      org.eclipse.equinox.preferences_3.2.100.v20060918
16      ACTIVE      org.eclipse.equinox.registry_3.2.1.R32x_v20060814
                    Fragments=13
25      ACTIVE      org.eclipse.core.runtime.compatibility_3.1.100.v20060603
33      RESOLVED    org.eclipse.equinox.servlet.api_1.0.0.v20060601
34      RESOLVED    org.eclipse.equinox.servletbridge.extensionbundle_1.0.0
                    Master=0
35      RESOLVED    org.eclipse.osgi.services_3.1.100.v20060601

osgi>

Gruß Tom
 
Hallo,

zunächst erstmal vielen Dank für dieses Tutorial!

Ich habe bei einer Anwendung an der ich gerade mit entwickel auch Spring und Hibernate im Einsatz. Wir verwende jedoch nicht die XML-Deklarationen, sondern eine zum Teil auf XML und zum anderen Teil auf Java basierte Definition. Die Java basierte ist "Annotation-Driven" und wird über @Configuration und mit dem entsprechenden ConfigurationPostProcessor ausgeführt und alle Beans registriert / initialisiert.

Ich habe jedoch zur Zeit das Problem, dass meine RCP-Anwendung die sessionFactory nicht richtig zu schließen scheint und die Anwendung bleibt bei der Beendung hängen.

Hier ein kleiner Auszug aus den Debugging-Informationen:
PHP:
2008-09-26 13:48:05,640 DEBUG Retrieved dependent beans for bean 'sessionFactory': [transactionManager, userService2, navigationService] - org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:447)
2008-09-26 13:48:05,640 DEBUG Retrieved dependent beans for bean 'transactionManager': [(inner bean)] - org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:447)
2008-09-26 13:48:05,640 DEBUG Retrieved dependent beans for bean '(inner bean)': [(inner bean), org.springframework.transaction.config.internalTransactionAdvisor] - org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:447)
2008-09-26 13:48:05,656 DEBUG Invoking destroy() on bean with name 'sessionFactory' - org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:148)
2008-09-26 13:48:05,656 INFO  Closing Hibernate SessionFactory - org.springframework.orm.hibernate3.AbstractSessionFactoryBean.destroy(AbstractSessionFactoryBean.java:246)
2008-09-26 13:48:05,656 INFO  closing - org.hibernate.impl.SessionFactoryImpl.close(SessionFactoryImpl.java:769)
2008-09-26 13:48:05,656 DEBUG Invoking destroy method 'close' on bean with name 'navigationDataSource' - org.springframework.beans.factory.support.DisposableBeanAdapter.invokeCustomDestroyMethod(DisposableBeanAdapter.java:203)

navigationDataSource ist eine ComboPooledDataSource von dem OpenSource-Projekt c3p0.

Hätten Sie da eine Idee, woran das liegen könnte?

Vielen Dank im Voraus

EDIT:

Wenn ich die ComboPooledDataSource-Bean-Definition aus der XML-Datei heraus nehme und anstatt dessen nurnoch eine bereits davor vorhandene verwende ist die letzte Zeile folgende:
PHP:
2008-09-26 14:08:32,609 INFO  closing - org.hibernate.impl.SessionFactoryImpl.close(SessionFactoryImpl.java:769)

EDIT 2:

Oh man - ich hab den Fehler gefunden. Die Anwendung kann zum einen eine Portal-Navigationsstruktur auslesen und zum anderen eine Datenbank-Navigationsstruktur. Es werden beim Portal Temp-Files angelegt, die wir beim Beenden der Anwendung löschen. Genau das werden sie bei der Navigationsstruktur nicht und daran lag das Problem!

Vielen Dank! :-)
 
Zuletzt bearbeitet:
Hallo,

Also das Tutorial sieht super aus und ich beschäftige mich derzeit mit einem Projekt, welches genau diese spezifikationen erfüllt.

Die Frage die ich mir stelle ist: wie compiliere und starte ich deinen sample source code.. sehe hier keine maven einstellungen also compilierst du wahrscheinlich mit eclipse.. hier bekomme ich aber beim importieren einige fehlermeldungen .

Hast du zu deinem project auch ein maven config file?

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.AbstractXmlApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

findet er im eclipse nicht.

Kannst du mir eventuell per private message deine komplette ordnerstruktur inklusive der libraries die ja nicht in dem zip package enthalten sind schicken?

das wäre wirklich sehr toll!

Weiters wäre das Beispiel mit dem OSGI Bridge Servlet sehr interessant.


mfg Mysti
 
Zuletzt bearbeitet:
Zurück