Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
569 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/.settings | ||
/.classpath | ||
/.project | ||
/target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<features> | ||
<feature name="hibernate-test"> | ||
|
||
<feature>karaf-framework</feature> | ||
|
||
<!-- JTA --> | ||
<bundle start-level="30">mvn:org.apache.geronimo.specs/geronimo-jta_1.1_spec/1.1.1</bundle> | ||
|
||
<!-- JPA --> | ||
<bundle start-level="30">mvn:org.apache.geronimo.specs/geronimo-jpa_2.0_spec/1.1</bundle> | ||
|
||
<!-- Taken from Karaf-Tutorial --> | ||
<bundle>mvn:commons-collections/commons-collections/3.2.1</bundle> | ||
<bundle>mvn:commons-pool/commons-pool/1.5.4</bundle> | ||
<bundle>mvn:commons-dbcp/commons-dbcp/1.4</bundle> | ||
<bundle>mvn:commons-lang/commons-lang/2.6</bundle> | ||
<bundle>wrap:mvn:net.sourceforge.serp/serp/1.13.1</bundle> | ||
|
||
<bundle>mvn:com.h2database/h2/1.3.170</bundle> | ||
|
||
<bundle>mvn:com.fasterxml/classmate/0.5.4</bundle> | ||
<bundle>mvn:org.jboss.spec.javax.security.jacc/jboss-jacc-api_1.4_spec/1.0.2.Final</bundle> | ||
<bundle>mvn:org.jboss.logging/jboss-logging/3.1.0.GA</bundle> | ||
|
||
<!-- These do not natively support OSGi, so using 3rd party bundles. --> | ||
<bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.antlr/2.7.7_5</bundle> | ||
<bundle>mvn:org.jboss.javassist/com.springsource.javassist/3.15.0.GA</bundle> | ||
<bundle>mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.jsr303-api-1.0.0/2.2.0</bundle> | ||
<bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.ant/1.8.2_2</bundle> | ||
<bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.dom4j/1.6.1_5</bundle> | ||
|
||
<!-- These do not natively support OSGi, so wrap with BND. --> | ||
<bundle>wrap:mvn:org.jboss/jandex/1.1.0.Alpha1</bundle> | ||
|
||
<!-- Needed by JACC --> | ||
<bundle>mvn:javax.servlet/javax.servlet-api/3.0.1</bundle> | ||
|
||
<bundle>mvn:org.hibernate.common/hibernate-commons-annotations/4.0.2-SNAPSHOT</bundle> | ||
<bundle>wrap:mvn:javax.validation/validation-api/1.0.0.GA</bundle> | ||
<bundle>mvn:org.hibernate/hibernate-validator/4.2.0.Final</bundle> | ||
|
||
<bundle>mvn:org.hibernate/hibernate-core/4.2.0-SNAPSHOT</bundle> | ||
<bundle>mvn:org.hibernate/hibernate-entitymanager/4.2.0-SNAPSHOT</bundle> | ||
<bundle>mvn:org.hibernate/hibernate-osgi/4.2.0-SNAPSHOT</bundle> | ||
|
||
<bundle>mvn:org.hibernate/HibernateOSGi_AppManaged/1.0.0</bundle> | ||
</feature> | ||
</features> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>org.hibernate</groupId> | ||
<artifactId>HibernateOSGi_AppManaged</artifactId> | ||
<version>1.0.0</version> | ||
<packaging>bundle</packaging> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.geronimo.specs</groupId> | ||
<artifactId>geronimo-jpa_2.0_spec</artifactId> | ||
<version>1.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.felix</groupId> | ||
<artifactId>org.osgi.core</artifactId> | ||
<version>1.4.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.osgi</groupId> | ||
<artifactId>org.osgi.enterprise</artifactId> | ||
<version>4.2.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.karaf.shell</groupId> | ||
<artifactId>org.apache.karaf.shell.console</artifactId> | ||
<version>2.3.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.hibernate</groupId> | ||
<artifactId>hibernate-core</artifactId> | ||
<version>4.2.0-SNAPSHOT</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.h2database</groupId> | ||
<artifactId>h2</artifactId> | ||
<version>1.3.170</version> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.felix</groupId> | ||
<artifactId>maven-bundle-plugin</artifactId> | ||
<extensions>true</extensions> | ||
<configuration> | ||
<instructions> | ||
<Bundle-SymbolicName>${pom.groupId}.${pom.artifactId}</Bundle-SymbolicName> | ||
<Bundle-Name>${pom.artifactId}</Bundle-Name> | ||
<Bundle-Version>1.0.0</Bundle-Version> | ||
<Export-Package> | ||
org.hibernate.osgitest, | ||
org.hibernate.osgitest.entity | ||
</Export-Package> | ||
<Import-Package> | ||
org.apache.felix.service.command, | ||
org.apache.felix.gogo.commands, | ||
org.apache.karaf.shell.console, | ||
org.apache.karaf.shell.commands, | ||
org.hibernate, | ||
org.hibernate.cfg, | ||
org.hibernate.service, | ||
* | ||
</Import-Package> | ||
</instructions> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
37 changes: 37 additions & 0 deletions
37
HibernateOSGi_AppManaged/src/main/java/org/hibernate/osgitest/DataPointService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<DataPoint> getAll(); | ||
|
||
public void deleteAll(); | ||
} |
58 changes: 58 additions & 0 deletions
58
HibernateOSGi_AppManaged/src/main/java/org/hibernate/osgitest/DataPointServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 org.hibernate.Session; | ||
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 List<DataPoint> getAll() { | ||
Session s = HibernateUtil.getSession(); | ||
s.getTransaction().begin(); | ||
List list = s.createQuery( "from DataPoint" ).list(); | ||
s.getTransaction().commit(); | ||
s.close(); | ||
return list; | ||
} | ||
|
||
public void deleteAll() { | ||
Session s = HibernateUtil.getSession(); | ||
s.getTransaction().begin(); | ||
s.createQuery( "delete from DataPoint" ).executeUpdate(); | ||
s.getTransaction().commit(); | ||
s.close(); | ||
} | ||
|
||
} |
49 changes: 49 additions & 0 deletions
49
HibernateOSGi_AppManaged/src/main/java/org/hibernate/osgitest/HibernateUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* 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.hibernate.cfg.Configuration; | ||
import org.hibernate.service.ServiceRegistry; | ||
import org.hibernate.service.ServiceRegistryBuilder; | ||
|
||
/** | ||
* @author Brett Meyer | ||
*/ | ||
|
||
public class HibernateUtil { | ||
|
||
private static SessionFactory sessionFactory = buildSessionFactory(); | ||
|
||
private static SessionFactory buildSessionFactory() { | ||
Configuration configuration = new Configuration(); | ||
configuration.configure(); | ||
ServiceRegistry serviceRegistry = new ServiceRegistryBuilder() | ||
.applySettings(configuration.getProperties()).buildServiceRegistry(); | ||
sessionFactory = configuration.buildSessionFactory(serviceRegistry); | ||
return sessionFactory; | ||
} | ||
|
||
public static Session getSession() { | ||
return sessionFactory.openSession(); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
HibernateOSGi_AppManaged/src/main/java/org/hibernate/osgitest/OsgiTestBundleActivator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* 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.osgi.framework.BundleActivator; | ||
import org.osgi.framework.BundleContext; | ||
|
||
/** | ||
* @author Brett Meyer | ||
*/ | ||
public class OsgiTestBundleActivator implements BundleActivator { | ||
|
||
public void start(BundleContext bc) throws Exception { | ||
|
||
} | ||
|
||
public void stop(BundleContext bc) throws Exception { | ||
|
||
} | ||
|
||
} |
44 changes: 44 additions & 0 deletions
44
HibernateOSGi_AppManaged/src/main/java/org/hibernate/osgitest/command/AddCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
|
||
} |
Oops, something went wrong.