From 04c8e8c87ae3c1a49e5920ae9e5208f7c07c20a6 Mon Sep 17 00:00:00 2001 From: Brett Meyer Date: Tue, 21 May 2013 14:47:26 -0400 Subject: [PATCH] HHH-8112 OSGi quickstart tutorial projects --- .../tutorials/osgi/datasource-h2.xml | 21 ++++ .../tutorials/osgi/managed-jpa/features.xml | 72 ++++++++++++ .../tutorials/osgi/managed-jpa/pom.xml | 63 ++++++++++ .../hibernate/osgitest/DataPointService.java | 37 ++++++ .../osgitest/DataPointServiceImpl.java | 58 +++++++++ .../osgitest/command/AddCommand.java | 44 +++++++ .../osgitest/command/DeleteAllCommand.java | 37 ++++++ .../osgitest/command/GetAllCommand.java | 43 +++++++ .../hibernate/osgitest/entity/DataPoint.java | 53 +++++++++ .../main/resources/META-INF/persistence.xml | 15 +++ .../OSGI-INF/blueprint/blueprint.xml | 50 ++++++++ .../tutorials/osgi/unmanaged-jpa/features.xml | 42 +++++++ .../tutorials/osgi/unmanaged-jpa/pom.xml | 74 ++++++++++++ .../hibernate/osgitest/DataPointService.java | 41 +++++++ .../osgitest/DataPointServiceImpl.java | 76 ++++++++++++ .../org/hibernate/osgitest/HibernateUtil.java | 57 +++++++++ .../osgitest/command/AddCommand.java | 44 +++++++ .../osgitest/command/DeleteAllCommand.java | 37 ++++++ .../osgitest/command/GetAllCommand.java | 43 +++++++ .../osgitest/command/UpdateCommand.java | 47 ++++++++ .../hibernate/osgitest/entity/DataPoint.java | 53 +++++++++ .../main/resources/META-INF/persistence.xml | 18 +++ .../OSGI-INF/blueprint/blueprint.xml | 50 ++++++++ .../osgi/unmanaged-native/features.xml | 72 ++++++++++++ .../tutorials/osgi/unmanaged-native/pom.xml | 82 +++++++++++++ .../hibernate/osgitest/DataPointService.java | 45 +++++++ .../osgitest/DataPointServiceImpl.java | 89 ++++++++++++++ .../org/hibernate/osgitest/HibernateUtil.java | 53 +++++++++ .../osgitest/command/AddCommand.java | 44 +++++++ .../osgitest/command/DeleteAllCommand.java | 37 ++++++ .../osgitest/command/GetAllCommand.java | 43 +++++++ .../osgitest/command/GetRevisionsCommand.java | 48 ++++++++ .../osgitest/command/UpdateCommand.java | 47 ++++++++ .../hibernate/osgitest/entity/DataPoint.java | 56 +++++++++ .../OSGI-INF/blueprint/blueprint.xml | 55 +++++++++ .../src/main/resources/ehcache.xml | 111 ++++++++++++++++++ .../src/main/resources/hibernate.cfg.xml | 46 ++++++++ .../src/main/resources/pool-one.properties | 7 ++ .../main/docbook/quickstart/tutorials/pom.xml | 1 + 39 files changed, 1911 insertions(+) create mode 100644 documentation/src/main/docbook/quickstart/tutorials/osgi/datasource-h2.xml create mode 100644 documentation/src/main/docbook/quickstart/tutorials/osgi/managed-jpa/features.xml create mode 100644 documentation/src/main/docbook/quickstart/tutorials/osgi/managed-jpa/pom.xml create mode 100644 documentation/src/main/docbook/quickstart/tutorials/osgi/managed-jpa/src/main/java/org/hibernate/osgitest/DataPointService.java create mode 100644 documentation/src/main/docbook/quickstart/tutorials/osgi/managed-jpa/src/main/java/org/hibernate/osgitest/DataPointServiceImpl.java create mode 100644 documentation/src/main/docbook/quickstart/tutorials/osgi/managed-jpa/src/main/java/org/hibernate/osgitest/command/AddCommand.java create mode 100644 documentation/src/main/docbook/quickstart/tutorials/osgi/managed-jpa/src/main/java/org/hibernate/osgitest/command/DeleteAllCommand.java create mode 100644 documentation/src/main/docbook/quickstart/tutorials/osgi/managed-jpa/src/main/java/org/hibernate/osgitest/command/GetAllCommand.java create mode 100644 documentation/src/main/docbook/quickstart/tutorials/osgi/managed-jpa/src/main/java/org/hibernate/osgitest/entity/DataPoint.java create mode 100644 documentation/src/main/docbook/quickstart/tutorials/osgi/managed-jpa/src/main/resources/META-INF/persistence.xml create mode 100644 documentation/src/main/docbook/quickstart/tutorials/osgi/managed-jpa/src/main/resources/OSGI-INF/blueprint/blueprint.xml create mode 100644 documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-jpa/features.xml create mode 100644 documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-jpa/pom.xml create mode 100644 documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-jpa/src/main/java/org/hibernate/osgitest/DataPointService.java create mode 100644 documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-jpa/src/main/java/org/hibernate/osgitest/DataPointServiceImpl.java create mode 100644 documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-jpa/src/main/java/org/hibernate/osgitest/HibernateUtil.java create mode 100644 documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-jpa/src/main/java/org/hibernate/osgitest/command/AddCommand.java create mode 100644 documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-jpa/src/main/java/org/hibernate/osgitest/command/DeleteAllCommand.java create mode 100644 documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-jpa/src/main/java/org/hibernate/osgitest/command/GetAllCommand.java create mode 100644 documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-jpa/src/main/java/org/hibernate/osgitest/command/UpdateCommand.java create mode 100644 documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-jpa/src/main/java/org/hibernate/osgitest/entity/DataPoint.java create mode 100644 documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-jpa/src/main/resources/META-INF/persistence.xml create mode 100644 documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-jpa/src/main/resources/OSGI-INF/blueprint/blueprint.xml create mode 100644 documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/features.xml create mode 100644 documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/pom.xml create mode 100644 documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/src/main/java/org/hibernate/osgitest/DataPointService.java create mode 100644 documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/src/main/java/org/hibernate/osgitest/DataPointServiceImpl.java create mode 100644 documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/src/main/java/org/hibernate/osgitest/HibernateUtil.java create mode 100644 documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/src/main/java/org/hibernate/osgitest/command/AddCommand.java create mode 100644 documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/src/main/java/org/hibernate/osgitest/command/DeleteAllCommand.java create mode 100644 documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/src/main/java/org/hibernate/osgitest/command/GetAllCommand.java create mode 100644 documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/src/main/java/org/hibernate/osgitest/command/GetRevisionsCommand.java create mode 100644 documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/src/main/java/org/hibernate/osgitest/command/UpdateCommand.java create mode 100644 documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/src/main/java/org/hibernate/osgitest/entity/DataPoint.java create mode 100644 documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/src/main/resources/OSGI-INF/blueprint/blueprint.xml create mode 100644 documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/src/main/resources/ehcache.xml create mode 100644 documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/src/main/resources/hibernate.cfg.xml create mode 100644 documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/src/main/resources/pool-one.properties diff --git a/documentation/src/main/docbook/quickstart/tutorials/osgi/datasource-h2.xml b/documentation/src/main/docbook/quickstart/tutorials/osgi/datasource-h2.xml new file mode 100644 index 0000000000..76ede3c842 --- /dev/null +++ b/documentation/src/main/docbook/quickstart/tutorials/osgi/datasource-h2.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + diff --git a/documentation/src/main/docbook/quickstart/tutorials/osgi/managed-jpa/features.xml b/documentation/src/main/docbook/quickstart/tutorials/osgi/managed-jpa/features.xml new file mode 100644 index 0000000000..47ac76c30d --- /dev/null +++ b/documentation/src/main/docbook/quickstart/tutorials/osgi/managed-jpa/features.xml @@ -0,0 +1,72 @@ + + + + + karaf-framework + + + + aries.transaction.recoverable = true + aries.transaction.timeout = 600 + aries.transaction.howl.logFileDir = ${karaf.data}/txlog + aries.transaction.howl.maxLogFiles = 2 + aries.transaction.howl.maxBlocksPerFile = 512 + aries.transaction.howl.bufferSizeKBytes = 4 + + mvn:org.apache.geronimo.specs/geronimo-jta_1.1_spec/1.1.1 + mvn:org.apache.aries.transaction/org.apache.aries.transaction.blueprint/1.0.0 + mvn:org.apache.aries.transaction/org.apache.aries.transaction.manager/1.0.1 + + + mvn:org.hibernate.javax.persistence/hibernate-jpa-2.1-api/1.0.0-SNAPSHOT + mvn:org.apache.aries/org.apache.aries.util/1.0.0 + mvn:org.apache.aries.jpa/org.apache.aries.jpa.api/1.0.1-SNAPSHOT + mvn:org.apache.aries.jpa/org.apache.aries.jpa.blueprint.aries/1.0.2-SNAPSHOT + mvn:org.apache.aries.jpa/org.apache.aries.jpa.container/1.0.1-SNAPSHOT + mvn:org.apache.aries.jpa/org.apache.aries.jpa.container.context/1.0.2-SNAPSHOT + + + mvn:org.apache.aries.jndi/org.apache.aries.jndi.api/1.0.0 + mvn:org.apache.aries.jndi/org.apache.aries.jndi.core/1.0.0 + mvn:org.apache.aries.jndi/org.apache.aries.jndi.rmi/1.0.0 + mvn:org.apache.aries.jndi/org.apache.aries.jndi.url/1.0.0 + mvn:org.apache.aries.jndi/org.apache.aries.jndi.legacy.support/1.0.0 + + + mvn:commons-collections/commons-collections/3.2.1 + mvn:commons-pool/commons-pool/1.5.4 + mvn:commons-dbcp/commons-dbcp/1.4 + mvn:commons-lang/commons-lang/2.6 + wrap:mvn:net.sourceforge.serp/serp/1.13.1 + + mvn:com.h2database/h2/1.3.170 + blueprint:file:/[PATH]/datasource-h2.xml + + + mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.antlr/2.7.7_5 + mvn:org.jboss.javassist/com.springsource.javassist/3.15.0.GA + mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.jsr303-api-1.0.0/2.2.0 + mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.ant/1.8.2_2 + mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.dom4j/1.6.1_5 + + + wrap:mvn:org.jboss/jandex/1.1.0.Alpha1 + + wrap:mvn:org.hibernate.common/hibernate-commons-annotations/4.0.2.Final + mvn:com.fasterxml/classmate/0.5.4 + mvn:org.jboss.logging/jboss-logging/3.1.0.GA + + mvn:org.hibernate/hibernate-core/4.3.0-SNAPSHOT + mvn:org.hibernate/hibernate-entitymanager/4.3.0-SNAPSHOT + + + mvn:org.hibernate.osgi/managed-jpa/1.0.0 + + mvn:org.hibernate/hibernate-osgi/4.3.0-SNAPSHOT + + diff --git a/documentation/src/main/docbook/quickstart/tutorials/osgi/managed-jpa/pom.xml b/documentation/src/main/docbook/quickstart/tutorials/osgi/managed-jpa/pom.xml new file mode 100644 index 0000000000..35f7009ab9 --- /dev/null +++ b/documentation/src/main/docbook/quickstart/tutorials/osgi/managed-jpa/pom.xml @@ -0,0 +1,63 @@ + + 4.0.0 + org.hibernate.osgi + managed-jpa + 1.0.0 + bundle + + + + org.hibernate.javax.persistence + hibernate-jpa-2.1-api + 1.0.0-SNAPSHOT + + + org.osgi + org.osgi.core + 4.3.1 + + + org.osgi + org.osgi.enterprise + 4.2.0 + + + org.apache.karaf.shell + org.apache.karaf.shell.console + 2.3.0 + + + + + + + org.apache.felix + maven-bundle-plugin + true + + + ${pom.groupId}.${pom.artifactId} + ${pom.artifactId} + 1.0.0 + + org.hibernate.osgitest, + org.hibernate.osgitest.entity + + + org.apache.felix.service.command, + org.apache.felix.gogo.commands, + org.apache.karaf.shell.console, + org.apache.karaf.shell.commands, + org.hibernate.proxy, + javassist.util.proxy, + javax.persistence;version="[1.0.0,2.1.0]", + * + + META-INF/persistence.xml + + + + + + diff --git a/documentation/src/main/docbook/quickstart/tutorials/osgi/managed-jpa/src/main/java/org/hibernate/osgitest/DataPointService.java b/documentation/src/main/docbook/quickstart/tutorials/osgi/managed-jpa/src/main/java/org/hibernate/osgitest/DataPointService.java new file mode 100644 index 0000000000..bdeaace115 --- /dev/null +++ b/documentation/src/main/docbook/quickstart/tutorials/osgi/managed-jpa/src/main/java/org/hibernate/osgitest/DataPointService.java @@ -0,0 +1,37 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * JBoss, Home of Professional Open Source + * Copyright 2013 Red Hat Inc. and/or its affiliates and other contributors + * as indicated by the @authors tag. All rights reserved. + * See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU Lesser General Public License, v. 2.1. + * This program is distributed in the hope that it will be useful, but WITHOUT A + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License, + * v.2.1 along with this distribution; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ +package org.hibernate.osgitest; + +import java.util.List; + +import org.hibernate.osgitest.entity.DataPoint; + +/** + * @author Brett Meyer + */ +public interface DataPointService { + + public void add(DataPoint dp); + + public List getAll(); + + public void deleteAll(); +} diff --git a/documentation/src/main/docbook/quickstart/tutorials/osgi/managed-jpa/src/main/java/org/hibernate/osgitest/DataPointServiceImpl.java b/documentation/src/main/docbook/quickstart/tutorials/osgi/managed-jpa/src/main/java/org/hibernate/osgitest/DataPointServiceImpl.java new file mode 100644 index 0000000000..f324889603 --- /dev/null +++ b/documentation/src/main/docbook/quickstart/tutorials/osgi/managed-jpa/src/main/java/org/hibernate/osgitest/DataPointServiceImpl.java @@ -0,0 +1,58 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * JBoss, Home of Professional Open Source + * Copyright 2013 Red Hat Inc. and/or its affiliates and other contributors + * as indicated by the @authors tag. All rights reserved. + * See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU Lesser General Public License, v. 2.1. + * This program is distributed in the hope that it will be useful, but WITHOUT A + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License, + * v.2.1 along with this distribution; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ +package org.hibernate.osgitest; + +import java.util.List; + +import javax.persistence.EntityManager; + +import org.hibernate.osgitest.entity.DataPoint; + +/** + * @author Brett Meyer + */ +public class DataPointServiceImpl implements DataPointService { + + private EntityManager entityManager; + + public void add(DataPoint dp) { + entityManager.persist( dp ); + entityManager.flush(); + } + + public List getAll() { + return entityManager.createQuery( "select d from DataPoint d", DataPoint.class ).getResultList(); + } + + public void deleteAll() { + entityManager.createQuery( "delete from DataPoint" ).executeUpdate(); + entityManager.flush(); + } + + public EntityManager getEntityManager() { + return entityManager; + } + + public void setEntityManager(EntityManager entityManager) { + this.entityManager = entityManager; + } + +} diff --git a/documentation/src/main/docbook/quickstart/tutorials/osgi/managed-jpa/src/main/java/org/hibernate/osgitest/command/AddCommand.java b/documentation/src/main/docbook/quickstart/tutorials/osgi/managed-jpa/src/main/java/org/hibernate/osgitest/command/AddCommand.java new file mode 100644 index 0000000000..9e9844c331 --- /dev/null +++ b/documentation/src/main/docbook/quickstart/tutorials/osgi/managed-jpa/src/main/java/org/hibernate/osgitest/command/AddCommand.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.hibernate.osgitest.command; + +import org.apache.felix.gogo.commands.Action; +import org.apache.felix.gogo.commands.Argument; +import org.apache.felix.gogo.commands.Command; +import org.apache.felix.service.command.CommandSession; +import org.hibernate.osgitest.DataPointService; +import org.hibernate.osgitest.entity.DataPoint; + +@Command(scope = "dp", name = "add") +public class AddCommand implements Action { + @Argument(index=0, name="Name", required=true, description="Name", multiValued=false) + String name; + + private DataPointService dpService; + + public void setDpService(DataPointService dpService) { + this.dpService = dpService; + } + + public Object execute(CommandSession session) throws Exception { + DataPoint dp = new DataPoint(); + dp.setName( name ); + dpService.add( dp ); + return null; + } + +} diff --git a/documentation/src/main/docbook/quickstart/tutorials/osgi/managed-jpa/src/main/java/org/hibernate/osgitest/command/DeleteAllCommand.java b/documentation/src/main/docbook/quickstart/tutorials/osgi/managed-jpa/src/main/java/org/hibernate/osgitest/command/DeleteAllCommand.java new file mode 100644 index 0000000000..d6c4ccf676 --- /dev/null +++ b/documentation/src/main/docbook/quickstart/tutorials/osgi/managed-jpa/src/main/java/org/hibernate/osgitest/command/DeleteAllCommand.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.hibernate.osgitest.command; + +import org.apache.felix.gogo.commands.Action; +import org.apache.felix.gogo.commands.Command; +import org.apache.felix.service.command.CommandSession; +import org.hibernate.osgitest.DataPointService; + +@Command(scope = "dp", name = "deleteAll") +public class DeleteAllCommand implements Action { +private DataPointService dpService; + + public void setDpService(DataPointService dpService) { + this.dpService = dpService; + } + + public Object execute(CommandSession session) throws Exception { + dpService.deleteAll(); + return null; + } + +} diff --git a/documentation/src/main/docbook/quickstart/tutorials/osgi/managed-jpa/src/main/java/org/hibernate/osgitest/command/GetAllCommand.java b/documentation/src/main/docbook/quickstart/tutorials/osgi/managed-jpa/src/main/java/org/hibernate/osgitest/command/GetAllCommand.java new file mode 100644 index 0000000000..ebdac60ea2 --- /dev/null +++ b/documentation/src/main/docbook/quickstart/tutorials/osgi/managed-jpa/src/main/java/org/hibernate/osgitest/command/GetAllCommand.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.hibernate.osgitest.command; + +import java.util.List; + +import org.apache.felix.gogo.commands.Action; +import org.apache.felix.gogo.commands.Command; +import org.apache.felix.service.command.CommandSession; +import org.hibernate.osgitest.DataPointService; +import org.hibernate.osgitest.entity.DataPoint; + +@Command(scope = "dp", name = "getAll") +public class GetAllCommand implements Action { + private DataPointService dpService; + + public void setDpService(DataPointService dpService) { + this.dpService = dpService; + } + + public Object execute(CommandSession session) throws Exception { + List dps = dpService.getAll(); + for (DataPoint dp : dps) { + System.out.println(dp.getId() + ", " + dp.getName()); + } + return null; + } + +} diff --git a/documentation/src/main/docbook/quickstart/tutorials/osgi/managed-jpa/src/main/java/org/hibernate/osgitest/entity/DataPoint.java b/documentation/src/main/docbook/quickstart/tutorials/osgi/managed-jpa/src/main/java/org/hibernate/osgitest/entity/DataPoint.java new file mode 100644 index 0000000000..2a566d8829 --- /dev/null +++ b/documentation/src/main/docbook/quickstart/tutorials/osgi/managed-jpa/src/main/java/org/hibernate/osgitest/entity/DataPoint.java @@ -0,0 +1,53 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * JBoss, Home of Professional Open Source + * Copyright 2013 Red Hat Inc. and/or its affiliates and other contributors + * as indicated by the @authors tag. All rights reserved. + * See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU Lesser General Public License, v. 2.1. + * This program is distributed in the hope that it will be useful, but WITHOUT A + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License, + * v.2.1 along with this distribution; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ +package org.hibernate.osgitest.entity; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +/** + * @author Brett Meyer + */ +@Entity +public class DataPoint { + @Id + @GeneratedValue + private long id; + + private String name; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/documentation/src/main/docbook/quickstart/tutorials/osgi/managed-jpa/src/main/resources/META-INF/persistence.xml b/documentation/src/main/docbook/quickstart/tutorials/osgi/managed-jpa/src/main/resources/META-INF/persistence.xml new file mode 100644 index 0000000000..5db3a42357 --- /dev/null +++ b/documentation/src/main/docbook/quickstart/tutorials/osgi/managed-jpa/src/main/resources/META-INF/persistence.xml @@ -0,0 +1,15 @@ + + + + osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=jdbc/h2ds) + + + + + + + + + \ No newline at end of file diff --git a/documentation/src/main/docbook/quickstart/tutorials/osgi/managed-jpa/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/documentation/src/main/docbook/quickstart/tutorials/osgi/managed-jpa/src/main/resources/OSGI-INF/blueprint/blueprint.xml new file mode 100644 index 0000000000..d7f2a95a47 --- /dev/null +++ b/documentation/src/main/docbook/quickstart/tutorials/osgi/managed-jpa/src/main/resources/OSGI-INF/blueprint/blueprint.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-jpa/features.xml b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-jpa/features.xml new file mode 100644 index 0000000000..9e31bed850 --- /dev/null +++ b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-jpa/features.xml @@ -0,0 +1,42 @@ + + + + + karaf-framework + + + mvn:org.apache.geronimo.specs/geronimo-jta_1.1_spec/1.1.1 + + + mvn:org.hibernate.javax.persistence/hibernate-jpa-2.1-api/1.0.0-SNAPSHOT + + + mvn:commons-collections/commons-collections/3.2.1 + mvn:commons-pool/commons-pool/1.5.4 + mvn:commons-dbcp/commons-dbcp/1.4 + mvn:commons-lang/commons-lang/2.6 + wrap:mvn:net.sourceforge.serp/serp/1.13.1 + + mvn:com.h2database/h2/1.3.170 + + + mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.antlr/2.7.7_5 + mvn:org.jboss.javassist/com.springsource.javassist/3.15.0.GA + mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.jsr303-api-1.0.0/2.2.0 + mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.ant/1.8.2_2 + mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.dom4j/1.6.1_5 + + + wrap:mvn:org.hibernate.common/hibernate-commons-annotations/4.0.2.Final + wrap:mvn:org.jboss/jandex/1.1.0.Alpha1 + + mvn:com.fasterxml/classmate/0.5.4 + mvn:org.jboss.logging/jboss-logging/3.1.0.GA + + mvn:org.hibernate/hibernate-core/4.3.0-SNAPSHOT + mvn:org.hibernate/hibernate-entitymanager/4.3.0-SNAPSHOT + mvn:org.hibernate/hibernate-osgi/4.3.0-SNAPSHOT + + mvn:org.hibernate.osgi/unmanaged-jpa/1.0.0 + + diff --git a/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-jpa/pom.xml b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-jpa/pom.xml new file mode 100644 index 0000000000..c09f30f155 --- /dev/null +++ b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-jpa/pom.xml @@ -0,0 +1,74 @@ + + 4.0.0 + org.hibernate.osgi + unmanaged-jpa + 1.0.0 + bundle + + + + org.hibernate.javax.persistence + hibernate-jpa-2.1-api + 1.0.0-SNAPSHOT + + + org.osgi + org.osgi.core + 4.3.1 + + + org.osgi + org.osgi.enterprise + 4.2.0 + + + org.apache.karaf.shell + org.apache.karaf.shell.console + 2.3.0 + + + org.hibernate + hibernate-entitymanager + 4.3.0-SNAPSHOT + + + com.h2database + h2 + 1.3.170 + + + + + + + + org.apache.felix + maven-bundle-plugin + true + + + ${pom.groupId}.${pom.artifactId} + ${pom.artifactId} + 1.0.0 + + org.hibernate.osgitest, + org.hibernate.osgitest.entity + + + org.apache.felix.service.command, + org.apache.felix.gogo.commands, + org.apache.karaf.shell.console, + org.apache.karaf.shell.commands, + org.h2, + org.hibernate.proxy, + javassist.util.proxy, + javax.persistence;version="[1.0.0,2.1.0]", + * + + + + + + + diff --git a/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-jpa/src/main/java/org/hibernate/osgitest/DataPointService.java b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-jpa/src/main/java/org/hibernate/osgitest/DataPointService.java new file mode 100644 index 0000000000..de8c960c1f --- /dev/null +++ b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-jpa/src/main/java/org/hibernate/osgitest/DataPointService.java @@ -0,0 +1,41 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * JBoss, Home of Professional Open Source + * Copyright 2013 Red Hat Inc. and/or its affiliates and other contributors + * as indicated by the @authors tag. All rights reserved. + * See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU Lesser General Public License, v. 2.1. + * This program is distributed in the hope that it will be useful, but WITHOUT A + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License, + * v.2.1 along with this distribution; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ +package org.hibernate.osgitest; + +import java.util.List; + +import org.hibernate.osgitest.entity.DataPoint; + +/** + * @author Brett Meyer + */ +public interface DataPointService { + + public void add(DataPoint dp); + + public void update(DataPoint dp); + + public DataPoint get(long id); + + public List getAll(); + + public void deleteAll(); +} diff --git a/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-jpa/src/main/java/org/hibernate/osgitest/DataPointServiceImpl.java b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-jpa/src/main/java/org/hibernate/osgitest/DataPointServiceImpl.java new file mode 100644 index 0000000000..e4b748daf4 --- /dev/null +++ b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-jpa/src/main/java/org/hibernate/osgitest/DataPointServiceImpl.java @@ -0,0 +1,76 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * JBoss, Home of Professional Open Source + * Copyright 2013 Red Hat Inc. and/or its affiliates and other contributors + * as indicated by the @authors tag. All rights reserved. + * See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU Lesser General Public License, v. 2.1. + * This program is distributed in the hope that it will be useful, but WITHOUT A + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License, + * v.2.1 along with this distribution; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ +package org.hibernate.osgitest; + +import java.util.List; + +import javax.persistence.EntityManager; + +import org.hibernate.osgitest.entity.DataPoint; + +/** + * @author Brett Meyer + */ +public class DataPointServiceImpl implements DataPointService { + + public void add(DataPoint dp) { + EntityManager em = HibernateUtil.getEntityManager(); + em.getTransaction().begin(); + em.persist( dp ); + em.getTransaction().commit(); + em.close(); + } + + public void update(DataPoint dp) { + EntityManager em = HibernateUtil.getEntityManager(); + em.getTransaction().begin(); + em.merge( dp ); + em.getTransaction().commit(); + em.close(); + } + + public DataPoint get(long id) { + EntityManager em = HibernateUtil.getEntityManager(); + em.getTransaction().begin(); + DataPoint dp = (DataPoint) em.createQuery( "from DataPoint dp where dp.id=" + id ).getSingleResult(); + em.getTransaction().commit(); + em.close(); + return dp; + } + + public List getAll() { + EntityManager em = HibernateUtil.getEntityManager(); + em.getTransaction().begin(); + List list = em.createQuery( "from DataPoint" ).getResultList(); + em.getTransaction().commit(); + em.close(); + return list; + } + + public void deleteAll() { + EntityManager em = HibernateUtil.getEntityManager(); + em.getTransaction().begin(); + em.createQuery( "delete from DataPoint" ).executeUpdate(); + em.getTransaction().commit(); + em.close(); + } + +} diff --git a/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-jpa/src/main/java/org/hibernate/osgitest/HibernateUtil.java b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-jpa/src/main/java/org/hibernate/osgitest/HibernateUtil.java new file mode 100644 index 0000000000..66442637b3 --- /dev/null +++ b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-jpa/src/main/java/org/hibernate/osgitest/HibernateUtil.java @@ -0,0 +1,57 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * JBoss, Home of Professional Open Source + * Copyright 2013 Red Hat Inc. and/or its affiliates and other contributors + * as indicated by the @authors tag. All rights reserved. + * See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU Lesser General Public License, v. 2.1. + * This program is distributed in the hope that it will be useful, but WITHOUT A + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License, + * v.2.1 along with this distribution; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ +package org.hibernate.osgitest; + +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.spi.PersistenceProvider; + +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; +import org.osgi.framework.FrameworkUtil; +import org.osgi.framework.ServiceReference; + +/** + * @author Brett Meyer + */ + +public class HibernateUtil { + + private static EntityManagerFactory emf; + + public static EntityManager getEntityManager() { + return getEntityManagerFactory().createEntityManager(); + } + + private static EntityManagerFactory getEntityManagerFactory() { + if ( emf == null ) { + Bundle thisBundle = FrameworkUtil.getBundle( HibernateUtil.class ); + // Could get this by wiring up OsgiTestBundleActivator as well. + BundleContext context = thisBundle.getBundleContext(); + + ServiceReference serviceReference = context.getServiceReference( PersistenceProvider.class.getName() ); + PersistenceProvider persistenceProvider = (PersistenceProvider) context.getService( serviceReference ); + + emf = persistenceProvider.createEntityManagerFactory( "unmanaged-jpa", null ); + } + return emf; + } +} diff --git a/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-jpa/src/main/java/org/hibernate/osgitest/command/AddCommand.java b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-jpa/src/main/java/org/hibernate/osgitest/command/AddCommand.java new file mode 100644 index 0000000000..c1b906c012 --- /dev/null +++ b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-jpa/src/main/java/org/hibernate/osgitest/command/AddCommand.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.hibernate.osgitest.command; + +import org.apache.felix.gogo.commands.Action; +import org.apache.felix.gogo.commands.Argument; +import org.apache.felix.gogo.commands.Command; +import org.apache.felix.service.command.CommandSession; +import org.hibernate.osgitest.DataPointService; +import org.hibernate.osgitest.entity.DataPoint; + +@Command(scope = "dp", name = "addJPA") +public class AddCommand implements Action { + @Argument(index=0, name="Name", required=true, description="Name", multiValued=false) + String name; + + private DataPointService dpService; + + public void setDpService(DataPointService dpService) { + this.dpService = dpService; + } + + public Object execute(CommandSession session) throws Exception { + DataPoint dp = new DataPoint(); + dp.setName( name ); + dpService.add( dp ); + return null; + } + +} diff --git a/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-jpa/src/main/java/org/hibernate/osgitest/command/DeleteAllCommand.java b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-jpa/src/main/java/org/hibernate/osgitest/command/DeleteAllCommand.java new file mode 100644 index 0000000000..0d404ae1a1 --- /dev/null +++ b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-jpa/src/main/java/org/hibernate/osgitest/command/DeleteAllCommand.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.hibernate.osgitest.command; + +import org.apache.felix.gogo.commands.Action; +import org.apache.felix.gogo.commands.Command; +import org.apache.felix.service.command.CommandSession; +import org.hibernate.osgitest.DataPointService; + +@Command(scope = "dp", name = "deleteAllJPA") +public class DeleteAllCommand implements Action { +private DataPointService dpService; + + public void setDpService(DataPointService dpService) { + this.dpService = dpService; + } + + public Object execute(CommandSession session) throws Exception { + dpService.deleteAll(); + return null; + } + +} diff --git a/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-jpa/src/main/java/org/hibernate/osgitest/command/GetAllCommand.java b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-jpa/src/main/java/org/hibernate/osgitest/command/GetAllCommand.java new file mode 100644 index 0000000000..6873e46303 --- /dev/null +++ b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-jpa/src/main/java/org/hibernate/osgitest/command/GetAllCommand.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.hibernate.osgitest.command; + +import java.util.List; + +import org.apache.felix.gogo.commands.Action; +import org.apache.felix.gogo.commands.Command; +import org.apache.felix.service.command.CommandSession; +import org.hibernate.osgitest.DataPointService; +import org.hibernate.osgitest.entity.DataPoint; + +@Command(scope = "dp", name = "getAllJPA") +public class GetAllCommand implements Action { + private DataPointService dpService; + + public void setDpService(DataPointService dpService) { + this.dpService = dpService; + } + + public Object execute(CommandSession session) throws Exception { + List dps = dpService.getAll(); + for (DataPoint dp : dps) { + System.out.println(dp.getId() + ", " + dp.getName()); + } + return null; + } + +} diff --git a/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-jpa/src/main/java/org/hibernate/osgitest/command/UpdateCommand.java b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-jpa/src/main/java/org/hibernate/osgitest/command/UpdateCommand.java new file mode 100644 index 0000000000..5de8983dd9 --- /dev/null +++ b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-jpa/src/main/java/org/hibernate/osgitest/command/UpdateCommand.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.hibernate.osgitest.command; + +import org.apache.felix.gogo.commands.Action; +import org.apache.felix.gogo.commands.Argument; +import org.apache.felix.gogo.commands.Command; +import org.apache.felix.service.command.CommandSession; +import org.hibernate.osgitest.DataPointService; +import org.hibernate.osgitest.entity.DataPoint; + +@Command(scope = "dp", name = "updateJPA") +public class UpdateCommand implements Action { + @Argument(index=0, name="Id", required=true, description="Id", multiValued=false) + String id; + + @Argument(index=1, name="Name", required=true, description="Name", multiValued=false) + String name; + + private DataPointService dpService; + + public void setDpService(DataPointService dpService) { + this.dpService = dpService; + } + + public Object execute(CommandSession session) throws Exception { + DataPoint dp = dpService.get( Long.valueOf( id ) ); + dp.setName( name ); + dpService.update( dp ); + return null; + } + +} diff --git a/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-jpa/src/main/java/org/hibernate/osgitest/entity/DataPoint.java b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-jpa/src/main/java/org/hibernate/osgitest/entity/DataPoint.java new file mode 100644 index 0000000000..2a566d8829 --- /dev/null +++ b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-jpa/src/main/java/org/hibernate/osgitest/entity/DataPoint.java @@ -0,0 +1,53 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * JBoss, Home of Professional Open Source + * Copyright 2013 Red Hat Inc. and/or its affiliates and other contributors + * as indicated by the @authors tag. All rights reserved. + * See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU Lesser General Public License, v. 2.1. + * This program is distributed in the hope that it will be useful, but WITHOUT A + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License, + * v.2.1 along with this distribution; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ +package org.hibernate.osgitest.entity; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +/** + * @author Brett Meyer + */ +@Entity +public class DataPoint { + @Id + @GeneratedValue + private long id; + + private String name; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-jpa/src/main/resources/META-INF/persistence.xml b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-jpa/src/main/resources/META-INF/persistence.xml new file mode 100644 index 0000000000..7c7efcae7e --- /dev/null +++ b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-jpa/src/main/resources/META-INF/persistence.xml @@ -0,0 +1,18 @@ + + + + org.hibernate.osgitest.entity.DataPoint + true + + + + + + + + + + + \ No newline at end of file diff --git a/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-jpa/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-jpa/src/main/resources/OSGI-INF/blueprint/blueprint.xml new file mode 100644 index 0000000000..896737d2e8 --- /dev/null +++ b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-jpa/src/main/resources/OSGI-INF/blueprint/blueprint.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/features.xml b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/features.xml new file mode 100644 index 0000000000..e505b7c5a9 --- /dev/null +++ b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/features.xml @@ -0,0 +1,72 @@ + + + + + karaf-framework + + + mvn:org.apache.geronimo.specs/geronimo-jta_1.1_spec/1.1.1 + + + mvn:org.hibernate.javax.persistence/hibernate-jpa-2.1-api/1.0.0-SNAPSHOT + + + mvn:commons-collections/commons-collections/3.2.1 + mvn:commons-pool/commons-pool/1.5.4 + mvn:commons-dbcp/commons-dbcp/1.4 + mvn:commons-lang/commons-lang/2.6 + wrap:mvn:net.sourceforge.serp/serp/1.13.1 + + mvn:com.h2database/h2/1.3.170 + + + mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.antlr/2.7.7_5 + mvn:org.jboss.javassist/com.springsource.javassist/3.15.0.GA + mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.jsr303-api-1.0.0/2.2.0 + mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.ant/1.8.2_2 + mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.dom4j/1.6.1_5 + + + wrap:mvn:org.hibernate.common/hibernate-commons-annotations/4.0.2.Final + wrap:mvn:org.jboss/jandex/1.1.0.Alpha1 + + + + + + + + mvn:com.fasterxml/classmate/0.5.4 + mvn:org.jboss.logging/jboss-logging/3.1.0.GA + + + + + + + + + + + + mvn:org.hibernate/hibernate-core/4.3.0-SNAPSHOT + + mvn:org.hibernate/hibernate-entitymanager/4.3.0-SNAPSHOT + mvn:org.hibernate/hibernate-envers/4.3.0-SNAPSHOT + + + + + mvn:org.hibernate/hibernate-osgi/4.3.0-SNAPSHOT + + mvn:org.hibernate.osgi/unmanaged-native/1.0.0 + + diff --git a/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/pom.xml b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/pom.xml new file mode 100644 index 0000000000..bb1b8c1874 --- /dev/null +++ b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/pom.xml @@ -0,0 +1,82 @@ + + 4.0.0 + org.hibernate.osgi + unmanaged-native + 1.0.0 + bundle + + + + org.hibernate.javax.persistence + hibernate-jpa-2.1-api + 1.0.0-SNAPSHOT + + + org.osgi + org.osgi.core + 4.3.1 + + + org.osgi + org.osgi.enterprise + 4.2.0 + + + org.apache.karaf.shell + org.apache.karaf.shell.console + 2.3.0 + + + org.hibernate + hibernate-core + 4.3.0-SNAPSHOT + + + org.hibernate + hibernate-envers + 4.3.0-SNAPSHOT + + + com.h2database + h2 + 1.3.170 + + + + + + + + org.apache.felix + maven-bundle-plugin + true + + + ${pom.groupId}.${pom.artifactId} + ${pom.artifactId} + 1.0.0 + + org.hibernate.osgitest, + org.hibernate.osgitest.entity + + + org.apache.felix.service.command, + org.apache.felix.gogo.commands, + org.apache.karaf.shell.console, + org.apache.karaf.shell.commands, + org.h2, + org.hibernate, + org.hibernate.cfg, + org.hibernate.service, + org.hibernate.proxy, + javassist.util.proxy, + javax.persistence;version="[1.0.0,2.1.0]", + * + + + + + + + diff --git a/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/src/main/java/org/hibernate/osgitest/DataPointService.java b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/src/main/java/org/hibernate/osgitest/DataPointService.java new file mode 100644 index 0000000000..ba71b211a6 --- /dev/null +++ b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/src/main/java/org/hibernate/osgitest/DataPointService.java @@ -0,0 +1,45 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * JBoss, Home of Professional Open Source + * Copyright 2013 Red Hat Inc. and/or its affiliates and other contributors + * as indicated by the @authors tag. All rights reserved. + * See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU Lesser General Public License, v. 2.1. + * This program is distributed in the hope that it will be useful, but WITHOUT A + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License, + * v.2.1 along with this distribution; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ +package org.hibernate.osgitest; + +import java.util.List; +import java.util.Map; + +import org.hibernate.envers.DefaultRevisionEntity; +import org.hibernate.osgitest.entity.DataPoint; + +/** + * @author Brett Meyer + */ +public interface DataPointService { + + public void add(DataPoint dp); + + public void update(DataPoint dp); + + public DataPoint get(long id); + + public List getAll(); + + public Map getRevisions(long id); + + public void deleteAll(); +} diff --git a/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/src/main/java/org/hibernate/osgitest/DataPointServiceImpl.java b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/src/main/java/org/hibernate/osgitest/DataPointServiceImpl.java new file mode 100644 index 0000000000..dfa5b66f35 --- /dev/null +++ b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/src/main/java/org/hibernate/osgitest/DataPointServiceImpl.java @@ -0,0 +1,89 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * JBoss, Home of Professional Open Source + * Copyright 2013 Red Hat Inc. and/or its affiliates and other contributors + * as indicated by the @authors tag. All rights reserved. + * See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU Lesser General Public License, v. 2.1. + * This program is distributed in the hope that it will be useful, but WITHOUT A + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License, + * v.2.1 along with this distribution; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ +package org.hibernate.osgitest; + +import java.util.HashSet; +import java.util.List; +import java.util.Map; + +import org.hibernate.Session; +import org.hibernate.criterion.Restrictions; +import org.hibernate.envers.AuditReader; +import org.hibernate.envers.AuditReaderFactory; +import org.hibernate.envers.DefaultRevisionEntity; +import org.hibernate.osgitest.entity.DataPoint; + +/** + * @author Brett Meyer + */ +public class DataPointServiceImpl implements DataPointService { + + public void add(DataPoint dp) { + Session s = HibernateUtil.getSession(); + s.getTransaction().begin(); + s.persist( dp ); + s.getTransaction().commit(); + s.close(); + } + + public void update(DataPoint dp) { + Session s = HibernateUtil.getSession(); + s.getTransaction().begin(); + s.update( dp ); + s.getTransaction().commit(); + s.close(); + } + + public DataPoint get(long id) { + Session s = HibernateUtil.getSession(); + s.getTransaction().begin(); + DataPoint dp = (DataPoint) s.createCriteria( DataPoint.class ).add( + Restrictions.eq( "id", id ) ).uniqueResult(); + s.getTransaction().commit(); + s.close(); + return dp; + } + + public List getAll() { + Session s = HibernateUtil.getSession(); + s.getTransaction().begin(); + List list = s.createQuery( "from DataPoint" ).list(); + s.getTransaction().commit(); + s.close(); + return list; + } + + public Map getRevisions(long id) { + Session s = HibernateUtil.getSession(); + AuditReader reader = AuditReaderFactory.get(s); + List revisionNums = reader.getRevisions( DataPoint.class, id ); + return reader.findRevisions( DefaultRevisionEntity.class, new HashSet(revisionNums) ); + } + + public void deleteAll() { + Session s = HibernateUtil.getSession(); + s.getTransaction().begin(); + s.createQuery( "delete from DataPoint" ).executeUpdate(); + s.getTransaction().commit(); + s.close(); + } + +} diff --git a/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/src/main/java/org/hibernate/osgitest/HibernateUtil.java b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/src/main/java/org/hibernate/osgitest/HibernateUtil.java new file mode 100644 index 0000000000..d44072f157 --- /dev/null +++ b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/src/main/java/org/hibernate/osgitest/HibernateUtil.java @@ -0,0 +1,53 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * JBoss, Home of Professional Open Source + * Copyright 2013 Red Hat Inc. and/or its affiliates and other contributors + * as indicated by the @authors tag. All rights reserved. + * See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU Lesser General Public License, v. 2.1. + * This program is distributed in the hope that it will be useful, but WITHOUT A + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License, + * v.2.1 along with this distribution; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ +package org.hibernate.osgitest; + +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; +import org.osgi.framework.FrameworkUtil; +import org.osgi.framework.ServiceReference; + +/** + * @author Brett Meyer + */ + +public class HibernateUtil { + + private static SessionFactory sf; + + public static Session getSession() { + return getSessionFactory().openSession(); + } + + private static SessionFactory getSessionFactory() { + if ( sf == null ) { + Bundle thisBundle = FrameworkUtil.getBundle( HibernateUtil.class ); + // Could get this by wiring up OsgiTestBundleActivator as well. + BundleContext context = thisBundle.getBundleContext(); + + ServiceReference sr = context.getServiceReference( SessionFactory.class.getName() ); + sf = (SessionFactory) context.getService( sr ); + } + return sf; + } +} diff --git a/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/src/main/java/org/hibernate/osgitest/command/AddCommand.java b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/src/main/java/org/hibernate/osgitest/command/AddCommand.java new file mode 100644 index 0000000000..9e9844c331 --- /dev/null +++ b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/src/main/java/org/hibernate/osgitest/command/AddCommand.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.hibernate.osgitest.command; + +import org.apache.felix.gogo.commands.Action; +import org.apache.felix.gogo.commands.Argument; +import org.apache.felix.gogo.commands.Command; +import org.apache.felix.service.command.CommandSession; +import org.hibernate.osgitest.DataPointService; +import org.hibernate.osgitest.entity.DataPoint; + +@Command(scope = "dp", name = "add") +public class AddCommand implements Action { + @Argument(index=0, name="Name", required=true, description="Name", multiValued=false) + String name; + + private DataPointService dpService; + + public void setDpService(DataPointService dpService) { + this.dpService = dpService; + } + + public Object execute(CommandSession session) throws Exception { + DataPoint dp = new DataPoint(); + dp.setName( name ); + dpService.add( dp ); + return null; + } + +} diff --git a/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/src/main/java/org/hibernate/osgitest/command/DeleteAllCommand.java b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/src/main/java/org/hibernate/osgitest/command/DeleteAllCommand.java new file mode 100644 index 0000000000..d6c4ccf676 --- /dev/null +++ b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/src/main/java/org/hibernate/osgitest/command/DeleteAllCommand.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.hibernate.osgitest.command; + +import org.apache.felix.gogo.commands.Action; +import org.apache.felix.gogo.commands.Command; +import org.apache.felix.service.command.CommandSession; +import org.hibernate.osgitest.DataPointService; + +@Command(scope = "dp", name = "deleteAll") +public class DeleteAllCommand implements Action { +private DataPointService dpService; + + public void setDpService(DataPointService dpService) { + this.dpService = dpService; + } + + public Object execute(CommandSession session) throws Exception { + dpService.deleteAll(); + return null; + } + +} diff --git a/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/src/main/java/org/hibernate/osgitest/command/GetAllCommand.java b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/src/main/java/org/hibernate/osgitest/command/GetAllCommand.java new file mode 100644 index 0000000000..ebdac60ea2 --- /dev/null +++ b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/src/main/java/org/hibernate/osgitest/command/GetAllCommand.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.hibernate.osgitest.command; + +import java.util.List; + +import org.apache.felix.gogo.commands.Action; +import org.apache.felix.gogo.commands.Command; +import org.apache.felix.service.command.CommandSession; +import org.hibernate.osgitest.DataPointService; +import org.hibernate.osgitest.entity.DataPoint; + +@Command(scope = "dp", name = "getAll") +public class GetAllCommand implements Action { + private DataPointService dpService; + + public void setDpService(DataPointService dpService) { + this.dpService = dpService; + } + + public Object execute(CommandSession session) throws Exception { + List dps = dpService.getAll(); + for (DataPoint dp : dps) { + System.out.println(dp.getId() + ", " + dp.getName()); + } + return null; + } + +} diff --git a/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/src/main/java/org/hibernate/osgitest/command/GetRevisionsCommand.java b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/src/main/java/org/hibernate/osgitest/command/GetRevisionsCommand.java new file mode 100644 index 0000000000..b4573f6200 --- /dev/null +++ b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/src/main/java/org/hibernate/osgitest/command/GetRevisionsCommand.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.hibernate.osgitest.command; + +import java.util.Map; + +import org.apache.felix.gogo.commands.Action; +import org.apache.felix.gogo.commands.Argument; +import org.apache.felix.gogo.commands.Command; +import org.apache.felix.service.command.CommandSession; +import org.hibernate.envers.DefaultRevisionEntity; +import org.hibernate.osgitest.DataPointService; + +@Command(scope = "dp", name = "getRevisions") +public class GetRevisionsCommand implements Action { + @Argument(index=0, name="Id", required=true, description="Id", multiValued=false) + String id; + + private DataPointService dpService; + + public void setDpService(DataPointService dpService) { + this.dpService = dpService; + } + + public Object execute(CommandSession session) throws Exception { + Map revisions = dpService.getRevisions(Long.valueOf( id )); + for (Number revisionNum : revisions.keySet()) { + DefaultRevisionEntity dre = revisions.get( revisionNum ); + System.out.println(revisionNum + ": " + dre.getId() + ", " + dre.getTimestamp()); + } + return null; + } + +} diff --git a/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/src/main/java/org/hibernate/osgitest/command/UpdateCommand.java b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/src/main/java/org/hibernate/osgitest/command/UpdateCommand.java new file mode 100644 index 0000000000..f694967444 --- /dev/null +++ b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/src/main/java/org/hibernate/osgitest/command/UpdateCommand.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.hibernate.osgitest.command; + +import org.apache.felix.gogo.commands.Action; +import org.apache.felix.gogo.commands.Argument; +import org.apache.felix.gogo.commands.Command; +import org.apache.felix.service.command.CommandSession; +import org.hibernate.osgitest.DataPointService; +import org.hibernate.osgitest.entity.DataPoint; + +@Command(scope = "dp", name = "update") +public class UpdateCommand implements Action { + @Argument(index=0, name="Id", required=true, description="Id", multiValued=false) + String id; + + @Argument(index=1, name="Name", required=true, description="Name", multiValued=false) + String name; + + private DataPointService dpService; + + public void setDpService(DataPointService dpService) { + this.dpService = dpService; + } + + public Object execute(CommandSession session) throws Exception { + DataPoint dp = dpService.get( Long.valueOf( id ) ); + dp.setName( name ); + dpService.update( dp ); + return null; + } + +} diff --git a/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/src/main/java/org/hibernate/osgitest/entity/DataPoint.java b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/src/main/java/org/hibernate/osgitest/entity/DataPoint.java new file mode 100644 index 0000000000..6f7126fd27 --- /dev/null +++ b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/src/main/java/org/hibernate/osgitest/entity/DataPoint.java @@ -0,0 +1,56 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * JBoss, Home of Professional Open Source + * Copyright 2013 Red Hat Inc. and/or its affiliates and other contributors + * as indicated by the @authors tag. All rights reserved. + * See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU Lesser General Public License, v. 2.1. + * This program is distributed in the hope that it will be useful, but WITHOUT A + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License, + * v.2.1 along with this distribution; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ +package org.hibernate.osgitest.entity; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +import org.hibernate.envers.Audited; + +/** + * @author Brett Meyer + */ +@Entity +@Audited +public class DataPoint { + @Id + @GeneratedValue + private long id; + + private String name; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/src/main/resources/OSGI-INF/blueprint/blueprint.xml new file mode 100644 index 0000000000..81cf11eddc --- /dev/null +++ b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/src/main/resources/OSGI-INF/blueprint/blueprint.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/src/main/resources/ehcache.xml b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/src/main/resources/ehcache.xml new file mode 100644 index 0000000000..11fddc733d --- /dev/null +++ b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/src/main/resources/ehcache.xml @@ -0,0 +1,111 @@ + + + + + + + + + + + + + + + + + --> + + + + diff --git a/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/src/main/resources/hibernate.cfg.xml b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/src/main/resources/hibernate.cfg.xml new file mode 100644 index 0000000000..278f529f89 --- /dev/null +++ b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/src/main/resources/hibernate.cfg.xml @@ -0,0 +1,46 @@ + + + + + + org.h2.Driver + jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;MVCC=TRUE + sa + + org.hibernate.dialect.H2Dialect + create-drop + + + + + + + + + + + + + diff --git a/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/src/main/resources/pool-one.properties b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/src/main/resources/pool-one.properties new file mode 100644 index 0000000000..abaee38558 --- /dev/null +++ b/documentation/src/main/docbook/quickstart/tutorials/osgi/unmanaged-native/src/main/resources/pool-one.properties @@ -0,0 +1,7 @@ +jdbc-0.proxool.alias=pool-one +jdbc-0.proxool.driver-url=jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;MVCC=TRUE +jdbc-0.proxool.driver-class=org.h2.Driver +jdbc-0.user=sa +jdbc-0.password= +jdbc-0.proxool.maximum-connection-count=2 +jdbc-0.proxool.house-keeping-test-sql=select CURRENT_DATE \ No newline at end of file diff --git a/documentation/src/main/docbook/quickstart/tutorials/pom.xml b/documentation/src/main/docbook/quickstart/tutorials/pom.xml index dd3adecac3..9e09ca1c08 100644 --- a/documentation/src/main/docbook/quickstart/tutorials/pom.xml +++ b/documentation/src/main/docbook/quickstart/tutorials/pom.xml @@ -44,6 +44,7 @@ annotations entitymanager envers + osgi