Skip to content

Commit

Permalink
Fixed up licenses, formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthur Taylor committed Apr 4, 2009
1 parent 92ef6bf commit ba65ac4
Show file tree
Hide file tree
Showing 27 changed files with 620 additions and 166 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
* Licensed to the Sakai Foundation (SF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The SF 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.sakaiproject.kernel2.jpatest.model;

import java.io.Serializable;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
* Licensed to the Sakai Foundation (SF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The SF 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.sakaiproject.kernel2.jpatest.model;

import org.eclipse.persistence.jpa.PersistenceProvider;
Expand Down Expand Up @@ -36,8 +54,7 @@ private void createAndRollback() {

System.out.println("Persisted " + g + ", but the transaction was rolled back.");
Greeting g2 = em.find(Greeting.class, g.getId());
System.out.println("Greeting " + g.getId() + " from db: " + g2); // should
// be null
System.out.println("Greeting " + g.getId() + " from db: " + g2);
}

private void initEntityManager() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
* Licensed to the Sakai Foundation (SF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The SF 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.sakaiproject.kernel2.osgi.jpaexample;

import org.osgi.framework.BundleActivator;
Expand All @@ -21,12 +39,12 @@ public void start(BundleContext arg0) throws Exception {
em.getTransaction().begin();
em.persist(model);
em.getTransaction().commit();

System.out.println("Attempting to read back model from database");
// model should be written to database now.
ExampleModel model2 = em.find(ExampleModel.class, model.getId());
System.out.println("Model " + model.getId() + " from db: " + model2);

SystemUser u = new SystemUser();
u.setName("Some user");
em.getTransaction().begin();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
* Licensed to the Sakai Foundation (SF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The SF 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.sakaiproject.kernel2.osgi.jpaexample.jpa.model;

import java.io.Serializable;
Expand All @@ -16,10 +34,9 @@ public class ExampleModel implements Serializable {

@Basic
private String property;

public long getId()
{
return id;

public long getId() {
return id;
}

public void setProperty(String property) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
* Licensed to the Sakai Foundation (SF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The SF 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.sakaiproject.kernel2.osgi.jpahelloworld.model;

import java.io.Serializable;
Expand Down Expand Up @@ -40,8 +58,7 @@ public int hashCode() {

@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not
// set
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Greeting)) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
* Licensed to the Sakai Foundation (SF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The SF 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.sakaiproject.kernel2.osgi.jpahelloworld.model;

import org.eclipse.persistence.config.PersistenceUnitProperties;
Expand Down Expand Up @@ -41,17 +59,16 @@ private void createAndRollback() {

System.out.println("Persisted " + g + ", but the transaction was rolled back.");
Greeting g2 = em.find(Greeting.class, g.getId());
System.out.println("Greeting " + g.getId() + " from db: " + g2); // should
// be null
System.out.println("Greeting " + g.getId() + " from db: " + g2);
}

private void initEntityManager() {
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PersistenceUnitProperties.DDL_GENERATION, PersistenceUnitProperties.DROP_AND_CREATE);
properties.put(PersistenceUnitProperties.DDL_GENERATION_MODE, PersistenceUnitProperties.DDL_DATABASE_GENERATION);
//properties.put(PersistenceUnitProperties.CLASSLOADER, this.getClass().getClassLoader());
emf = new PersistenceProvider()
.createEntityManagerFactory(PERSISTENCE_UNIT_NAME, properties);
properties.put(PersistenceUnitProperties.DDL_GENERATION,
PersistenceUnitProperties.DROP_AND_CREATE);
properties.put(PersistenceUnitProperties.DDL_GENERATION_MODE,
PersistenceUnitProperties.DDL_DATABASE_GENERATION);
emf = new PersistenceProvider().createEntityManagerFactory(PERSISTENCE_UNIT_NAME, properties);
em = emf.createEntityManager();
}

Expand All @@ -62,7 +79,5 @@ public void start(BundleContext arg0) throws Exception {
}

public void stop(BundleContext arg0) throws Exception {
// TODO Auto-generated method stub

}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
* Licensed to the Sakai Foundation (SF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The SF 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.sakaiproject.kernel2.osgi.jpaprovider;

import com.thoughtworks.xstream.XStream;
Expand Down Expand Up @@ -48,8 +66,7 @@ public AmalgamatingClassloader(ClassLoader classLoader) {
public Class<?> loadClass(String name) throws ClassNotFoundException {
BundleGatheringResourceFinder finder = PersistenceBundleMonitor.getBundleResourceFinder();
Class<?> result = finder.loadClass(name);
if (result == null)
{
if (result == null) {
return super.loadClass(name);
}
return result;
Expand Down Expand Up @@ -125,7 +142,8 @@ private URL constructUrl(XStream xstream, XStreamWritable writable, String filen

// The base directory must be empty since JPA will scan it searching for
// classes.
File file = new File(System.getProperty("java.io.tmpdir") + "/sakai" + System.currentTimeMillis() + "/" + filename);
File file = new File(System.getProperty("java.io.tmpdir") + "/sakai"
+ System.currentTimeMillis() + "/" + filename);
if (file.getParentFile().mkdirs()) {
LOG.debug("Created " + file);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
* Licensed to the Sakai Foundation (SF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The SF 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.sakaiproject.kernel2.osgi.jpaprovider;

import org.osgi.framework.Bundle;
Expand Down Expand Up @@ -28,15 +46,12 @@ public List<URL> getResources(String string) {
}
return result;
}

public Class<?> loadClass(String name) {
for (Bundle bundle : bundles) {
try
{
try {
return bundle.loadClass(name);
}
catch (Exception e)
{
} catch (Exception e) {
/* Try another bundle */
}
}
Expand Down
Loading

0 comments on commit ba65ac4

Please sign in to comment.