Merge branch 'master' of ssh://git.eclipse.org/gitroot/eclipselink/examples
Conflicts:
jpa/polyglot/web/.project
diff --git a/employee/employee.dynamic/src/test/java/tests/TestCreatePUUsingAPI.java b/employee/employee.dynamic/src/test/java/tests/TestCreatePUUsingAPI.java
deleted file mode 100644
index 9cf69ca..0000000
--- a/employee/employee.dynamic/src/test/java/tests/TestCreatePUUsingAPI.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2013 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * dclarke - Dynamic Persistence INCUBATION - Enhancement 200045
- * http://wiki.eclipse.org/EclipseLink/Development/JPA/Dynamic
- *
- * This code is being developed under INCUBATION and is not currently included
- * in the automated EclipseLink build. The API in this code may change, or
- * may never be included in the product. Please provide feedback through mailing
- * lists or the bug database.
- ******************************************************************************/
-package tests;
-
-import static example.PersistenceHelper.EMPLOYEE_API_PU;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-
-import org.eclipse.persistence.config.PersistenceUnitProperties;
-import org.eclipse.persistence.dynamic.DynamicClassLoader;
-import org.eclipse.persistence.dynamic.DynamicType;
-import org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl;
-import org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl;
-import org.eclipse.persistence.internal.jpa.deployment.SEPersistenceUnitInfo;
-import org.eclipse.persistence.internal.sessions.DatabaseSessionImpl;
-import org.eclipse.persistence.jpa.dynamic.JPADynamicHelper;
-import org.eclipse.persistence.logging.SessionLog;
-import org.eclipse.persistence.tools.schemaframework.SchemaManager;
-import org.junit.Test;
-
-import example.EmployeeDynamicMappings;
-import example.Queries;
-import example.Samples;
-import example.Transactions;
-
-public class TestCreatePUUsingAPI {
-
- @Test
- public void runDynamicAPITest() {
- // Create a dynamic class loader and create the types.
- DynamicClassLoader dcl = new DynamicClassLoader(Thread.currentThread().getContextClassLoader());
- DynamicType[] types = EmployeeDynamicMappings.createTypes(dcl, "example.jpa.dynamic.model.employee");
-
- // Create an entity manager factory.
- EntityManagerFactory emf = createEntityManagerFactory(dcl, EMPLOYEE_API_PU, true);
-
- // Create JPA Dynamic Helper (with the emf above) and after the types
- // have been created and add the types through the helper.
- JPADynamicHelper helper = new JPADynamicHelper(emf);
- helper.addTypes(true, true, types);
-
- // Create database and populate
- new SchemaManager(helper.getSession()).replaceDefaultTables();
-
- EntityManager em = emf.createEntityManager();
- em.getTransaction().begin();
- new Samples(emf).persistAll(em);
- em.getTransaction().commit();
- em.clear();
-
- // Lookup types
- DynamicType empType = helper.getType("Employee");
-
- // Run Queries
- Queries queries = new Queries();
-
- int minEmpId = queries.minimumEmployeeId(em);
- queries.findEmployee(em, empType, minEmpId);
- queries.findEmployeesUsingGenderIn(em);
-
- // Example transactions
- Transactions txn = new Transactions();
-
- txn.createUsingPersist(em);
-
- em.close();
- emf.close();
- }
-
- private EntityManagerFactory createEntityManagerFactory(DynamicClassLoader dcl, String persistenceUnit, boolean createTables) {
- Map<String, Object> props = new HashMap<String, Object>();
-
- // Ensure the persistence.xml provided data source are ignored for Java
- // SE testing
- props.put(PersistenceUnitProperties.NON_JTA_DATASOURCE, "");
- props.put(PersistenceUnitProperties.JTA_DATASOURCE, "");
-
- if (createTables) {
- props.put(PersistenceUnitProperties.DDL_GENERATION, PersistenceUnitProperties.DROP_AND_CREATE);
- props.put(PersistenceUnitProperties.DDL_GENERATION_MODE, PersistenceUnitProperties.DDL_DATABASE_GENERATION);
- }
-
- // Configure the use of embedded derby for the tests allowing system
- // properties of the same name to override
- props.put(PersistenceUnitProperties.JDBC_DRIVER, "org.apache.derby.jdbc.EmbeddedDriver");
- props.put(PersistenceUnitProperties.JDBC_URL, "jdbc:derby:target/derby/dynamic-api;create=true");
- props.put(PersistenceUnitProperties.JDBC_USER, "app");
- props.put(PersistenceUnitProperties.JDBC_PASSWORD, "app");
- props.put(PersistenceUnitProperties.CLASSLOADER, dcl);
- props.put(PersistenceUnitProperties.WEAVING, "static");
- props.put(PersistenceUnitProperties.LOGGING_LEVEL, SessionLog.FINE_LABEL);
-
- SEPersistenceUnitInfo info = new SEPersistenceUnitInfo();
- info.setClassLoader(dcl);
- info.setPersistenceUnitName("test");
- Properties p = new Properties();
- p.putAll(props);
- info.setProperties(p);
-
- EntityManagerSetupImpl setup = new EntityManagerSetupImpl("test", "test");
- setup.predeploy(info, props);
- DatabaseSessionImpl sessionImpl = setup.deploy(dcl, props);
- return new EntityManagerFactoryImpl(sessionImpl);
- }
-
-}
diff --git a/employee/employee.web/src/main/webapp/WEB-INF/template.jsf b/employee/employee.web/src/main/webapp/WEB-INF/template.jsf
deleted file mode 100644
index bed3307..0000000
--- a/employee/employee.web/src/main/webapp/WEB-INF/template.jsf
+++ /dev/null
@@ -1,56 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml"
- xmlns:f="http://java.sun.com/jsf/core"
- xmlns:h="http://java.sun.com/jsf/html"
- xmlns:ui="http://java.sun.com/jsf/facelets">
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
-<title>EclipseLink Employee Example</title>
-<style type="text/css" media="all">
-@import "#{request.contextPath}/css/main.css";
-
-@import "#{request.contextPath}/css/custom.css";
-
-@import "#{request.contextPath}/css/normalize.css";
-</style>
-</head>
-<body>
- <div id="body-container">
- <div id="header-container">
-
- <header class="wrapper clearfix">
- <h1 class="title">Employee Example</h1>
- <nav> <h:form>
- <ul>
- <li><h:commandLink action="/index?faces-redirect=true"
- value="Home" /></li>
- <li><h:commandLink action="/about?faces-redirect=true"
- value="About" /></li>
- <li><h:commandLink action="/admin?faces-redirect=true"
- value="Admin" /></li>
- </ul>
- </h:form></nav> </header>
- </div>
-
-
- <div id="main-container">
- <div class="main wrapper clearfix">
-
- <article> <header> <ui:insert name="body" /> </header> </article>
-
- <aside> <img
- src="#{request.contextPath}/images/eclipselink-logo.png"
- alt="EclipseLink" border="0" class="logo"
- title="EclipseLink Employee Example" /> <ui:insert
- name="eclipselink" /> </aside>
-
- </div>
- </div>
-
- <div id="footer-container">
- <footer class="wrapper"> <h:messages /> </footer>
- </div>
- </div>
-</body>
-</html>
diff --git a/jpa/employee/employee.model/createDDL.jdbc b/jpa/employee/employee.model/createDDL.jdbc
deleted file mode 100644
index 9d05b6b..0000000
--- a/jpa/employee/employee.model/createDDL.jdbc
+++ /dev/null
@@ -1,23 +0,0 @@
-CREATE TABLE PROJECT (PROJ_ID INTEGER NOT NULL, PROJ_TYPE VARCHAR(31), DESCRIP VARCHAR(255), PROJ_NAME VARCHAR(255), VERSION BIGINT, LEADER_ID INTEGER, PRIMARY KEY (PROJ_ID))
-CREATE TABLE ADDRESS (ADDRESS_ID INTEGER NOT NULL, CITY VARCHAR(255), COUNTRY CLOB(2147483647), P_CODE VARCHAR(255), PROVINCE VARCHAR(255), STREET VARCHAR(255), PRIMARY KEY (ADDRESS_ID))
-CREATE TABLE EMPLOYEE (EMP_ID INTEGER NOT NULL, F_NAME VARCHAR(255), GENDER VARCHAR(255), L_NAME VARCHAR(255), VERSION BIGINT, END_DATE DATE, START_DATE DATE, MANAGER_ID INTEGER, ADDR_ID INTEGER, PRIMARY KEY (EMP_ID))
-CREATE TABLE SALARY (EMP_ID INTEGER NOT NULL, SALARY FLOAT, PRIMARY KEY (EMP_ID))
-CREATE TABLE PHONE (TYPE VARCHAR(255) NOT NULL, AREA_CODE VARCHAR(255), EMP_ID INTEGER NOT NULL, P_NUMBER VARCHAR(255), PRIMARY KEY (TYPE, EMP_ID))
-CREATE TABLE LPROJECT (PROJ_ID INTEGER NOT NULL, BUDGET FLOAT, MILESTONE TIMESTAMP, PRIMARY KEY (PROJ_ID))
-CREATE TABLE RESPONS (Employee_EMP_ID INTEGER, RESPONSIBILITIES VARCHAR(255))
-CREATE TABLE PROJ_EMP (EMP_ID INTEGER NOT NULL, PROJ_ID INTEGER NOT NULL, PRIMARY KEY (EMP_ID, PROJ_ID))
-ALTER TABLE PROJECT ADD CONSTRAINT PROJECT_LEADER_ID FOREIGN KEY (LEADER_ID) REFERENCES EMPLOYEE (EMP_ID)
-ALTER TABLE EMPLOYEE ADD CONSTRAINT EMPLOYEEMANAGER_ID FOREIGN KEY (MANAGER_ID) REFERENCES EMPLOYEE (EMP_ID)
-ALTER TABLE EMPLOYEE ADD CONSTRAINT EMPLOYEE_ADDR_ID FOREIGN KEY (ADDR_ID) REFERENCES ADDRESS (ADDRESS_ID)
-ALTER TABLE SALARY ADD CONSTRAINT FK_SALARY_EMP_ID FOREIGN KEY (EMP_ID) REFERENCES EMPLOYEE (EMP_ID)
-ALTER TABLE PHONE ADD CONSTRAINT FK_PHONE_EMP_ID FOREIGN KEY (EMP_ID) REFERENCES EMPLOYEE (EMP_ID)
-ALTER TABLE LPROJECT ADD CONSTRAINT LPROJECT_PROJ_ID FOREIGN KEY (PROJ_ID) REFERENCES PROJECT (PROJ_ID)
-ALTER TABLE RESPONS ADD CONSTRAINT RSPONSmployeeEMPID FOREIGN KEY (Employee_EMP_ID) REFERENCES EMPLOYEE (EMP_ID)
-ALTER TABLE PROJ_EMP ADD CONSTRAINT FK_PROJ_EMP_EMP_ID FOREIGN KEY (EMP_ID) REFERENCES EMPLOYEE (EMP_ID)
-ALTER TABLE PROJ_EMP ADD CONSTRAINT PROJ_EMP_PROJ_ID FOREIGN KEY (PROJ_ID) REFERENCES PROJECT (PROJ_ID)
-CREATE TABLE SEQUENCE (SEQ_NAME VARCHAR(50) NOT NULL, SEQ_COUNT DECIMAL(15), PRIMARY KEY (SEQ_NAME))
-INSERT INTO SEQUENCE(SEQ_NAME, SEQ_COUNT) values ('SEQ_GEN', 0)
-CREATE SEQUENCE ADDR_SEQ INCREMENT BY 50 START WITH 50
-CREATE TABLE SEQUENCE (SEQ_NAME VARCHAR(50) NOT NULL, SEQ_COUNT DECIMAL(15), PRIMARY KEY (SEQ_NAME))
-CREATE SEQUENCE ADDR_SEQ INCREMENT BY 50 START WITH 50
-INSERT INTO SEQUENCE(SEQ_NAME, SEQ_COUNT) values ('SEQ_GEN', 0)
diff --git a/jpa/employee/employee.model/dropDDL.jdbc b/jpa/employee/employee.model/dropDDL.jdbc
deleted file mode 100644
index c4e8cbe..0000000
--- a/jpa/employee/employee.model/dropDDL.jdbc
+++ /dev/null
@@ -1,19 +0,0 @@
-ALTER TABLE PROJECT DROP CONSTRAINT PROJECT_LEADER_ID
-ALTER TABLE EMPLOYEE DROP CONSTRAINT EMPLOYEEMANAGER_ID
-ALTER TABLE EMPLOYEE DROP CONSTRAINT EMPLOYEE_ADDR_ID
-ALTER TABLE SALARY DROP CONSTRAINT FK_SALARY_EMP_ID
-ALTER TABLE PHONE DROP CONSTRAINT FK_PHONE_EMP_ID
-ALTER TABLE LPROJECT DROP CONSTRAINT LPROJECT_PROJ_ID
-ALTER TABLE RESPONS DROP CONSTRAINT RSPONSmployeeEMPID
-ALTER TABLE PROJ_EMP DROP CONSTRAINT FK_PROJ_EMP_EMP_ID
-ALTER TABLE PROJ_EMP DROP CONSTRAINT PROJ_EMP_PROJ_ID
-DROP TABLE PROJECT
-DROP TABLE ADDRESS
-DROP TABLE EMPLOYEE
-DROP TABLE SALARY
-DROP TABLE PHONE
-DROP TABLE LPROJECT
-DROP TABLE RESPONS
-DROP TABLE PROJ_EMP
-DROP SEQUENCE ADDR_SEQ RESTRICT
-DELETE FROM SEQUENCE WHERE SEQ_NAME = 'SEQ_GEN'
diff --git a/jpa/employee/employee.web/.classpath b/jpa/employee/employee.web/.classpath
index 0f4a4c2..fcfac2c 100644
--- a/jpa/employee/employee.web/.classpath
+++ b/jpa/employee/employee.web/.classpath
@@ -6,11 +6,6 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
- <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
- <attributes>
- <attribute name="maven.pomderived" value="true"/>
- </attributes>
- </classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
diff --git a/jpa/polyglot/client/.project b/jpa/polyglot/client/.project
index 3ee038d..057924c 100644
--- a/jpa/polyglot/client/.project
+++ b/jpa/polyglot/client/.project
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
- <name>client</name>
+ <name>polyglot.client</name>
<comment></comment>
<projects>
</projects>
diff --git a/jpa/polyglot/composite-pu/.project b/jpa/polyglot/composite-pu/.project
index 559e2bb..ad76521 100644
--- a/jpa/polyglot/composite-pu/.project
+++ b/jpa/polyglot/composite-pu/.project
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
- <name>composite-pu</name>
+ <name>polyglot.composite-pu</name>
<comment></comment>
<projects>
</projects>
diff --git a/jpa/polyglot/nosql-pu/.project b/jpa/polyglot/nosql-pu/.project
index 81cec1b..4fa5566 100644
--- a/jpa/polyglot/nosql-pu/.project
+++ b/jpa/polyglot/nosql-pu/.project
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
- <name>nosql-pu</name>
+ <name>polyglot.nosql-pu</name>
<comment></comment>
<projects>
</projects>
diff --git a/jpa/polyglot/relational-pu/.project b/jpa/polyglot/relational-pu/.project
index 9d0f3ff..152c4c0 100644
--- a/jpa/polyglot/relational-pu/.project
+++ b/jpa/polyglot/relational-pu/.project
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
- <name>relational-pu</name>
+ <name>polyglot.relational-pu</name>
<comment></comment>
<projects>
</projects>
diff --git a/mysports/README.md b/mysports/README.md
new file mode 100644
index 0000000..1fabfc9
--- /dev/null
+++ b/mysports/README.md
@@ -0,0 +1,6 @@
+EclipseLink MySports Example Application
+========================================
+
+This example application illustrates some of the latest features in EclipseLink 2.4 including extensible entities, tenant isolation, and externalized metadata storage.
+
+http://wiki.eclipse.org/EclipseLink/Examples/MySports
diff --git a/mysports/admin.services/.classpath b/mysports/admin.services/.classpath
new file mode 100644
index 0000000..9a07d21
--- /dev/null
+++ b/mysports/admin.services/.classpath
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" output="target/classes" path="src/main/java">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/resource"/>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/java">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
diff --git a/mysports/admin.services/.project b/mysports/admin.services/.project
new file mode 100644
index 0000000..8ae8a9c
--- /dev/null
+++ b/mysports/admin.services/.project
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>mysports.admin.services</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.wst.common.project.facet.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.wst.validation.validationbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.m2e.core.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
+ <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.m2e.core.maven2Nature</nature>
+ <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+ </natures>
+</projectDescription>
diff --git a/mysports/admin.services/.settings/org.eclipse.jdt.core.prefs b/mysports/admin.services/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..443e085
--- /dev/null
+++ b/mysports/admin.services/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.7
diff --git a/mysports/admin.services/.settings/org.eclipse.jpt.core.prefs b/mysports/admin.services/.settings/org.eclipse.jpt.core.prefs
new file mode 100644
index 0000000..716ada6
--- /dev/null
+++ b/mysports/admin.services/.settings/org.eclipse.jpt.core.prefs
@@ -0,0 +1,10 @@
+eclipse.preferences.version=1
+org.eclipse.jpt.core.platform=eclipselink2_4
+org.eclipse.jpt.jpa.core.discoverAnnotatedClasses=false
+problem.EMBEDDED_ID_CLASS_SHOULD_NOT_CONTAIN_RELATIONSHIP_MAPPINGS=error
+problem.MAPPING_INVALID_MAPPED_BY=warning
+problem.MAPS_ID_VALUE_INVALID=error
+problem.PROJECT_INACTIVE_CONNECTION=info
+problem.PROJECT_INVALID_CONNECTION=info
+problem.TYPE_MAPPING_ID_CLASS_ATTRIBUTE_TYPE_DOES_NOT_AGREE=warning
+workspace_preferences_overriden=true
diff --git a/mysports/admin.services/.settings/org.eclipse.m2e.core.prefs b/mysports/admin.services/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 0000000..f897a7f
--- /dev/null
+++ b/mysports/admin.services/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/mysports/admin.services/.settings/org.eclipse.wst.common.component b/mysports/admin.services/.settings/org.eclipse.wst.common.component
new file mode 100644
index 0000000..7a26529
--- /dev/null
+++ b/mysports/admin.services/.settings/org.eclipse.wst.common.component
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
+ <wb-module deploy-name="mysports.admin.services">
+ <wb-resource deploy-path="/" source-path="/ejbModule" tag="defaultRootSource"/>
+ <wb-resource deploy-path="/" source-path="/src/main/java"/>
+ <wb-resource deploy-path="/" source-path="/src/test/resource"/>
+ <wb-resource deploy-path="/" source-path="/src/test/java"/>
+ <wb-resource deploy-path="/" source-path="/src/main/resources"/>
+ <property name="java-output-path" value="/mysports.admin.services/target/classes"/>
+ </wb-module>
+</project-modules>
diff --git a/mysports/admin.services/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml b/mysports/admin.services/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml
new file mode 100644
index 0000000..7961132
--- /dev/null
+++ b/mysports/admin.services/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml
@@ -0,0 +1,7 @@
+<root>
+ <facet id="jpt.jpa">
+ <node name="libprov">
+ <attribute name="provider-id" value="jpa-no-op-library-provider"/>
+ </node>
+ </facet>
+</root>
diff --git a/mysports/admin.services/.settings/org.eclipse.wst.common.project.facet.core.xml b/mysports/admin.services/.settings/org.eclipse.wst.common.project.facet.core.xml
new file mode 100644
index 0000000..4f901b8
--- /dev/null
+++ b/mysports/admin.services/.settings/org.eclipse.wst.common.project.facet.core.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+ <installed facet="java" version="1.7"/>
+ <installed facet="jpt.jpa" version="2.0"/>
+ <installed facet="jst.ejb" version="3.1"/>
+</faceted-project>
diff --git "a/mysports/admin.services/eclipse-runconfigs/CreateDatabaseTest \0501\051.launch" "b/mysports/admin.services/eclipse-runconfigs/CreateDatabaseTest \0501\051.launch"
new file mode 100644
index 0000000..18e6598
--- /dev/null
+++ "b/mysports/admin.services/eclipse-runconfigs/CreateDatabaseTest \0501\051.launch"
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/MySports Admin Services/src/test/java/eclipselink/example/mysports/admin/services/test/CreateDatabaseTest.java"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="1"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
+<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
+<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
+<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="eclipselink.example.mysports.admin.services.test.CreateDatabaseTest"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="MySports Admin Services"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-javaagent:${system_property:user.home}/.m2/repository/org/eclipse/persistence/eclipselink/2.4.2-SNAPSHOT/eclipselink-2.4.2-SNAPSHOT.jar -Djavax.persistence.jdbc.driver=com.mysql.jdbc.Driver"/>
+</launchConfiguration>
diff --git a/mysports/admin.services/eclipse-runconfigs/CreateDatabaseTest.launch b/mysports/admin.services/eclipse-runconfigs/CreateDatabaseTest.launch
new file mode 100644
index 0000000..03bec91
--- /dev/null
+++ b/mysports/admin.services/eclipse-runconfigs/CreateDatabaseTest.launch
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/TestCreateDatabase.java"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="1"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
+<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
+<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
+<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="eclipselink.example.mysports.admin.services.test.CreateDatabaseTest"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="admin.services"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-javaagent:${system_property:user.home}/.m2/repository/eclipselink/example/mysports/persistence/2.4.2-SNAPSHOT/persistence-2.4.2-SNAPSHOT.jar"/>
+</launchConfiguration>
diff --git a/mysports/admin.services/eclipse-runconfigs/TestCreateHostEnvironments.launch b/mysports/admin.services/eclipse-runconfigs/TestCreateHostEnvironments.launch
new file mode 100644
index 0000000..c2fb749
--- /dev/null
+++ b/mysports/admin.services/eclipse-runconfigs/TestCreateHostEnvironments.launch
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/TestCreateHostEnvironments.java"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="1"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
+<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
+<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
+<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="eclipselink.example.mysports.admin.services.test.TestCreateHostEnvironments"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="admin.services"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-javaagent:${system_property:user.home}/.m2/repository/eclipselink/example/mysports/persistence/0.0.1-SNAPSHOT/persistence-0.0.1-SNAPSHOT.jar"/>
+</launchConfiguration>
diff --git "a/mysports/admin.services/eclipse-runconfigs/TestCreateLeagues \0501\051.launch" "b/mysports/admin.services/eclipse-runconfigs/TestCreateLeagues \0501\051.launch"
new file mode 100644
index 0000000..ae81ceb
--- /dev/null
+++ "b/mysports/admin.services/eclipse-runconfigs/TestCreateLeagues \0501\051.launch"
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/MySports Admin Services/src/test/java/eclipselink/example/mysports/admin/services/test/TestCreateLeagues.java"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="1"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
+<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
+<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
+<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="eclipselink.example.mysports.admin.services.test.TestCreateLeagues"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="MySports Admin Services"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-javaagent:${system_property:user.home}/.m2/repository/org/eclipse/persistence/eclipselink/2.4.2-SNAPSHOT/eclipselink-2.4.2-SNAPSHOT.jar"/>
+</launchConfiguration>
diff --git a/mysports/admin.services/eclipse-runconfigs/TestCreateLeagues.launch b/mysports/admin.services/eclipse-runconfigs/TestCreateLeagues.launch
new file mode 100644
index 0000000..9a0482e
--- /dev/null
+++ b/mysports/admin.services/eclipse-runconfigs/TestCreateLeagues.launch
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/TestCreateLeagues.java"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="1"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
+<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
+<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
+<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="eclipselink.example.mysports.admin.services.test.TestCreateLeagues"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="admin.services"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-javaagent:${system_property:user.home}/.m2/repository/eclipselink/example/mysports/persistence/2.4.2-SNAPSHOT/persistence-2.4.2-SNAPSHOT.jar"/>
+</launchConfiguration>
diff --git a/mysports/admin.services/eclipse-runconfigs/TestCreateOrmXml.launch b/mysports/admin.services/eclipse-runconfigs/TestCreateOrmXml.launch
new file mode 100644
index 0000000..db0f979
--- /dev/null
+++ b/mysports/admin.services/eclipse-runconfigs/TestCreateOrmXml.launch
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/extensions/TestCreateOrmXml.java"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="1"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
+<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
+<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
+<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="eclipselink.example.mysports.admin.services.test.extensions.TestCreateOrmXml"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="admin.services"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-javaagent:${system_property:user.home}/.m2/repository/eclipselink/example/mysports/persistence/2.4.2-SNAPSHOT/persistence-2.4.2-SNAPSHOT.jar"/>
+</launchConfiguration>
diff --git a/mysports/admin.services/eclipse-runconfigs/TestCreateStyles.launch b/mysports/admin.services/eclipse-runconfigs/TestCreateStyles.launch
new file mode 100644
index 0000000..bf55ed0
--- /dev/null
+++ b/mysports/admin.services/eclipse-runconfigs/TestCreateStyles.launch
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/style/TestCreateStyles.java"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="1"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
+<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
+<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
+<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="eclipselink.example.mysports.admin.services.test.style.TestCreateStyles"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="admin.services"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-javaagent:${system_property:user.home}/.m2/repository/eclipselink/example/mysports/persistence/2.4.2-SNAPSHOT/persistence-2.4.2-SNAPSHOT.jar"/>
+</launchConfiguration>
diff --git a/mysports/admin.services/eclipse-runconfigs/TestHostedLeagueRepository.launch b/mysports/admin.services/eclipse-runconfigs/TestHostedLeagueRepository.launch
new file mode 100644
index 0000000..42e3f9b
--- /dev/null
+++ b/mysports/admin.services/eclipse-runconfigs/TestHostedLeagueRepository.launch
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/TestHostedLeagueRepository.java"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="1"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
+<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
+<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
+<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="eclipselink.example.mysports.admin.services.test.TestHostedLeagueRepository"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="admin.services"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-javaagent:${system_property:user.home}/.m2/repository/eclipselink/example/mysports/persistence/2.4.2-SNAPSHOT/persistence-2.4.2-SNAPSHOT.jar"/>
+</launchConfiguration>
diff --git a/mysports/admin.services/eclipse-runconfigs/VerifyModelAndMappingsTest.launch b/mysports/admin.services/eclipse-runconfigs/VerifyModelAndMappingsTest.launch
new file mode 100644
index 0000000..1cefc64
--- /dev/null
+++ b/mysports/admin.services/eclipse-runconfigs/VerifyModelAndMappingsTest.launch
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/MySports Admin Services/src/test/java/eclipselink/example/mysports/admin/services/test/VerifyModelAndMappingsTest.java"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="1"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
+<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
+<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
+<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="eclipselink.example.mysports.admin.services.test.VerifyModelAndMappingsTest"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="MySports Admin Services"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-javaagent:${system_property:user.home}/.m2/repository/org/eclipse/persistence/eclipselink/2.4.2-SNAPSHOT/eclipselink-2.4.2-SNAPSHOT.jar"/>
+</launchConfiguration>
diff --git a/mysports/admin.services/ejbModule/META-INF/MANIFEST.MF b/mysports/admin.services/ejbModule/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..5e94951
--- /dev/null
+++ b/mysports/admin.services/ejbModule/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
diff --git a/mysports/admin.services/pom.xml b/mysports/admin.services/pom.xml
new file mode 100644
index 0000000..0f5f666
--- /dev/null
+++ b/mysports/admin.services/pom.xml
@@ -0,0 +1,161 @@
+<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>
+
+ <parent>
+ <groupId>eclipselink.example.mysports</groupId>
+ <artifactId>bom</artifactId>
+ <version>2.4.2-SNAPSHOT</version>
+ <relativePath>..</relativePath>
+ </parent>
+
+ <artifactId>admin.services</artifactId>
+ <packaging>jar</packaging>
+ <name>MySports Admin Services</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>${eclipselink.groupid}</groupId>
+ <artifactId>eclipselink</artifactId>
+ <version>${eclipselink.version}</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>commonj.sdo</artifactId>
+ <groupId>commonj.sdo</groupId>
+ </exclusion>
+ </exclusions>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-client</artifactId>
+ <version>1.16</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.derby</groupId>
+ <artifactId>derby</artifactId>
+ <version>10.9.1.0</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <version>5.1.22</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.0</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.12.4</version>
+ <configuration>
+ <argLine>-javaagent:../persistence/target/persistence-${project.version}.jar</argLine>
+ <excludedGroups>eclipselink.example.mysports.admin.services.test.services.ServerTests</excludedGroups>
+ <systemProperties>
+ <property>
+ <name>derby.stream.error.file</name>
+ <value>target/derby.log</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.4</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>mysql</id>
+ <activation>
+ <property>
+ <name>mysql</name>
+ </property>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <version>5.1.22</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.12.4</version>
+ <configuration>
+ <systemProperties>
+ <property>
+ <name>javax.persistence.jdbc.url</name>
+ <value>jdbc:mysql://localhost:3306/mysports</value>
+ </property>
+ <property>
+ <name>javax.persistence.jdbc.driver</name>
+ <value>com.mysql.jdbc.Driver</value>
+ </property>
+ <property>
+ <name>javax.persistence.jdbc.user</name>
+ <value>mysports</value>
+ </property>
+ <property>
+ <name>javax.persistence.jdbc.password</name>
+ <value>mysports</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+</project>
diff --git a/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/examples/ExampleLeagueDefinition.java b/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/examples/ExampleLeagueDefinition.java
new file mode 100644
index 0000000..2c2905c
--- /dev/null
+++ b/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/examples/ExampleLeagueDefinition.java
@@ -0,0 +1,133 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.4 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.admin.examples;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringWriter;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+
+import eclipselink.example.mysports.admin.model.HostedLeague;
+import eclipselink.example.mysports.admin.services.HostedLeagueRepository;
+
+/**
+ * TODO
+ *
+ * @author dclarke
+ * @since EclipseLink 2.4.2
+ */
+public abstract class ExampleLeagueDefinition {
+
+ private HostedLeague league;
+
+ public ExampleLeagueDefinition(String id, String name, String scheme, String logoUrl, String dataSource) {
+ this.league = new HostedLeague(id, name, scheme);
+ this.league.setLogoUrl(logoUrl);
+ this.league.setDatasourceName(dataSource);
+ addExtensions();
+ }
+
+ public HostedLeague getLeague() {
+ return league;
+ }
+
+ protected abstract void addExtensions();
+
+ public static ExampleLeagueDefinition OSL = new ExampleLeagueDefinition("OSL", "Ottawa Soccer League", "black", "/logos/osl.png", "jdbc/MySports") {
+ @Override
+ protected void addExtensions() {
+ getLeague().addPlayerExtension("allergies", "java.lang.String", "FLEX_1");
+ }
+ };
+
+ public static ExampleLeagueDefinition HTHL = new ExampleLeagueDefinition("HTHL", "High Tech Hockey League", "red", "/logos/hthl.png", "jdbc/MySports") {
+ @Override
+ protected void addExtensions() {
+ getLeague().addPlayerExtension("position", "java.lang.String", "FLEX_1");
+ getLeague().addPlayerExtension("penaltyMinutes", "java.lang.Integer", "FLEX_2");
+ }
+ };
+
+ public static ExampleLeagueDefinition KFL = new ExampleLeagueDefinition("KFL", "Kid's Football League", "green", "/logos/kfl.png", "jdbc/MySports") {
+ @Override
+ protected void addExtensions() {
+ getLeague().addPlayerExtension("position", "java.lang.String", "FLEX_1");
+ }
+ };
+
+ public static ExampleLeagueDefinition MHL = new ExampleLeagueDefinition("MHL", "Minor Hockey League", "red", "/logos/mhl.png", "jdbc/MySportsMHL") {
+ @Override
+ protected void addExtensions() {
+ getLeague().addPlayerExtension("position", "java.lang.String", "FLEX_1");
+ }
+ };
+
+ public static void populateAll(HostedLeagueRepository repository) {
+ repository.create(OSL.getLeague());
+ repository.create(KFL.getLeague());
+ repository.create(MHL.getLeague());
+ repository.create(HTHL.getLeague());
+ createStyles(repository);
+ }
+
+ public static void clearDatabase(EntityManagerFactory emf) {
+ EntityManager em = emf.createEntityManager();
+
+ try {
+ em.getTransaction().begin();
+ em.createNativeQuery("DELETE FROM mys_admin_player_ext").executeUpdate();
+ em.createNativeQuery("DELETE FROM mys_admin_team_ext").executeUpdate();
+ em.createNativeQuery("DELETE FROM mys_admin_div_ext").executeUpdate();
+ em.createQuery("DELETE FROM HostedLeague").executeUpdate();
+ em.createQuery("DELETE FROM Style").executeUpdate();
+ em.getTransaction().commit();
+ } finally {
+ em.close();
+ }
+ }
+
+ public static void createStyles(HostedLeagueRepository repository) {
+ repository.createStyle("default", load("blue"));
+ repository.createStyle("red", load("red"));
+ repository.createStyle("black", load("black"));
+ repository.createStyle("blue", load("blue"));
+ repository.createStyle("green", load("green"));
+ }
+
+ private static String load(String name) {
+ String resource = name + ".css";
+ InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
+
+ if (in == null) {
+ throw new IllegalArgumentException("Could not find CSS for '" + name + " @ " + resource);
+ }
+ try {
+ StringWriter writer = new StringWriter(in.available());
+ for (int ch = in.read(); ch >= 0; ch = in.read()) {
+ writer.write(ch);
+ }
+ return writer.toString();
+ } catch (IOException ioe) {
+ throw new RuntimeException(ioe);
+ } finally {
+ try {
+ in.close();
+ } catch (IOException e) {
+ }
+ }
+
+ }
+
+}
diff --git a/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/model/DataIsolation.java b/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/model/DataIsolation.java
new file mode 100644
index 0000000..70cab3c
--- /dev/null
+++ b/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/model/DataIsolation.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.4 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.admin.model;
+
+import org.eclipse.persistence.annotations.Multitenant;
+
+/**
+ * This enum describes the various data isolation modes the MySports example
+ * application supports. It leverages the {@link Multitenant} types supported by
+ * EclipseLink combined with application specific usage.
+ *
+ * @author dclarke
+ * @since EclipseLink 2.4
+ */
+public enum DataIsolation {
+
+ /**
+ * The data for this league in the same table as other leagues.
+ *
+ * @Multitenant(SINGLE_TABLE)
+ */
+ ROW,
+
+ /**
+ * The data for this league is stored in its own table within a shared
+ * schema using the league identifier as a suffix to the default table name
+ *
+ * @Multitenant(TABLE_PER_TENANT)
+ * @TenantTableDiscriminator(type=SUFFIX)
+ */
+ TABLE,
+
+ /**
+ * The data for this league is stored in its own table within a shared
+ * schema using the league identifier as the schema name
+ *
+ * @Multitenant(TABLE_PER_TENANT)
+ * @TenantTableDiscriminator(type=SCHEMA)
+ */
+ SCHEMA,
+
+ /**
+ * The data for this league is stored in a dedicated database. It is the
+ * responsibility of the deployer to ensure that a data source is specified
+ * that is dedicated to this tenant.
+ */
+ DATABASE
+}
diff --git a/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/model/Datasource.java b/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/model/Datasource.java
new file mode 100644
index 0000000..98cc24b
--- /dev/null
+++ b/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/model/Datasource.java
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.4 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.admin.model;
+
+
+/**
+ * Represents an application's datasource. Within the admin application each
+ * data source is managed with both the name in host container as well as the
+ * detailed JDBC information to support schema provisioning.
+ *
+ * @author dclarke
+ * @since EclipseLink 2.4
+ */
+public class Datasource {
+ /**
+ * Data source JNDI name
+ */
+ private String name;
+
+ private String description;
+
+ private String driver;
+
+ private String url;
+
+ private String user;
+
+ private String password;
+
+ private long version;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getDriver() {
+ return driver;
+ }
+
+ public void setDriver(String driver) {
+ this.driver = driver;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ public String getUser() {
+ return user;
+ }
+
+ public void setUser(String user) {
+ this.user = user;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public long getVersion() {
+ return version;
+ }
+
+ public String toString() {
+ return "DataSource[" + getName() + "]";
+ }
+}
diff --git a/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/model/Extension.java b/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/model/Extension.java
new file mode 100644
index 0000000..ae9c5c9
--- /dev/null
+++ b/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/model/Extension.java
@@ -0,0 +1,139 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.admin.model;
+
+import java.io.Serializable;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.IdClass;
+import javax.persistence.Table;
+
+/**
+ * An extension represents an additional 'virtual' attribute that an entity in
+ * the MySports application can store.
+ *
+ * @author dclarke
+ * @since EclipseLink 2.3.0
+ */
+@Entity
+@IdClass(Extension.ID.class)
+@Table(name = "MYS_ADMIN_EXT")
+public class Extension {
+
+ @Id
+ private HostedLeague league;
+
+ @Id
+ private String type;
+
+ @Id
+ private String name = "";
+
+ @Column(name = "JTYPE")
+ private String javaType = "java.lang.String";
+
+ private String columnName;
+
+ public Extension() {
+ }
+
+ public Extension(String name, String javaType, String columnName) {
+ setName(name);
+ setJavaType(javaType);
+ setColumnName(columnName);
+ }
+
+ public HostedLeague getLeague() {
+ return league;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ protected void setLeague(HostedLeague league, String type) {
+ this.league = league;
+ this.type = type;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getJavaType() {
+ return javaType;
+ }
+
+ public void setJavaType(String javaType) {
+ this.javaType = javaType;
+ }
+
+ public String getColumnName() {
+ return columnName;
+ }
+
+ public void setColumnName(String columnName) {
+ this.columnName = columnName;
+ }
+
+ public static class ID implements Serializable {
+ private static final long serialVersionUID = 1L;
+ private String league;
+ private String type;
+ private String name;
+
+ public ID() {
+ super();
+ }
+
+ public ID(String league, String type, String name) {
+ super();
+ this.league = league;
+ this.type = type;
+ this.name = name;
+ }
+
+ public String getLeague() {
+ return league;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public int hashCode() {
+ return getLeague().hashCode() + getType().hashCode() + getName().hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj != null && getClass().isAssignableFrom(obj.getClass())) {
+ ID id = (ID) obj;
+ return getLeague().equals(id.getLeague()) && getType().equals(id.getType()) && getName().equals(id.getName());
+ }
+ return false;
+ }
+
+ }
+}
diff --git a/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/model/GlassFish.java b/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/model/GlassFish.java
new file mode 100644
index 0000000..186e904
--- /dev/null
+++ b/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/model/GlassFish.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.4 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.admin.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Entity;
+
+import eclipselink.example.mysports.admin.services.glassfish.JDBCResource;
+import eclipselink.example.mysports.admin.services.glassfish.RESTOperations;
+
+/**
+ * Represents a single GlassFish instance.
+ *
+ * @author dclarke
+ * @since EclipseLink 2.4
+ */
+@Entity
+@DiscriminatorValue("GlassFish")
+public class GlassFish extends HostEnvironment {
+
+ public List<Datasource> getDatasources() {
+ List<Datasource> datasources = new ArrayList<Datasource>();
+ RESTOperations ops = new RESTOperations("localhost");
+ String[] resourceNames = JDBCResource.getJDBCResourceNames(ops);
+
+ for (String name : resourceNames) {
+ Datasource ds = new Datasource();
+ ds.setName(name);
+ datasources.add(ds);
+ }
+ return datasources;
+ }
+}
diff --git a/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/model/HostEnvironment.java b/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/model/HostEnvironment.java
new file mode 100644
index 0000000..7cb7828
--- /dev/null
+++ b/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/model/HostEnvironment.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.4 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.admin.model;
+
+import java.util.Collection;
+
+import javax.persistence.DiscriminatorColumn;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
+
+/**
+ * Represents a target environment where the MySports application can be
+ * deployed to. This could be a specific web or application server, a
+ * cluster/grid of servers, or a cloud implementation.
+ *
+ * @author dclarke
+ * @since EclipseLink 2.4
+ */
+@Entity
+@Table(name="MYS_ADMIN_ENV")
+@Inheritance(strategy=InheritanceType.JOINED)
+@DiscriminatorColumn(name="ENV_TYPE")
+@NamedQuery(name="HostEnvironment.all", query="SELECT he FROM HostEnvironment he ORDER BY he.id")
+public abstract class HostEnvironment {
+
+ @Id
+ @GeneratedValue
+ private int id;
+
+ private String name;
+
+ private String description;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public abstract Collection<Datasource> getDatasources();
+
+
+}
diff --git a/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/model/HostedLeague.java b/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/model/HostedLeague.java
new file mode 100644
index 0000000..5a8af27
--- /dev/null
+++ b/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/model/HostedLeague.java
@@ -0,0 +1,265 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.admin.model;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.Id;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+import javax.persistence.Version;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+
+import org.eclipse.persistence.annotations.Customizer;
+
+import eclipselink.example.mysports.admin.model.persistence.ExtensionMappingsCustomizer;
+
+/**
+ * A HostedLeague represents a sports league that is configured in the MySports
+ * Admin application. It contains the league's (tenant) configuration with
+ * respect to EclipseLink customization of data source, multi-tenancy, table
+ * names, and extended attributes. It also contains Look-and-Feel configuration
+ * for color scheme (CSS) and logo.
+ *
+ * @author dclarke
+ * @since EclipseLink 2.3.0
+ */
+@Entity
+@Table(name = "MYS_ADMIN_LEAGUE")
+@NamedQueries({ @NamedQuery(name = "HostedLeague.findAll", query = "SELECT l FROM HostedLeague l ORDER BY l.name"), @NamedQuery(name = "HostedLeague.findAllShared", query = "SELECT l FROM HostedLeague l WHERE l.shared = TRUE ORDER BY l.name") })
+@Customizer(ExtensionMappingsCustomizer.class)
+@XmlRootElement
+public class HostedLeague {
+
+ public static final String PLAYER = "Player";
+ public static final String TEAM = "Team";
+ public static final String DIVISION = "Division";
+
+ /**
+ * Unique identifier for the league. This must be a simple string with just
+ * characters that can be used within a URI.
+ */
+ @Id
+ private String id;
+
+ /**
+ * Descriptive name of league. This string is used for display purposes only
+ * and can contain spaces and punctuation.
+ */
+ private String name;
+
+ private String colourScheme = "default";
+
+ private String logoUrl;
+
+ @Transient
+ private String uri;
+
+ @Column(name = "DATA_SOURCE")
+ private String datasourceName;
+
+ /**
+ * Indicates that the league is hosted on a shared application instance
+ * using a SaaS approach. If False the league requires its own dedicated
+ * application instances to be packaged and deployed.
+ */
+ private boolean shared = true;
+
+ @Enumerated(EnumType.STRING)
+ @Column(name = "DATA_ISOLATION")
+ private DataIsolation dataIsolation = DataIsolation.ROW;
+
+ @OneToMany(mappedBy = "league", cascade = CascadeType.ALL)
+ @XmlTransient
+ private List<Extension> playerExtensions = new ArrayList<Extension>();
+
+ @OneToMany(mappedBy = "league", cascade = CascadeType.ALL)
+ @XmlTransient
+ private List<Extension> teamExtensions = new ArrayList<Extension>();
+
+ @OneToMany(mappedBy = "league", cascade = CascadeType.ALL)
+ @XmlTransient
+ private List<Extension> divisionExtensions = new ArrayList<Extension>();
+
+ @Version
+ private long version;
+
+ public HostedLeague() {
+ }
+
+ public HostedLeague(String id, String name, String scheme) {
+ this();
+
+ this.id = id;
+ this.name = name;
+ this.colourScheme = scheme;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getColourScheme() {
+ return colourScheme;
+ }
+
+ public void setColourScheme(String colourScheme) {
+ this.colourScheme = colourScheme;
+ }
+
+ public String getLogoUrl() {
+ return logoUrl;
+ }
+
+ public void setLogoUrl(String logoUrl) {
+ this.logoUrl = logoUrl;
+ }
+
+ public String getUri() {
+ return uri;
+ }
+
+ public void setUri(String uri) {
+ this.uri = uri;
+ }
+
+ public long getVersion() {
+ return version;
+ }
+
+ public String getDatasourceName() {
+ return datasourceName;
+ }
+
+ public void setDatasourceName(String datasourceName) {
+ this.datasourceName = datasourceName;
+ }
+
+ public void addPlayerExtension(Extension extension) {
+
+ }
+
+ public Collection<Extension> getPlayerExtensions() {
+ return this.playerExtensions;
+ }
+
+ public void addPlayerExtension(String name, String javaType, String columnName) {
+ Extension ext = new Extension(name, javaType, columnName);
+ ext.setLeague(this, "Player");
+ getPlayerExtensions().add(ext);
+ }
+
+ public Extension getPlayerExtension(String columnName) {
+ for (Extension ext : getPlayerExtensions()) {
+ if (ext.getColumnName().equals(columnName)) {
+ return ext;
+ }
+ }
+ return null;
+ }
+
+ public Collection<Extension> getTeamExtensions() {
+ return this.teamExtensions;
+ }
+
+ public void addTeamExtension(String name, String javaType, String columnName) {
+ Extension ext = new Extension(name, javaType, columnName);
+ ext.setLeague(this, "Team");
+ getTeamExtensions().add(ext);
+ }
+
+ public Extension getTeamExtension(String columnName) {
+ for (Extension ext : getTeamExtensions()) {
+ if (ext.getColumnName().equals(columnName)) {
+ return ext;
+ }
+ }
+ return null;
+ }
+
+ public Collection<Extension> getDivisionExtensions() {
+ return this.divisionExtensions;
+ }
+
+ public void addDivisionExtension(String name, String javaType, String columnName) {
+ Extension ext = new Extension(name, javaType, columnName);
+ ext.setLeague(this, "Division");
+ getDivisionExtensions().add(ext);
+ }
+
+ public Extension getDivisionExtension(String columnName) {
+ for (Extension ext : getPlayerExtensions()) {
+ if (ext.getColumnName().equals(columnName)) {
+ return ext;
+ }
+ }
+ return null;
+ }
+
+ public boolean isShared() {
+ return shared;
+ }
+
+ public void setShared(boolean shared) {
+ this.shared = shared;
+ }
+
+ public DataIsolation getDataIsolation() {
+ return dataIsolation;
+ }
+
+ public void setDataIsolation(DataIsolation dataIsolation) {
+ this.dataIsolation = dataIsolation;
+ }
+
+ protected void setVersion(long version) {
+ this.version = version;
+ }
+
+ public Collection<Extension> getExtensions(String type) {
+ if (PLAYER.equals(type)) {
+ return getPlayerExtensions();
+ }
+ if (TEAM.equals(type)) {
+ return getTeamExtensions();
+ }
+ if (DIVISION.equals(type)) {
+ return getDivisionExtensions();
+ }
+ throw new IllegalArgumentException("No HostedLeague extensions for type: " + type);
+ }
+
+}
diff --git a/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/model/Style.java b/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/model/Style.java
new file mode 100644
index 0000000..4aa8f70
--- /dev/null
+++ b/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/model/Style.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.4 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.admin.model;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Lob;
+import javax.persistence.Table;
+
+import org.eclipse.persistence.annotations.Cache;
+import org.eclipse.persistence.annotations.CacheType;
+
+/**
+ * @author dclarke
+ * @since EclipseLink 2.3.0
+ */
+@Entity
+@Table(name = "MYS_ADMIN_STYLE")
+@Cache(type=CacheType.FULL, size=10)
+public class Style {
+
+ @Id
+ private String name;
+
+ @Lob
+ private String css;
+
+ public Style() {
+ }
+ public Style(String name, String css) {
+ this.name = name;
+ this.css = css;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getCss() {
+ return css;
+ }
+
+ public void setCss(String css) {
+ this.css = css;
+ }
+
+}
diff --git a/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/model/WebLogic.java b/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/model/WebLogic.java
new file mode 100644
index 0000000..cfda340
--- /dev/null
+++ b/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/model/WebLogic.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.4 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.admin.model;
+
+import java.util.List;
+
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Entity;
+
+/**
+ * Represents a single WebLogic instance.
+ *
+ * @author dclarke
+ * @since EclipseLink 2.4
+ */
+@Entity
+@DiscriminatorValue("WEBLOGIC")
+public class WebLogic extends HostEnvironment {
+
+ @Override
+ public List<Datasource> getDatasources() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/model/jaxb.properties b/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/model/jaxb.properties
new file mode 100644
index 0000000..5837a4c
--- /dev/null
+++ b/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/model/jaxb.properties
@@ -0,0 +1 @@
+javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactory
\ No newline at end of file
diff --git a/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/model/persistence/ExtensionMappingsCustomizer.java b/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/model/persistence/ExtensionMappingsCustomizer.java
new file mode 100644
index 0000000..12b59e0
--- /dev/null
+++ b/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/model/persistence/ExtensionMappingsCustomizer.java
@@ -0,0 +1,35 @@
+package eclipselink.example.mysports.admin.model.persistence;
+
+import org.eclipse.persistence.descriptors.ClassDescriptor;
+import org.eclipse.persistence.expressions.Expression;
+import org.eclipse.persistence.expressions.ExpressionBuilder;
+import org.eclipse.persistence.mappings.OneToManyMapping;
+import org.eclipse.persistence.sessions.factories.DescriptorCustomizer;
+
+import eclipselink.example.mysports.admin.model.Extension;
+import eclipselink.example.mysports.admin.model.HostedLeague;
+
+public class ExtensionMappingsCustomizer implements DescriptorCustomizer {
+
+ @Override
+ public void customize(ClassDescriptor descriptor) throws Exception {
+ OneToManyMapping playerMapping = (OneToManyMapping) descriptor.getMappingForAttributeName("playerExtensions");
+ ExpressionBuilder eb = new ExpressionBuilder(Extension.class);
+ Expression fkExp = eb.getField(descriptor.getMappingForAttributeName("league").getField()).equal(eb.getParameter("id"));
+ Expression typeExp = eb.getField(descriptor.getMappingForAttributeName("type").getField()).equal(HostedLeague.PLAYER);
+ playerMapping.setSelectionCriteria(fkExp.and(typeExp));
+
+ OneToManyMapping teamMapping = (OneToManyMapping) descriptor.getMappingForAttributeName("teamExtensions");
+ eb = new ExpressionBuilder(Extension.class);
+ fkExp = eb.getField(descriptor.getMappingForAttributeName("league").getField()).equal(eb.getParameter("id"));
+ typeExp = eb.getField(descriptor.getMappingForAttributeName("type").getField()).equal(HostedLeague.TEAM);
+ teamMapping.setSelectionCriteria(fkExp.and(typeExp));
+
+ OneToManyMapping divisionMapping = (OneToManyMapping) descriptor.getMappingForAttributeName("divisionExtensions");
+ eb = new ExpressionBuilder(Extension.class);
+ fkExp = eb.getField(descriptor.getMappingForAttributeName("league").getField()).equal(eb.getParameter("id"));
+ typeExp = eb.getField(descriptor.getMappingForAttributeName("type").getField()).equal(HostedLeague.DIVISION);
+ divisionMapping.setSelectionCriteria(fkExp.and(typeExp));
+ }
+
+}
diff --git a/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/services/AdminSchemaManager.java b/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/services/AdminSchemaManager.java
new file mode 100644
index 0000000..0340600
--- /dev/null
+++ b/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/services/AdminSchemaManager.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.4.2 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.admin.services;
+
+import javax.persistence.EntityManagerFactory;
+
+import org.eclipse.persistence.jpa.JpaHelper;
+import org.eclipse.persistence.sessions.server.Server;
+import org.eclipse.persistence.tools.schemaframework.DefaultTableGenerator;
+import org.eclipse.persistence.tools.schemaframework.SchemaManager;
+import org.eclipse.persistence.tools.schemaframework.TableCreator;
+
+public class AdminSchemaManager {
+
+ public static void createTables(EntityManagerFactory emf) {
+ Server session = JpaHelper.getServerSession(emf);
+ SchemaManager sm = new SchemaManager(session);
+
+ sm.replaceDefaultTables();
+ sm.createSequences();
+ }
+
+ public static void dropTables(EntityManagerFactory emf) {
+ Server session = JpaHelper.getServerSession(emf);
+ SchemaManager sm = new SchemaManager(session);
+
+ TableCreator tc = new DefaultTableGenerator(session.getProject(), true).generateDefaultTableCreator();
+ tc.setIgnoreDatabaseException(true);
+ tc.dropTables(session, sm, true);
+ }
+}
diff --git a/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/services/HostEnvironmentRepository.java b/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/services/HostEnvironmentRepository.java
new file mode 100644
index 0000000..6c2cf7b
--- /dev/null
+++ b/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/services/HostEnvironmentRepository.java
@@ -0,0 +1,19 @@
+package eclipselink.example.mysports.admin.services;
+
+import java.util.List;
+
+import javax.ejb.Local;
+
+import eclipselink.example.mysports.admin.model.HostEnvironment;
+
+@Local
+public interface HostEnvironmentRepository {
+
+ void create(HostEnvironment env);
+
+ void delete(HostEnvironment env);
+
+ HostEnvironment find(String name);
+
+ List<HostEnvironment> getEnvironments();
+}
\ No newline at end of file
diff --git a/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/services/HostEnvironmentRepositoryBean.java b/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/services/HostEnvironmentRepositoryBean.java
new file mode 100644
index 0000000..d8aed50
--- /dev/null
+++ b/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/services/HostEnvironmentRepositoryBean.java
@@ -0,0 +1,52 @@
+package eclipselink.example.mysports.admin.services;
+
+import java.util.List;
+
+import javax.ejb.Stateless;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+import eclipselink.example.mysports.admin.model.HostEnvironment;
+
+/**
+ * Repository providing the admin application with read and write access for
+ * {@link HostEnvironment} definitions.
+ *
+ * @author dclarke
+ * @since EclipseLInk 2.4
+ */
+@Stateless
+public class HostEnvironmentRepositoryBean implements HostEnvironmentRepository {
+
+ @PersistenceContext(unitName = "MySportsAdmin")
+ private EntityManager entityManager;
+
+ public EntityManager getEntityManager() {
+ return entityManager;
+ }
+
+ public void setEntityManager(EntityManager entityManager) {
+ this.entityManager = entityManager;
+ }
+
+ // TODO: maintain a list versus query every time?
+ public List<HostEnvironment> getEnvironments() {
+ return getEntityManager().createNamedQuery("HostEnvironment.all", HostEnvironment.class).getResultList();
+ }
+
+ @Override
+ public void create(HostEnvironment env) {
+ getEntityManager().persist(env);
+ }
+
+ @Override
+ public void delete(HostEnvironment env) {
+ getEntityManager().remove(env);
+ }
+
+ @Override
+ public HostEnvironment find(String name) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+}
diff --git a/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/services/HostedLeagueRepository.java b/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/services/HostedLeagueRepository.java
new file mode 100644
index 0000000..06a227f
--- /dev/null
+++ b/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/services/HostedLeagueRepository.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.4 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.admin.services;
+
+import eclipselink.example.mysports.admin.model.HostedLeague;
+import eclipselink.example.mysports.admin.model.Style;
+
+import java.io.InputStream;
+import java.util.List;
+import javax.ejb.Local;
+
+/**
+ *
+ * @author dclarke
+ * @since EclipseLink 2.4
+ */
+@Local
+public interface HostedLeagueRepository {
+
+ List<HostedLeague> allLeagues();
+
+ List<HostedLeague> allSharedLeagues();
+
+ HostedLeague getLeague(String leagueId);
+
+ String getORM(String leagueId);
+
+ String getCSS(String leagueId);
+
+ InputStream getLogo(String leagueId);
+
+ HostedLeague merge(HostedLeague league);
+
+ Style createStyle(String name, String css);
+
+ void create(HostedLeague league);
+}
diff --git a/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/services/HostedLeagueRepositoryBean.java b/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/services/HostedLeagueRepositoryBean.java
new file mode 100644
index 0000000..684d5af
--- /dev/null
+++ b/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/services/HostedLeagueRepositoryBean.java
@@ -0,0 +1,109 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.4 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.admin.services;
+
+import java.io.InputStream;
+import java.util.List;
+
+import javax.ejb.Stateless;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+import org.eclipse.persistence.logging.SessionLog;
+import org.eclipse.persistence.sessions.server.Server;
+
+import eclipselink.example.mysports.admin.model.HostedLeague;
+import eclipselink.example.mysports.admin.model.Style;
+
+/**
+ *
+ * @author dclarke
+ * @since EclipseLink 2.4
+ */
+@Stateless
+public class HostedLeagueRepositoryBean implements HostedLeagueRepository {
+
+ @PersistenceContext(unitName = "MySportsAdmin")
+ private EntityManager entityManager;
+
+ public EntityManager getEntityManager() {
+ return this.entityManager;
+ }
+
+ public void setEntityManager(EntityManager em) {
+ this.entityManager = em;
+ }
+
+ public List<HostedLeague> allLeagues() {
+ return getEntityManager().createNamedQuery("HostedLeague.findAll", HostedLeague.class).getResultList();
+ }
+
+ public List<HostedLeague> allSharedLeagues() {
+ return getEntityManager().createNamedQuery("HostedLeague.findAllShared", HostedLeague.class).getResultList();
+ }
+
+ public HostedLeague getLeague(String leagueId) {
+ getEntityManager().unwrap(Server.class).getSessionLog().log(SessionLog.FINE, "HostedLeagueRepositoryBean.getLeague::" + leagueId);
+ return getEntityManager().find(HostedLeague.class, leagueId);
+ }
+
+ public HostedLeague merge(HostedLeague league) {
+ HostedLeague existingLeague = getEntityManager().find(HostedLeague.class, league.getId());
+
+ if (existingLeague == null) {
+ throw new IllegalStateException("Could not find league: " + league.getId());
+ }
+ return getEntityManager().merge(league);
+ }
+
+ @Override
+ public void create(HostedLeague league) {
+ getEntityManager().persist(league);
+ }
+
+ @Override
+ public Style createStyle(String name, String css) {
+ Style style = new Style(name, css);
+ return getEntityManager().merge(style);
+ }
+
+ public String getORM(String leagueId) {
+ return MappingsLoader.getORMapping(getEntityManager(), leagueId);
+ }
+
+ public String getCSS(String leagueId) {
+ EntityManager em = getEntityManager();
+
+ HostedLeague league = em.find(HostedLeague.class, leagueId);
+
+ if (league == null) {
+ throw new IllegalArgumentException("Unknown League: " + leagueId);
+ }
+
+ Style style = null;
+
+ if (league != null && league.getColourScheme() != null) {
+ style = em.find(Style.class, league.getColourScheme());
+ }
+ if (style == null) {
+ style = em.find(Style.class, "default");
+ }
+
+ return style.getCss();
+ }
+
+ public InputStream getLogo(String leagueId) {
+ return Thread.currentThread().getContextClassLoader().getResourceAsStream(leagueId.toLowerCase() + ".png");
+ }
+
+}
diff --git a/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/services/MappingsLoader.java b/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/services/MappingsLoader.java
new file mode 100644
index 0000000..83eccdd
--- /dev/null
+++ b/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/services/MappingsLoader.java
@@ -0,0 +1,158 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.admin.services;
+
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.EntityManager;
+
+import org.eclipse.persistence.Version;
+import org.eclipse.persistence.annotations.MultitenantType;
+import org.eclipse.persistence.annotations.TenantTableDiscriminatorType;
+import org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EmbeddableAccessor;
+import org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor;
+import org.eclipse.persistence.internal.jpa.metadata.accessors.classes.MappedSuperclassAccessor;
+import org.eclipse.persistence.internal.jpa.metadata.accessors.classes.XMLAttributes;
+import org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.BasicAccessor;
+import org.eclipse.persistence.internal.jpa.metadata.columns.ColumnMetadata;
+import org.eclipse.persistence.internal.jpa.metadata.columns.TenantDiscriminatorColumnMetadata;
+import org.eclipse.persistence.internal.jpa.metadata.multitenant.MultitenantMetadata;
+import org.eclipse.persistence.internal.jpa.metadata.multitenant.TenantTableDiscriminatorMetadata;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLEntityMappings;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLEntityMappingsWriter;
+
+import eclipselink.example.mysports.admin.model.Extension;
+import eclipselink.example.mysports.admin.model.HostedLeague;
+
+/**
+ * Load the {@link Extension} from the database and generate the ORM and OXM
+ * mapping files for the extensions.
+ *
+ * @author dclarke
+ * @since EclipseLink 2.3.0
+ */
+public class MappingsLoader {
+
+ private static final String MODEL_PACKAGE = "eclipselink.example.mysports.application.model";
+
+ public static XMLEntityMappings getXMLEntityMappings(EntityManager em, String leagueId) {
+ HostedLeague league = em.find(HostedLeague.class, leagueId);
+
+ if (league == null) {
+ throw new IllegalArgumentException("Unknown League: " + leagueId);
+ }
+
+ return getXMLEntityMappings(league);
+ }
+
+ public static XMLEntityMappings getXMLEntityMappings(HostedLeague league) {
+ XMLEntityMappings mappings = new XMLEntityMappings();
+ mappings.setVersion(Version.getVersion());
+ mappings.setEntities(new ArrayList<EntityAccessor>());
+ mappings.setEmbeddables(new ArrayList<EmbeddableAccessor>());
+ mappings.setMappedSuperclasses(new ArrayList<MappedSuperclassAccessor>());
+
+ mappings.setPackage(MODEL_PACKAGE);
+
+ addEntity(league, "Division", mappings);
+ addEntity(league, "Team", mappings);
+ addEntity(league, "Player", mappings);
+
+ return mappings;
+ }
+
+ public static String getORMapping(EntityManager em, String leagueId) {
+ XMLEntityMappings mappings = getXMLEntityMappings(em, leagueId);
+
+ StringWriter writer = new StringWriter();
+ XMLEntityMappingsWriter.write(mappings, writer);
+
+ return writer.toString();
+ }
+
+ public static void addEntity(HostedLeague league, String entityType, XMLEntityMappings mappings) {
+
+ EntityAccessor accessor = new EntityAccessor();
+ accessor.setClassName(entityType);
+ mappings.getEntities().add(accessor);
+
+ switch (league.getDataIsolation()) {
+ case ROW:
+ // Add @Multitenant(SINGLE_TABLE)
+ MultitenantMetadata multitenant = new MultitenantMetadata();
+ multitenant.setType(MultitenantType.SINGLE_TABLE.name());
+ List<TenantDiscriminatorColumnMetadata> tenantDiscriminatorColumns = new ArrayList<TenantDiscriminatorColumnMetadata>(1);
+ TenantDiscriminatorColumnMetadata tenantDiscColumn = new TenantDiscriminatorColumnMetadata();
+ tenantDiscColumn.setName("LEAGUE_ID");
+ tenantDiscColumn.setContextProperty("league");
+ tenantDiscColumn.setLength(5);
+ tenantDiscriminatorColumns.add(tenantDiscColumn);
+ multitenant.setTenantDiscriminatorColumns(tenantDiscriminatorColumns);
+ accessor.setMultitenant(multitenant);
+ break;
+ case TABLE:
+ // Add @Multitenant(TABLE_PER_TENANT) with
+ // @TenenatTableDisciminator(SUFFIX)
+ multitenant = new MultitenantMetadata();
+ multitenant.setType(MultitenantType.TABLE_PER_TENANT.name());
+ TenantTableDiscriminatorMetadata tenantTableDiscriminator = new TenantTableDiscriminatorMetadata();
+ tenantTableDiscriminator.setType(TenantTableDiscriminatorType.SUFFIX.name());
+ tenantTableDiscriminator.setContextProperty("league");
+ multitenant.setTenantTableDiscriminator(tenantTableDiscriminator);
+ accessor.setMultitenant(multitenant);
+ break;
+ case SCHEMA:
+ // Add @Multitenant(TABLE_PER_TENANT) with
+ // @TenenatTableDisciminator(SCHEMA)
+ multitenant = new MultitenantMetadata();
+ multitenant.setType(MultitenantType.TABLE_PER_TENANT.name());
+ tenantTableDiscriminator = new TenantTableDiscriminatorMetadata();
+ tenantTableDiscriminator.setType(TenantTableDiscriminatorType.SCHEMA.name());
+ tenantTableDiscriminator.setContextProperty("league");
+ multitenant.setTenantTableDiscriminator(tenantTableDiscriminator);
+ accessor.setMultitenant(multitenant);
+ break;
+
+ // TODO
+ case DATABASE:
+ throw new RuntimeException("DataIsolation.DATABASE::NOT YET SUPPORTED");
+ }
+
+ if (league != null) {
+
+ for (Extension ext : league.getExtensions(entityType)) {
+ BasicAccessor allergies = new BasicAccessor();
+ allergies.setName(ext.getName());
+ allergies.setAttributeType(ext.getJavaType());
+ allergies.setAccess("VIRTUAL");
+
+ ColumnMetadata column = new ColumnMetadata();
+ column.setName(ext.getColumnName());
+ allergies.setColumn(column);
+
+ if (accessor.getAttributes() == null) {
+ accessor.setAttributes(new XMLAttributes());
+ }
+ if (accessor.getAttributes().getBasics() == null) {
+ accessor.getAttributes().setBasics(new ArrayList<BasicAccessor>());
+ }
+ accessor.getAttributes().getBasics().add(allergies);
+ }
+
+ }
+
+ }
+
+}
diff --git a/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/services/glassfish/JDBCResource.java b/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/services/glassfish/JDBCResource.java
new file mode 100644
index 0000000..042d08c
--- /dev/null
+++ b/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/services/glassfish/JDBCResource.java
@@ -0,0 +1,119 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.4 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.admin.services.glassfish;
+
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+
+import org.eclipse.persistence.oxm.MediaType;
+import org.eclipse.persistence.oxm.annotations.XmlPath;
+
+/**
+ * Represents a JDBC Resource in GlassFish. Used to interact with GlassFish over
+ * REST.
+ *
+ * @author dclarke
+ * @since EclipseLink 2.4
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+public class JDBCResource extends Result {
+
+ /**
+ * Management URI extension to get list of JDBC resources
+ */
+ public static final String LIST_URI = "/domain/resources/list-jdbc-resources";
+
+ /**
+ * Management URI extension to get details of a specific JDBC resource
+ */
+ public static final String RESOURCE_URI = "/domain/resources/jdbc-resource/";
+
+ @XmlPath("extraProperties/entity/description/text()")
+ private String description;
+
+ @XmlPath("extraProperties/entity/enabled/text()")
+ private String enabled;
+
+ @XmlPath("extraProperties/entity/jndiName/text()")
+ private String jndiName;
+
+ @XmlPath("extraProperties/entity/objectType/text()")
+ private String objectType;
+
+ @XmlPath("extraProperties/entity/poolName/text()")
+ private String poolName;
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getEnabled() {
+ return enabled;
+ }
+
+ public void setEnabled(String enabled) {
+ this.enabled = enabled;
+ }
+
+ public String getJndiName() {
+ return jndiName;
+ }
+
+ public void setJndiName(String jndiName) {
+ this.jndiName = jndiName;
+ }
+
+ public String getObjectType() {
+ return objectType;
+ }
+
+ public void setObjectType(String objectType) {
+ this.objectType = objectType;
+ }
+
+ public String getPoolName() {
+ return poolName;
+ }
+
+ public void setPoolName(String poolName) {
+ this.poolName = poolName;
+ }
+
+ /**
+ * TODO
+ */
+ public static String[] getJDBCResourceNames(RESTOperations ops) {
+ try {
+ Result result = ops.get(LIST_URI, MediaType.APPLICATION_JSON, Result.class);
+ return result.getChildrenMessages();
+ } catch (JAXBException e) {
+ throw new RuntimeException("Failure to get JDBC resource from GlassFish@" + ops.getServer(), e);
+ }
+ }
+
+ /**
+ * TODO
+ */
+ public static JDBCResource getJDBResource(RESTOperations ops, String name) {
+ try {
+ return ops.get(RESOURCE_URI + name.replace("/", "%2F"), MediaType.APPLICATION_JSON, JDBCResource.class);
+ } catch (JAXBException e) {
+ throw new RuntimeException("Failure to get JDBC resource from GlassFish@" + ops.getServer(), e);
+ }
+ }
+}
diff --git a/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/services/glassfish/MOXyContextHelper.java b/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/services/glassfish/MOXyContextHelper.java
new file mode 100644
index 0000000..02c46e1
--- /dev/null
+++ b/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/services/glassfish/MOXyContextHelper.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.4 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.admin.services.glassfish;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+import static org.eclipse.persistence.jaxb.MarshallerProperties.MEDIA_TYPE;
+import static org.eclipse.persistence.jaxb.UnmarshallerProperties.JSON_INCLUDE_ROOT;
+
+import org.eclipse.persistence.jaxb.JAXBContextFactory;
+import org.eclipse.persistence.oxm.MediaType;
+
+/**
+ * Helper class to simplify the XML/JSON conversions.
+ *
+ * @author dclarke
+ * @since EclipseLink 2.4
+ */
+public class MOXyContextHelper {
+
+ /**
+ * Cache the {@link JAXBContext} to avoid recreating it each time. The
+ * context is thread safe.
+ */
+ private static JAXBContext context = null;
+
+ public static JAXBContext createContext() throws JAXBException {
+ if (context == null) {
+ context = JAXBContextFactory.createContext(new Class[] { Result.class, JDBCResource.class }, null);
+ }
+ return context;
+ }
+
+ public static Marshaller createMarshaller(MediaType mediaType) throws JAXBException {
+ Marshaller marshaller = createContext().createMarshaller();
+ marshaller.setProperty(MEDIA_TYPE, mediaType.getMediaType());
+ return marshaller;
+ }
+
+ public static Unmarshaller createUnmarshaller(MediaType mediaType) throws JAXBException {
+ Unmarshaller unmarshaller = createContext().createUnmarshaller();
+ unmarshaller.setProperty(MEDIA_TYPE, mediaType.getMediaType());
+ unmarshaller.setProperty(JSON_INCLUDE_ROOT, false);
+ return unmarshaller;
+ }
+}
diff --git a/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/services/glassfish/Message.java b/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/services/glassfish/Message.java
new file mode 100644
index 0000000..1c6ef50
--- /dev/null
+++ b/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/services/glassfish/Message.java
@@ -0,0 +1,29 @@
+package eclipselink.example.mysports.admin.services.glassfish;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+
+@XmlAccessorType(XmlAccessType.FIELD)
+public class Message {
+
+ private String message;
+
+ private Properties properties;
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public Properties getProperties() {
+ return properties;
+ }
+
+ public void setProperties(Properties properties) {
+ this.properties = properties;
+ }
+
+}
diff --git a/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/services/glassfish/Properties.java b/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/services/glassfish/Properties.java
new file mode 100644
index 0000000..b32bedd
--- /dev/null
+++ b/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/services/glassfish/Properties.java
@@ -0,0 +1,25 @@
+package eclipselink.example.mysports.admin.services.glassfish;
+
+public class Properties {
+
+ private String name;
+
+ private String value;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+}
diff --git a/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/services/glassfish/Property.java b/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/services/glassfish/Property.java
new file mode 100644
index 0000000..6fcf1f1
--- /dev/null
+++ b/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/services/glassfish/Property.java
@@ -0,0 +1,25 @@
+package eclipselink.example.mysports.admin.services.glassfish;
+
+public class Property {
+
+ private String name;
+
+ private String value;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+}
diff --git a/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/services/glassfish/RESTOperations.java b/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/services/glassfish/RESTOperations.java
new file mode 100644
index 0000000..c449e94
--- /dev/null
+++ b/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/services/glassfish/RESTOperations.java
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.4 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.admin.services.glassfish;
+
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.transform.stream.StreamSource;
+
+import org.eclipse.persistence.oxm.MediaType;
+
+import com.sun.jersey.api.client.Client;
+import com.sun.jersey.api.client.ClientResponse;
+import com.sun.jersey.api.client.WebResource;
+
+/**
+ * Helper to invoke management REST operations against a GlassFish instance
+ * using the Jersey client library.
+ *
+ * @author dclarke
+ * @since EclipseLink 2.4
+ */
+public class RESTOperations {
+
+ private String server;
+
+ private int port = 4848;
+
+ public RESTOperations(String server) {
+ super();
+ this.server = server;
+ }
+
+ public int getPort() {
+ return port;
+ }
+
+ public void setPort(int port) {
+ this.port = port;
+ }
+
+ public String getServer() {
+ return server;
+ }
+
+ private static final String ADMINISTRATION_URL = "/management";
+
+ protected WebResource getWebResource(Client client, String resourcePath) {
+ return client.resource("http://" + getServer() + ":" + getPort() + ADMINISTRATION_URL + resourcePath);
+ }
+
+ public <T> T get(String resourcePath, MediaType mediaType, Class<T> resultClass) throws JAXBException {
+ Client client = Client.create();
+ WebResource webResource = getWebResource(client, resourcePath);
+ ClientResponse response = webResource.accept(mediaType.getMediaType()).get(ClientResponse.class);
+
+ if (response.getStatus() != 200) {
+ throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
+ }
+
+ Unmarshaller unmarshaller = MOXyContextHelper.createUnmarshaller(mediaType);
+ return unmarshaller.unmarshal(new StreamSource(response.getEntityInputStream()), resultClass).getValue();
+ }
+
+}
diff --git a/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/services/glassfish/Result.java b/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/services/glassfish/Result.java
new file mode 100644
index 0000000..58ecb8d
--- /dev/null
+++ b/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/services/glassfish/Result.java
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.4 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.admin.services.glassfish;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlSeeAlso;
+
+import org.eclipse.persistence.oxm.annotations.XmlPath;
+
+/**
+ * TODO
+ *
+ * @author dclarke
+ * @since EclipseLink 2.4
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlSeeAlso({ JDBCResource.class })
+public class Result {
+
+ private String message;
+
+ private String command;
+
+ @XmlElement(name = "exit_code")
+ private String exitCode;
+
+ private List<Message> children;
+
+ private Properties properties;
+
+ @XmlPath("extraProperties/properties")
+ private List<Property> extraProperties;
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public String getCommand() {
+ return command;
+ }
+
+ public void setCommand(String command) {
+ this.command = command;
+ }
+
+ public String getExitCode() {
+ return exitCode;
+ }
+
+ public void setExitCode(String exitCode) {
+ this.exitCode = exitCode;
+ }
+
+ public List<Message> getChildren() {
+ return children;
+ }
+
+ public String[] getChildrenMessages() {
+ String[] messages = new String[getChildren().size()];
+ for (int index = 0; index < getChildren().size(); index++) {
+ messages[index] = getChildren().get(index).getMessage();
+ }
+ return messages;
+ }
+
+ public Properties getProperties() {
+ return properties;
+ }
+
+ public List<Property> getExtraProperties() {
+ return extraProperties;
+ }
+
+ public String toString() {
+ return "RESTResult(" + getCommand() + ")";
+ }
+}
diff --git a/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/services/glassfish/jaxb.properties b/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/services/glassfish/jaxb.properties
new file mode 100644
index 0000000..5837a4c
--- /dev/null
+++ b/mysports/admin.services/src/main/java/eclipselink/example/mysports/admin/services/glassfish/jaxb.properties
@@ -0,0 +1 @@
+javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactory
\ No newline at end of file
diff --git a/mysports/admin.services/src/main/jpa-modelgen/eclipselink/example/mysports/admin/model/Extension_.java b/mysports/admin.services/src/main/jpa-modelgen/eclipselink/example/mysports/admin/model/Extension_.java
new file mode 100644
index 0000000..2dcc360
--- /dev/null
+++ b/mysports/admin.services/src/main/jpa-modelgen/eclipselink/example/mysports/admin/model/Extension_.java
@@ -0,0 +1,15 @@
+package eclipselink.example.mysports.admin.model;
+
+import javax.annotation.Generated;
+import javax.persistence.metamodel.SingularAttribute;
+import javax.persistence.metamodel.StaticMetamodel;
+
+@Generated(value="Dali", date="2013-02-22T10:11:27.052-0500")
+@StaticMetamodel(Extension.class)
+public class Extension_ {
+ public static volatile SingularAttribute<Extension, HostedLeague> league;
+ public static volatile SingularAttribute<Extension, String> type;
+ public static volatile SingularAttribute<Extension, String> name;
+ public static volatile SingularAttribute<Extension, String> javaType;
+ public static volatile SingularAttribute<Extension, String> columnName;
+}
diff --git a/mysports/admin.services/src/main/jpa-modelgen/eclipselink/example/mysports/admin/model/GlassFish_.java b/mysports/admin.services/src/main/jpa-modelgen/eclipselink/example/mysports/admin/model/GlassFish_.java
new file mode 100644
index 0000000..c9290d3
--- /dev/null
+++ b/mysports/admin.services/src/main/jpa-modelgen/eclipselink/example/mysports/admin/model/GlassFish_.java
@@ -0,0 +1,9 @@
+package eclipselink.example.mysports.admin.model;
+
+import javax.annotation.Generated;
+import javax.persistence.metamodel.StaticMetamodel;
+
+@Generated(value="Dali", date="2013-02-22T10:11:27.055-0500")
+@StaticMetamodel(GlassFish.class)
+public class GlassFish_ extends HostEnvironment_ {
+}
diff --git a/mysports/admin.services/src/main/jpa-modelgen/eclipselink/example/mysports/admin/model/HostEnvironment_.java b/mysports/admin.services/src/main/jpa-modelgen/eclipselink/example/mysports/admin/model/HostEnvironment_.java
new file mode 100644
index 0000000..dc99855
--- /dev/null
+++ b/mysports/admin.services/src/main/jpa-modelgen/eclipselink/example/mysports/admin/model/HostEnvironment_.java
@@ -0,0 +1,13 @@
+package eclipselink.example.mysports.admin.model;
+
+import javax.annotation.Generated;
+import javax.persistence.metamodel.SingularAttribute;
+import javax.persistence.metamodel.StaticMetamodel;
+
+@Generated(value="Dali", date="2013-02-22T10:11:27.056-0500")
+@StaticMetamodel(HostEnvironment.class)
+public class HostEnvironment_ {
+ public static volatile SingularAttribute<HostEnvironment, Integer> id;
+ public static volatile SingularAttribute<HostEnvironment, String> name;
+ public static volatile SingularAttribute<HostEnvironment, String> description;
+}
diff --git a/mysports/admin.services/src/main/jpa-modelgen/eclipselink/example/mysports/admin/model/HostedLeague_.java b/mysports/admin.services/src/main/jpa-modelgen/eclipselink/example/mysports/admin/model/HostedLeague_.java
new file mode 100644
index 0000000..b833d44
--- /dev/null
+++ b/mysports/admin.services/src/main/jpa-modelgen/eclipselink/example/mysports/admin/model/HostedLeague_.java
@@ -0,0 +1,22 @@
+package eclipselink.example.mysports.admin.model;
+
+import javax.annotation.Generated;
+import javax.persistence.metamodel.ListAttribute;
+import javax.persistence.metamodel.SingularAttribute;
+import javax.persistence.metamodel.StaticMetamodel;
+
+@Generated(value="Dali", date="2013-02-22T10:11:27.055-0500")
+@StaticMetamodel(HostedLeague.class)
+public class HostedLeague_ {
+ public static volatile SingularAttribute<HostedLeague, String> id;
+ public static volatile SingularAttribute<HostedLeague, String> name;
+ public static volatile SingularAttribute<HostedLeague, String> colourScheme;
+ public static volatile SingularAttribute<HostedLeague, String> logoUrl;
+ public static volatile SingularAttribute<HostedLeague, String> datasourceName;
+ public static volatile SingularAttribute<HostedLeague, Boolean> shared;
+ public static volatile SingularAttribute<HostedLeague, DataIsolation> dataIsolation;
+ public static volatile ListAttribute<HostedLeague, Extension> playerExtensions;
+ public static volatile ListAttribute<HostedLeague, Extension> teamExtensions;
+ public static volatile ListAttribute<HostedLeague, Extension> divisionExtensions;
+ public static volatile SingularAttribute<HostedLeague, Long> version;
+}
diff --git a/mysports/admin.services/src/main/jpa-modelgen/eclipselink/example/mysports/admin/model/Style_.java b/mysports/admin.services/src/main/jpa-modelgen/eclipselink/example/mysports/admin/model/Style_.java
new file mode 100644
index 0000000..b12fd68
--- /dev/null
+++ b/mysports/admin.services/src/main/jpa-modelgen/eclipselink/example/mysports/admin/model/Style_.java
@@ -0,0 +1,12 @@
+package eclipselink.example.mysports.admin.model;
+
+import javax.annotation.Generated;
+import javax.persistence.metamodel.SingularAttribute;
+import javax.persistence.metamodel.StaticMetamodel;
+
+@Generated(value="Dali", date="2013-02-22T10:11:27.057-0500")
+@StaticMetamodel(Style.class)
+public class Style_ {
+ public static volatile SingularAttribute<Style, String> name;
+ public static volatile SingularAttribute<Style, String> css;
+}
diff --git a/mysports/admin.services/src/main/jpa-modelgen/eclipselink/example/mysports/admin/model/WebLogic_.java b/mysports/admin.services/src/main/jpa-modelgen/eclipselink/example/mysports/admin/model/WebLogic_.java
new file mode 100644
index 0000000..284d7ec
--- /dev/null
+++ b/mysports/admin.services/src/main/jpa-modelgen/eclipselink/example/mysports/admin/model/WebLogic_.java
@@ -0,0 +1,9 @@
+package eclipselink.example.mysports.admin.model;
+
+import javax.annotation.Generated;
+import javax.persistence.metamodel.StaticMetamodel;
+
+@Generated(value="Dali", date="2013-02-22T10:11:27.058-0500")
+@StaticMetamodel(WebLogic.class)
+public class WebLogic_ extends HostEnvironment_ {
+}
diff --git a/mysports/admin.services/src/main/resources/META-INF/eclipselink-oxm.xml b/mysports/admin.services/src/main/resources/META-INF/eclipselink-oxm.xml
new file mode 100644
index 0000000..e1ffdc1
--- /dev/null
+++ b/mysports/admin.services/src/main/resources/META-INF/eclipselink-oxm.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0"?>
+<xml-bindings version="2.4"
+ xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm"
+ package-name="eclipselink.example.mysports.admin.model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.eclipse.org/eclipselink/xsds/persistence/oxm http://www.eclipse.org/eclipselink/xsds/eclipselink_oxm_2_4.xsd">
+ <java-types>
+ <java-type name="HostedLeague" xml-accessor-type="FIELD" >
+ <xml-root-element name="league"/>
+ <java-attributes>
+ <xml-attribute java-attribute="id" />
+ <xml-attribute java-attribute="version" />
+ <xml-element java-attribute="name" />
+ <xml-element java-attribute="colourScheme"/>
+ <xml-element java-attribute="logoUrl"/>
+ <xml-element java-attribute="uri" xml-path="link/@href"/>
+ <xml-transient java-attribute="extensions"/>
+ <xml-transient java-attribute="dataIsolation"/>
+ <xml-transient java-attribute="datasource"/>
+ <xml-transient java-attribute="shared"/>
+ </java-attributes>
+ </java-type>
+ </java-types>
+</xml-bindings>
\ No newline at end of file
diff --git a/mysports/admin.services/src/main/resources/META-INF/persistence.xml b/mysports/admin.services/src/main/resources/META-INF/persistence.xml
new file mode 100644
index 0000000..9384ed4
--- /dev/null
+++ b/mysports/admin.services/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
+ <persistence-unit name="MySportsAdmin">
+ <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+ <jta-data-source>java:global/mysports</jta-data-source>
+ <class>eclipselink.example.mysports.admin.model.WebLogic</class>
+ <class>eclipselink.example.mysports.admin.model.Style</class>
+ <class>eclipselink.example.mysports.admin.model.Extension</class>
+ <class>eclipselink.example.mysports.admin.model.GlassFish</class>
+ <class>eclipselink.example.mysports.admin.model.HostedLeague</class>
+ <class>eclipselink.example.mysports.admin.model.HostEnvironment</class>
+ <validation-mode>NONE</validation-mode>
+ <properties>
+ <property name="eclipselink.weaving" value="true"/>
+ <property name="eclipselink.logging.level" value="FINE"/>
+ <property name="eclipselink.logging.timestamp" value="false"/>
+ <property name="eclipselink.logging.thread" value="false"/>
+ <property name="eclipselink.logging.session" value="false"/>
+ <property name="eclipselink.logging.exceptions" value="false"/>
+ <property name="eclipselink.logging.connection" value="false"/>
+ <property name="eclipselink.logging.level.metadata" value="WARNING"/>
+ <property name="eclipselink.logging.logger" value="DefaultLogger"/>
+ </properties>
+ </persistence-unit>
+</persistence>
diff --git a/mysports/admin.services/src/main/resources/black.css b/mysports/admin.services/src/main/resources/black.css
new file mode 100644
index 0000000..d646aa3
--- /dev/null
+++ b/mysports/admin.services/src/main/resources/black.css
@@ -0,0 +1,209 @@
+#*******************************************************************************
+# * Copyright (c) 2010 Oracle. All rights reserved.
+# * This program and the accompanying materials are made available under the
+# * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+# * which accompanies this distribution.
+# * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+# * and the Eclipse Distribution License is available at
+# * http://www.eclipse.org/org/documents/edl-v10.php.
+# *
+# * Contributors:
+# * dclarke - MySports Example for EclipseLink 2.3
+# ******************************************************************************/
+BODY, P, LI, UL, OL {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 50%;
+ color:#000000;
+ list-style-position: outside;
+}
+
+A:link {
+ font-family: Arial, Helvetica, sans-serif;
+ color:#663300;
+}
+
+A:active {
+ font-family: Arial, Helvetica, sans-serif;
+ color:#ff6600;
+
+}
+
+A:visited {
+ font-family: Arial, Helvetica, sans-serif;
+ color:#996633;
+
+}
+
+A.navigation:link
+{
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:65%;
+ color:#996633;
+}
+
+A.navigation:active
+{
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:65%;
+ color:#996633;
+}
+
+A.navigation:visited
+{
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:65%;
+ color:#996633;
+}
+
+.clear { /* generic container (i.e. div) for floating buttons */
+ overflow: hidden;
+ width: 100%;
+}
+
+c.button {
+ background: transparent url('../images/bg_button_a.gif') no-repeat scroll top right;
+ color: #444;
+ display: block;
+ float: left;
+ font: normal 12px arial, sans-serif;
+ height: 24px;
+ margin-right: 6px;
+ padding-right: 18px; /* sliding doors padding */
+ text-decoration: none;
+}
+
+a.button span {
+ background: transparent url('../images/bg_button_span.gif') no-repeat;
+ display: block;
+ line-height: 14px;
+ padding: 5px 0 5px 18px;
+}
+
+a.button:active {
+ background-position: bottom right;
+ color: #000;
+ outline: none; /* hide dotted outline in Firefox */
+}
+
+a.button:active span {
+ background-position: bottom left;
+ padding: 6px 0 4px 18px; /* push text down 1px */
+}
+p.listpara
+{text-indent: 15%}
+
+H1 {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:200%;
+ color: red;
+ width : 100%;
+ border-width : 0px 0px 2px 0px;
+ margin-left: 20px;
+}
+
+H2 {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:130%;
+ font-style: italic;
+ color: white;
+ width : 100%;
+ margin-left: 20px;
+}
+
+H3 {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:110%;
+ color: red;
+ border : solid #CCCC99;
+ width : 100%;
+ border-width : 0px 0px 2px 0px;
+}
+
+H4 {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:92%;
+ color:#000000;
+ font-weight: bold;
+ width : 100%;
+}
+
+.code_no_color {
+ color : #000000;
+ font-family : "Courier New", "Courier", "monospace";
+}
+
+code {
+ color : #336699;
+ font-family : "Courier New", "Courier", "monospace";
+}
+
+P.indent {
+ text-indent: 9%;
+}
+
+table.borders {
+ border : 1% solid #BDB76B;
+}
+
+TR {
+ text-align : left;
+ vertical-align : top;
+}
+
+TH {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 11pt;
+ color:#000000;
+ font-weight: bold;
+}
+
+TD {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 11pt;
+ color:#000000;
+}
+
+.smalltext {
+ font-size:80%;
+}
+
+p.note {
+ display: block;
+ font-family: Arial, Helvetica, Geneva, sans-serif;
+ font-size: 95%;
+}
+
+p.warning {
+ display: block;
+ font-family: Arial, Helvetica, Geneva, sans-serif;
+ font-size: 95%;
+}
+
+pre {
+ font-family: "Courier New", Courier, mono;
+ font-size: 92%;
+ text-indent : 15%;
+}
+
+table.pretty {
+ background: whitesmoke;
+ border-collapse: collapse;
+}
+table.pretty th, table.pretty td {
+ border: 1px silver solid;
+ padding: 0.2em;
+ font-size: 10pt;
+}
+table.pretty th {
+ background: black;
+ text-align: left;
+ color: white;
+}
+table.pretty caption {
+ margin-left: inherit;
+ margin-right: inherit;
+}
+
+table.accent {
+ background: black;
+}
diff --git a/mysports/admin.services/src/main/resources/blue.css b/mysports/admin.services/src/main/resources/blue.css
new file mode 100644
index 0000000..7f228a4
--- /dev/null
+++ b/mysports/admin.services/src/main/resources/blue.css
@@ -0,0 +1,212 @@
+#*******************************************************************************
+# * Copyright (c) 2010 Oracle. All rights reserved.
+# * This program and the accompanying materials are made available under the
+# * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+# * which accompanies this distribution.
+# * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+# * and the Eclipse Distribution License is available at
+# * http://www.eclipse.org/org/documents/edl-v10.php.
+# *
+# * Contributors:
+# * dclarke - MySports Example for EclipseLink 2.3
+# ******************************************************************************/
+BODY, P, LI, UL, OL {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 50%;
+ color:#000000;
+ list-style-position: outside;
+}
+
+A:link {
+ font-family: Arial, Helvetica, sans-serif;
+ color:#663300;
+
+}
+
+A:active {
+ font-family: Arial, Helvetica, sans-serif;
+ color:#ff6600;
+
+}
+
+A:visited {
+ font-family: Arial, Helvetica, sans-serif;
+ color:#996633;
+
+}
+
+A.navigation:link
+{
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:65%;
+ color:#996633;
+}
+
+A.navigation:active
+{
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:65%;
+ color:#996633;
+}
+
+A.navigation:visited
+{
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:65%;
+ color:#996633;
+}
+
+.clear { /* generic container (i.e. div) for floating buttons */
+ overflow: hidden;
+ width: 100%;
+}
+
+c.button {
+ background: transparent url('../images/bg_button_a.gif') no-repeat scroll top right;
+ color: #444;
+ display: block;
+ float: left;
+ font: normal 12px arial, sans-serif;
+ height: 24px;
+ margin-right: 6px;
+ padding-right: 18px; /* sliding doors padding */
+ text-decoration: none;
+}
+
+a.button span {
+ background: transparent url('../images/bg_button_span.gif') no-repeat;
+ display: block;
+ line-height: 14px;
+ padding: 5px 0 5px 18px;
+}
+
+a.button:active {
+ background-position: bottom right;
+ color: #000;
+ outline: none; /* hide dotted outline in Firefox */
+}
+
+a.button:active span {
+ background-position: bottom left;
+ padding: 6px 0 4px 18px; /* push text down 1px */
+}
+p.listpara
+{text-indent: 15%}
+
+H1 {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:170%;
+ color:#336699;
+ border : solid ##3333CC;
+ width : 100%;
+ border-width : 0px 0px 2px 0px;
+ margin-left: 20px;
+}
+
+H2 {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:130%;
+ font-style: italic;
+ color: white;
+ width : 100%;
+ margin-left: 20px;
+}
+
+H3 {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:110%;
+ color:#336699;
+ border : solid #CCCC99;
+ width : 100%;
+ border-width : 0px 0px 2px 0px;
+}
+
+H4 {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:92%;
+ color:#000000;
+ font-weight: bold;
+ width : 100%;
+}
+
+.code_no_color {
+ color : #000000;
+ font-family : "Courier New", "Courier", "monospace";
+}
+
+code {
+ color : #336699;
+ font-family : "Courier New", "Courier", "monospace";
+}
+
+P.indent {
+ text-indent: 9%;
+}
+
+table.borders {
+ border : 1% solid #BDB76B;
+}
+
+TR {
+ text-align : left;
+ vertical-align : top;
+}
+
+TH {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 11pt;
+ color:#000000;
+ font-weight: bold;
+}
+
+TD {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 11pt;
+ color:#000000;
+}
+
+.smalltext {
+ font-size:80%;
+}
+
+p.note {
+ display: block;
+ font-family: Arial, Helvetica, Geneva, sans-serif;
+ font-size: 95%;
+}
+
+p.warning {
+ display: block;
+ font-family: Arial, Helvetica, Geneva, sans-serif;
+ font-size: 95%;
+}
+
+pre {
+ font-family: "Courier New", Courier, mono;
+ font-size: 92%;
+ text-indent : 15%;
+}
+
+table.pretty {
+ background: whitesmoke;
+ border-collapse: collapse;
+}
+table.pretty th, table.pretty td {
+ border: 1px silver solid;
+ padding: 0.2em;
+ font-size: 10pt;
+}
+table.pretty th {
+ background: blue;
+ text-align: left;
+ color: white;
+}
+table.pretty caption {
+ margin-left: inherit;
+ margin-right: inherit;
+}
+
+table.accent {
+ background: blue;
+}
+
diff --git a/mysports/admin.services/src/main/resources/default.css b/mysports/admin.services/src/main/resources/default.css
new file mode 100644
index 0000000..8136a7a
--- /dev/null
+++ b/mysports/admin.services/src/main/resources/default.css
@@ -0,0 +1,212 @@
+#*******************************************************************************
+# * Copyright (c) 2010 Oracle. All rights reserved.
+# * This program and the accompanying materials are made available under the
+# * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+# * which accompanies this distribution.
+# * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+# * and the Eclipse Distribution License is available at
+# * http://www.eclipse.org/org/documents/edl-v10.php.
+# *
+# * Contributors:
+# * dclarke - MySports Example for EclipseLink 2.3
+# ******************************************************************************/
+BODY, P, LI, UL, OL {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 50%;
+ color:#000000;
+ list-style-position: outside;
+}
+
+A:link {
+ font-family: Arial, Helvetica, sans-serif;
+ color:#663300;
+
+}
+
+A:active {
+ font-family: Arial, Helvetica, sans-serif;
+ color:#ff6600;
+
+}
+
+A:visited {
+ font-family: Arial, Helvetica, sans-serif;
+ color:#996633;
+
+}
+
+A.navigation:link
+{
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:65%;
+ color:#996633;
+}
+
+A.navigation:active
+{
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:65%;
+ color:#996633;
+}
+
+A.navigation:visited
+{
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:65%;
+ color:#996633;
+}
+
+.clear { /* generic container (i.e. div) for floating buttons */
+ overflow: hidden;
+ width: 100%;
+}
+
+c.button {
+ background: transparent url('../images/bg_button_a.gif') no-repeat scroll top right;
+ color: #444;
+ display: block;
+ float: left;
+ font: normal 12px arial, sans-serif;
+ height: 24px;
+ margin-right: 6px;
+ padding-right: 18px; /* sliding doors padding */
+ text-decoration: none;
+}
+
+a.button span {
+ background: transparent url('../images/bg_button_span.gif') no-repeat;
+ display: block;
+ line-height: 14px;
+ padding: 5px 0 5px 18px;
+}
+
+a.button:active {
+ background-position: bottom right;
+ color: #000;
+ outline: none; /* hide dotted outline in Firefox */
+}
+
+a.button:active span {
+ background-position: bottom left;
+ padding: 6px 0 4px 18px; /* push text down 1px */
+}
+p.listpara
+{text-indent: 15%}
+
+H1 {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:170%;
+ color:#336699;
+ border : solid ##3333CC;
+ width : 100%;
+ border-width : 0px 0px 2px 0px;
+ margin-left: 20px;
+}
+
+H2 {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:130%;
+ font-style: italic;
+ color: white;
+ width : 100%;
+ margin-left: 20px;
+}
+
+H3 {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:110%;
+ color:#336699;
+ border : solid #CCCC99;
+ width : 100%;
+ border-width : 0px 0px 2px 0px;
+}
+
+H4 {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:92%;
+ color:#000000;
+ font-weight: bold;
+ width : 100%;
+}
+
+.code_no_color {
+ color : #000000;
+ font-family : "Courier New", "Courier", "monospace";
+}
+
+code {
+ color : #336699;
+ font-family : "Courier New", "Courier", "monospace";
+}
+
+P.indent {
+ text-indent: 9%;
+}
+
+table.borders {
+ border : 1% solid #BDB76B;
+}
+
+TR {
+ text-align : left;
+ vertical-align : top;
+}
+
+TH {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 11pt;
+ color:#000000;
+ font-weight: bold;
+}
+
+TD {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 11pt;
+ color:#000000;
+}
+
+.smalltext {
+ font-size:80%;
+}
+
+p.note {
+ display: block;
+ font-family: Arial, Helvetica, Geneva, sans-serif;
+ font-size: 95%;
+}
+
+p.warning {
+ display: block;
+ font-family: Arial, Helvetica, Geneva, sans-serif;
+ font-size: 95%;
+}
+
+pre {
+ font-family: "Courier New", Courier, mono;
+ font-size: 92%;
+ text-indent : 15%;
+}
+
+table.pretty {
+ background: whitesmoke;
+ border-collapse: collapse;
+}
+table.pretty th, table.pretty td {
+ border: 1px silver solid;
+ padding: 0.2em;
+ font-size: 10pt;
+}
+table.pretty th {
+ background: green;
+ text-align: left;
+ color: white;
+}
+table.pretty caption {
+ margin-left: inherit;
+ margin-right: inherit;
+}
+
+table.accent {
+ background: green;
+}
+
diff --git a/mysports/admin.services/src/main/resources/green.css b/mysports/admin.services/src/main/resources/green.css
new file mode 100644
index 0000000..8136a7a
--- /dev/null
+++ b/mysports/admin.services/src/main/resources/green.css
@@ -0,0 +1,212 @@
+#*******************************************************************************
+# * Copyright (c) 2010 Oracle. All rights reserved.
+# * This program and the accompanying materials are made available under the
+# * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+# * which accompanies this distribution.
+# * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+# * and the Eclipse Distribution License is available at
+# * http://www.eclipse.org/org/documents/edl-v10.php.
+# *
+# * Contributors:
+# * dclarke - MySports Example for EclipseLink 2.3
+# ******************************************************************************/
+BODY, P, LI, UL, OL {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 50%;
+ color:#000000;
+ list-style-position: outside;
+}
+
+A:link {
+ font-family: Arial, Helvetica, sans-serif;
+ color:#663300;
+
+}
+
+A:active {
+ font-family: Arial, Helvetica, sans-serif;
+ color:#ff6600;
+
+}
+
+A:visited {
+ font-family: Arial, Helvetica, sans-serif;
+ color:#996633;
+
+}
+
+A.navigation:link
+{
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:65%;
+ color:#996633;
+}
+
+A.navigation:active
+{
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:65%;
+ color:#996633;
+}
+
+A.navigation:visited
+{
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:65%;
+ color:#996633;
+}
+
+.clear { /* generic container (i.e. div) for floating buttons */
+ overflow: hidden;
+ width: 100%;
+}
+
+c.button {
+ background: transparent url('../images/bg_button_a.gif') no-repeat scroll top right;
+ color: #444;
+ display: block;
+ float: left;
+ font: normal 12px arial, sans-serif;
+ height: 24px;
+ margin-right: 6px;
+ padding-right: 18px; /* sliding doors padding */
+ text-decoration: none;
+}
+
+a.button span {
+ background: transparent url('../images/bg_button_span.gif') no-repeat;
+ display: block;
+ line-height: 14px;
+ padding: 5px 0 5px 18px;
+}
+
+a.button:active {
+ background-position: bottom right;
+ color: #000;
+ outline: none; /* hide dotted outline in Firefox */
+}
+
+a.button:active span {
+ background-position: bottom left;
+ padding: 6px 0 4px 18px; /* push text down 1px */
+}
+p.listpara
+{text-indent: 15%}
+
+H1 {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:170%;
+ color:#336699;
+ border : solid ##3333CC;
+ width : 100%;
+ border-width : 0px 0px 2px 0px;
+ margin-left: 20px;
+}
+
+H2 {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:130%;
+ font-style: italic;
+ color: white;
+ width : 100%;
+ margin-left: 20px;
+}
+
+H3 {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:110%;
+ color:#336699;
+ border : solid #CCCC99;
+ width : 100%;
+ border-width : 0px 0px 2px 0px;
+}
+
+H4 {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:92%;
+ color:#000000;
+ font-weight: bold;
+ width : 100%;
+}
+
+.code_no_color {
+ color : #000000;
+ font-family : "Courier New", "Courier", "monospace";
+}
+
+code {
+ color : #336699;
+ font-family : "Courier New", "Courier", "monospace";
+}
+
+P.indent {
+ text-indent: 9%;
+}
+
+table.borders {
+ border : 1% solid #BDB76B;
+}
+
+TR {
+ text-align : left;
+ vertical-align : top;
+}
+
+TH {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 11pt;
+ color:#000000;
+ font-weight: bold;
+}
+
+TD {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 11pt;
+ color:#000000;
+}
+
+.smalltext {
+ font-size:80%;
+}
+
+p.note {
+ display: block;
+ font-family: Arial, Helvetica, Geneva, sans-serif;
+ font-size: 95%;
+}
+
+p.warning {
+ display: block;
+ font-family: Arial, Helvetica, Geneva, sans-serif;
+ font-size: 95%;
+}
+
+pre {
+ font-family: "Courier New", Courier, mono;
+ font-size: 92%;
+ text-indent : 15%;
+}
+
+table.pretty {
+ background: whitesmoke;
+ border-collapse: collapse;
+}
+table.pretty th, table.pretty td {
+ border: 1px silver solid;
+ padding: 0.2em;
+ font-size: 10pt;
+}
+table.pretty th {
+ background: green;
+ text-align: left;
+ color: white;
+}
+table.pretty caption {
+ margin-left: inherit;
+ margin-right: inherit;
+}
+
+table.accent {
+ background: green;
+}
+
diff --git a/mysports/admin.services/src/main/resources/red.css b/mysports/admin.services/src/main/resources/red.css
new file mode 100644
index 0000000..23f0864
--- /dev/null
+++ b/mysports/admin.services/src/main/resources/red.css
@@ -0,0 +1,209 @@
+#*******************************************************************************
+# * Copyright (c) 2010 Oracle. All rights reserved.
+# * This program and the accompanying materials are made available under the
+# * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+# * which accompanies this distribution.
+# * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+# * and the Eclipse Distribution License is available at
+# * http://www.eclipse.org/org/documents/edl-v10.php.
+# *
+# * Contributors:
+# * dclarke - MySports Example for EclipseLink 2.3
+# ******************************************************************************/
+BODY, P, LI, UL, OL {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 50%;
+ color:#000000;
+ list-style-position: outside;
+}
+
+A:link {
+ font-family: Arial, Helvetica, sans-serif;
+ color:#663300;
+}
+
+A:active {
+ font-family: Arial, Helvetica, sans-serif;
+ color:#ff6600;
+
+}
+
+A:visited {
+ font-family: Arial, Helvetica, sans-serif;
+ color:#996633;
+
+}
+
+A.navigation:link
+{
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:65%;
+ color:#996633;
+}
+
+A.navigation:active
+{
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:65%;
+ color:#996633;
+}
+
+A.navigation:visited
+{
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:65%;
+ color:#996633;
+}
+
+.clear { /* generic container (i.e. div) for floating buttons */
+ overflow: hidden;
+ width: 100%;
+}
+
+c.button {
+ background: transparent url('../images/bg_button_a.gif') no-repeat scroll top right;
+ color: #444;
+ display: block;
+ float: left;
+ font: normal 12px arial, sans-serif;
+ height: 24px;
+ margin-right: 6px;
+ padding-right: 18px; /* sliding doors padding */
+ text-decoration: none;
+}
+
+a.button span {
+ background: transparent url('../images/bg_button_span.gif') no-repeat;
+ display: block;
+ line-height: 14px;
+ padding: 5px 0 5px 18px;
+}
+
+a.button:active {
+ background-position: bottom right;
+ color: #000;
+ outline: none; /* hide dotted outline in Firefox */
+}
+
+a.button:active span {
+ background-position: bottom left;
+ padding: 6px 0 4px 18px; /* push text down 1px */
+}
+p.listpara
+{text-indent: 15%}
+
+H1 {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:200%;
+ color: red;
+ width : 100%;
+ border-width : 0px 0px 2px 0px;
+ margin-left: 20px;
+}
+
+H2 {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:130%;
+ font-style: italic;
+ color: white;
+ width : 100%;
+ margin-left: 20px;
+}
+
+H3 {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:110%;
+ color: red;
+ border : solid #CCCC99;
+ width : 100%;
+ border-width : 0px 0px 2px 0px;
+}
+
+H4 {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:92%;
+ color:#000000;
+ font-weight: bold;
+ width : 100%;
+}
+
+.code_no_color {
+ color : #000000;
+ font-family : "Courier New", "Courier", "monospace";
+}
+
+code {
+ color : #336699;
+ font-family : "Courier New", "Courier", "monospace";
+}
+
+P.indent {
+ text-indent: 9%;
+}
+
+table.borders {
+ border : 1% solid #BDB76B;
+}
+
+TR {
+ text-align : left;
+ vertical-align : top;
+}
+
+TH {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 11pt;
+ color:#000000;
+ font-weight: bold;
+}
+
+TD {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 11pt;
+ color:#000000;
+}
+
+.smalltext {
+ font-size:80%;
+}
+
+p.note {
+ display: block;
+ font-family: Arial, Helvetica, Geneva, sans-serif;
+ font-size: 95%;
+}
+
+p.warning {
+ display: block;
+ font-family: Arial, Helvetica, Geneva, sans-serif;
+ font-size: 95%;
+}
+
+pre {
+ font-family: "Courier New", Courier, mono;
+ font-size: 92%;
+ text-indent : 15%;
+}
+
+table.pretty {
+ background: whitesmoke;
+ border-collapse: collapse;
+}
+table.pretty th, table.pretty td {
+ border: 1px silver solid;
+ padding: 0.2em;
+ font-size: 10pt;
+}
+table.pretty th {
+ background: red;
+ text-align: left;
+ color: white;
+}
+table.pretty caption {
+ margin-left: inherit;
+ margin-right: inherit;
+}
+
+table.accent {
+ background: red;
+}
diff --git a/mysports/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/AdminPersistenceTesting.java b/mysports/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/AdminPersistenceTesting.java
new file mode 100644
index 0000000..f9a4028
--- /dev/null
+++ b/mysports/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/AdminPersistenceTesting.java
@@ -0,0 +1,115 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.4 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.admin.services.test;
+
+import java.lang.reflect.Proxy;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+
+import org.eclipse.persistence.config.PersistenceUnitProperties;
+import org.eclipse.persistence.jpa.JpaHelper;
+import org.eclipse.persistence.sessions.server.Server;
+import org.eclipse.persistence.tools.schemaframework.DefaultTableGenerator;
+import org.eclipse.persistence.tools.schemaframework.SchemaManager;
+import org.eclipse.persistence.tools.schemaframework.TableCreator;
+
+import eclipselink.example.mysports.admin.examples.ExampleLeagueDefinition;
+import eclipselink.example.mysports.admin.services.AdminSchemaManager;
+import eclipselink.example.mysports.admin.services.HostedLeagueRepository;
+
+public class AdminPersistenceTesting {
+
+ public static Map<String, Object> add(Map<String, Object> properties) {
+ Map<String, Object> props = properties;
+
+ if (props == null) {
+ props = new HashMap<String, Object>();
+ }
+ // Ensure the persistence.xml provided data source are ignored for Java
+ // SE testing
+ props.put(PersistenceUnitProperties.NON_JTA_DATASOURCE, "");
+ props.put(PersistenceUnitProperties.JTA_DATASOURCE, "");
+
+ // Configure the use of embedded derby for the tests allowing system
+ // properties of the same name to override
+ setProperty(props, PersistenceUnitProperties.JDBC_DRIVER, "org.apache.derby.jdbc.EmbeddedDriver");
+ setProperty(props, PersistenceUnitProperties.JDBC_URL, "jdbc:derby:target/derby/mysports;create=true");
+ setProperty(props, PersistenceUnitProperties.JDBC_USER, "app");
+ setProperty(props, PersistenceUnitProperties.JDBC_PASSWORD, "app");
+
+ // Ensure weaving is used
+ props.put(PersistenceUnitProperties.WEAVING, "true");
+
+ return props;
+ }
+
+ public static Map<String, Object> get() {
+ return add(null);
+ }
+
+ public static HostedLeagueRepository createTestRepository(boolean replaceSchema, boolean populate) {
+ EntityManagerFactory emf = Persistence.createEntityManagerFactory("MySportsAdmin", get());
+ if (replaceSchema) {
+ AdminSchemaManager.createTables(emf);
+ }
+ HostedLeagueRepository repository = (HostedLeagueRepository) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] { HostedLeagueRepository.class }, new HostedLeagueRepositoryHandler(emf));
+
+ if (populate) {
+ ExampleLeagueDefinition.populateAll(repository);
+ }
+ return repository;
+ }
+
+ public static HostedLeagueRepository createTestRepository(boolean replaceSchema) {
+ return createTestRepository(replaceSchema, true);
+ }
+
+ public static EntityManagerFactory getEMF(HostedLeagueRepository repository) {
+ HostedLeagueRepositoryHandler handler = (HostedLeagueRepositoryHandler) Proxy.getInvocationHandler(repository);
+ return handler.getEmf();
+ }
+
+ public static void closeTestingRepository(HostedLeagueRepository repository, boolean dropTables) {
+ EntityManagerFactory emf = getEMF(repository);
+ if (dropTables) {
+ dropTables(emf);
+ }
+ emf.close();
+ }
+
+ public static void dropTables(EntityManagerFactory emf) {
+ Server session = JpaHelper.getServerSession(emf);
+ SchemaManager sm = new SchemaManager(session);
+
+ TableCreator tc = new DefaultTableGenerator(session.getProject(), true).generateDefaultTableCreator();
+ tc.setIgnoreDatabaseException(true);
+ tc.dropTables(session, sm, true);
+ }
+
+
+ /**
+ * Add the system property value if it exists, otherwise use the default
+ * value.
+ */
+ private static void setProperty(Map<String, Object> props, String key, String defaultValue) {
+ String value = defaultValue;
+ if (System.getProperties().containsKey(key)) {
+ value = System.getProperty(key);
+ }
+ props.put(key, value);
+ }
+
+}
diff --git a/mysports/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/CreateDatabaseTest.java b/mysports/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/CreateDatabaseTest.java
new file mode 100644
index 0000000..6000d01
--- /dev/null
+++ b/mysports/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/CreateDatabaseTest.java
@@ -0,0 +1,125 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.admin.services.test;
+
+import java.util.Map;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+
+import org.eclipse.persistence.config.PersistenceUnitProperties;
+import org.eclipse.persistence.config.SessionCustomizer;
+import org.eclipse.persistence.exceptions.IntegrityChecker;
+import org.eclipse.persistence.jpa.JpaHelper;
+import org.eclipse.persistence.sessions.Session;
+import org.eclipse.persistence.sessions.server.Server;
+import org.junit.Assert;
+import org.junit.Test;
+
+import eclipselink.example.mysports.admin.services.HostedLeagueRepository;
+
+/**
+ * Create Schema and verify using integrity checker.
+ *
+ * @author dclarke
+ * @since EclipseLink 2.3.0
+ */
+public class CreateDatabaseTest {
+
+ /**
+ * Using EclipseLink's schema generation when the
+ * {@link EntityManagerFactory} is created to drop and create the tables and
+ * sequences.
+ */
+ @Test
+ public void createMySportsAdminSchema() throws Exception {
+ HostedLeagueRepository repository= null;
+
+ try {
+ repository = AdminPersistenceTesting.createTestRepository(true, false);
+ } finally {
+ if (repository != null) {
+ AdminPersistenceTesting.closeTestingRepository(repository, false);
+ }
+ }
+ }
+
+ /**
+ * Verify that the database is empty with multitenancy disabled
+ */
+ @Test
+ public void verifyEmpty() throws Exception {
+ HostedLeagueRepository repository= null;
+
+ try {
+ repository = AdminPersistenceTesting.createTestRepository(true, false);
+ EntityManagerFactory emf = AdminPersistenceTesting.getEMF(repository);
+ EntityManager em = emf.createEntityManager();
+
+ try {
+ Assert.assertEquals(0, em.createQuery("SELECT COUNT(o) FROM HostedLeague o", Number.class).getSingleResult().intValue());
+ } finally {
+ em.close();
+ }
+ } finally {
+ if (repository != null) {
+ AdminPersistenceTesting.closeTestingRepository(repository, false);
+ }
+ }
+ }
+
+ /**
+ * Verify the schema using the integrity checker to compare database
+ * structure to that expected in the mappings.
+ */
+ @Test
+ public void verifyMySportsAdminSchema() {
+ Map<String, Object> properties = AdminPersistenceTesting.get();
+
+ properties.put(PersistenceUnitProperties.SESSION_CUSTOMIZER, EnableIntegrityChecker.class.getName());
+ properties.put(PersistenceUnitProperties.DEPLOY_ON_STARTUP, Boolean.TRUE.toString());
+ properties.put(PersistenceUnitProperties.DDL_GENERATION, PersistenceUnitProperties.DROP_AND_CREATE);
+ properties.put(PersistenceUnitProperties.DDL_GENERATION_MODE, PersistenceUnitProperties.DDL_DATABASE_GENERATION);
+
+ EntityManagerFactory emf = null;
+ try {
+ emf = Persistence.createEntityManagerFactory("MySportsAdmin", properties);
+
+ Server session = JpaHelper.getServerSession(emf);
+ IntegrityChecker ic = session.getIntegrityChecker();
+ Assert.assertNotNull(ic);
+ Assert.assertTrue(ic.getCaughtExceptions().isEmpty());
+ } finally {
+ if (emf != null) {
+ emf.close();
+ }
+ }
+ }
+
+ /**
+ * {@link SessionCustomizer} that enables the {@link IntegrityChecker}.
+ *
+ * NOTE: If another {@link SessionCustomizer} is specified in the
+ * persistence.xml this one will replace it.
+ */
+ public static class EnableIntegrityChecker implements SessionCustomizer {
+
+ public void customize(Session session) throws Exception {
+ IntegrityChecker ic = new IntegrityChecker();
+ ic.setShouldCheckDatabase(true);
+ session.setIntegrityChecker(ic);
+ }
+
+ }
+}
diff --git a/mysports/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/HostedLeagueRepositoryHandler.java b/mysports/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/HostedLeagueRepositoryHandler.java
new file mode 100644
index 0000000..5e60910
--- /dev/null
+++ b/mysports/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/HostedLeagueRepositoryHandler.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.4 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.admin.services.test;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+
+import eclipselink.example.mysports.admin.services.HostedLeagueRepositoryBean;
+
+/**
+ * TODO
+ *
+ * @since EclipseLink 2.4.2
+ * @author dclarke
+ */
+class HostedLeagueRepositoryHandler implements InvocationHandler {
+
+ private EntityManagerFactory emf;
+
+ private HostedLeagueRepositoryBean repositoryBean;
+
+ protected HostedLeagueRepositoryHandler(EntityManagerFactory emf) {
+ super();
+ this.emf = emf;
+ this.repositoryBean = new HostedLeagueRepositoryBean();
+ }
+
+ public EntityManagerFactory getEmf() {
+ return emf;
+ }
+
+ HostedLeagueRepositoryBean getRepositoryBean() {
+ return repositoryBean;
+ }
+
+ @Override
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ EntityManager em = getEmf().createEntityManager();
+
+ try {
+ em.getTransaction().begin();
+ getRepositoryBean().setEntityManager(em);
+ return method.invoke(getRepositoryBean(), args);
+ } catch (InvocationTargetException ite) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ throw ite.getTargetException();
+ } finally {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().commit();
+ }
+ em.close();
+ getRepositoryBean().setEntityManager(null);
+ }
+ }
+
+}
diff --git a/mysports/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/TestCreateHostEnvironments.java b/mysports/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/TestCreateHostEnvironments.java
new file mode 100644
index 0000000..8ef6e20
--- /dev/null
+++ b/mysports/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/TestCreateHostEnvironments.java
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.admin.services.test;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import eclipselink.example.mysports.admin.model.Datasource;
+import eclipselink.example.mysports.admin.model.GlassFish;
+import eclipselink.example.mysports.admin.model.HostEnvironment;
+import eclipselink.example.mysports.admin.services.AdminSchemaManager;
+import eclipselink.example.mysports.admin.services.HostEnvironmentRepository;
+import eclipselink.example.mysports.admin.services.HostEnvironmentRepositoryBean;
+
+/**
+ * Create initial {@link Datasource} instances.
+ *
+ * @author dclarke
+ * @since EclipseLink 2.3.0
+ */
+public class TestCreateHostEnvironments {
+
+ private static EntityManagerFactory emf;
+
+ private EntityManager entityManager;
+
+ private HostEnvironmentRepositoryBean repository;
+
+ public HostEnvironmentRepository getRepository() {
+ return repository;
+ }
+
+ @Test
+ public void createEnvironments() {
+ HostEnvironment gf = new GlassFish();
+ gf.setName("GlassFish@localhost");
+ gf.setDescription("GlassFish 3.1.2 instance");
+
+ getRepository().create(gf);
+ }
+
+ @Before
+ public void setupRespoitory() {
+ repository = new HostEnvironmentRepositoryBean();
+ entityManager = emf.createEntityManager();
+ entityManager.getTransaction().begin();
+ repository.setEntityManager(entityManager);
+ }
+
+ @After
+ public void completeTransaction() {
+ if (this.entityManager != null && this.entityManager.isOpen()) {
+ if (this.entityManager.getTransaction().isActive()) {
+ this.entityManager.getTransaction().commit();
+ }
+ this.entityManager.close();
+ }
+ this.entityManager = null;
+ this.repository = null;
+ }
+
+ @BeforeClass
+ public static void createReposirory() {
+ emf = Persistence.createEntityManagerFactory("MySportsAdmin", AdminPersistenceTesting.get());
+ AdminSchemaManager.createTables(emf);
+
+ EntityManager em = emf.createEntityManager();
+ try {
+ em.getTransaction().begin();
+ em.createQuery("DELETE FROM HostEnvironment").executeUpdate();
+ em.getTransaction().commit();
+ } finally {
+ em.close();
+ }
+ }
+
+ @AfterClass
+ public static void shutdown() {
+ if (emf != null && emf.isOpen()) {
+ emf.close();
+ }
+ emf = null;
+ }
+
+}
diff --git a/mysports/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/TestCreateLeagues.java b/mysports/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/TestCreateLeagues.java
new file mode 100644
index 0000000..b06a5bc
--- /dev/null
+++ b/mysports/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/TestCreateLeagues.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.admin.services.test;
+
+import javax.persistence.EntityManagerFactory;
+
+import org.eclipse.persistence.jpa.JpaHelper;
+import org.eclipse.persistence.sessions.server.Server;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import eclipselink.example.mysports.admin.examples.ExampleLeagueDefinition;
+import eclipselink.example.mysports.admin.services.HostedLeagueRepository;
+
+/**
+ * Create initial league entities.
+ *
+ * @author dclarke
+ * @since EclipseLink 2.3.0
+ */
+public class TestCreateLeagues {
+
+ @Test
+ public void verifySession() {
+ EntityManagerFactory emf = AdminPersistenceTesting.getEMF(repository);
+ Assert.assertNotNull(emf);
+
+ Server session = JpaHelper.getServerSession(emf);
+ Assert.assertNotNull(session);
+ Assert.assertTrue(session.isServerSession());
+ }
+
+ @Test
+ public void createLeagues() {
+ ExampleLeagueDefinition.populateAll(repository);
+ }
+
+ private static HostedLeagueRepository repository;
+
+ @BeforeClass
+ public static void createRespository() {
+ repository = AdminPersistenceTesting.createTestRepository(true, false);
+ }
+
+ @AfterClass
+ public static void closeRepository() {
+ AdminPersistenceTesting.closeTestingRepository(repository, false);
+ }
+
+}
diff --git a/mysports/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/TestHostedLeagueRepository.java b/mysports/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/TestHostedLeagueRepository.java
new file mode 100644
index 0000000..cdca89b
--- /dev/null
+++ b/mysports/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/TestHostedLeagueRepository.java
@@ -0,0 +1,128 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.4 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.admin.services.test;
+
+import java.lang.reflect.Proxy;
+import java.util.List;
+
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import eclipselink.example.mysports.admin.examples.ExampleLeagueDefinition;
+import eclipselink.example.mysports.admin.model.HostedLeague;
+import eclipselink.example.mysports.admin.services.HostedLeagueRepository;
+
+/**
+ * TODO
+ *
+ * @since EclipseLink 2.4.2
+ * @author dclarke
+ */
+public class TestHostedLeagueRepository {
+
+ @Test
+ public void verifyProxy() {
+ Assert.assertTrue(Proxy.isProxyClass(repository.getClass()));
+ }
+
+ @Test
+ public void verifySchema() {
+ //EntityManagerFactory emf = AdminPersistenceTesting.getEMF(repository);
+
+ }
+
+ @Test
+ public void verifyAllLeagues() {
+ List<HostedLeague> allLeagues = repository.allLeagues();
+
+ Assert.assertNotNull(allLeagues);
+ }
+
+ @Test
+ public void verifyAllSharedLeagues() {
+ List<HostedLeague> allLeagues = repository.allSharedLeagues();
+
+ Assert.assertNotNull(allLeagues);
+ }
+
+ //@Test
+ public void getValidLogos() {
+ Assert.assertNotNull(repository.getLogo(ExampleLeagueDefinition.HTHL.getLeague().getId()));
+ Assert.assertNotNull(repository.getLogo(ExampleLeagueDefinition.KFL.getLeague().getId()));
+ Assert.assertNotNull(repository.getLogo(ExampleLeagueDefinition.MHL.getLeague().getId()));
+ Assert.assertNotNull(repository.getLogo(ExampleLeagueDefinition.OSL.getLeague().getId()));
+ }
+
+ //@Test
+ public void getInValidLogo() {
+ try {
+ repository.getLogo("XXX");
+ } catch (IllegalArgumentException e) {
+ return;
+ }
+ Assert.fail("IllegalArgumentException expected but not thrown");
+
+ }
+
+ @Test
+ public void getValidCSS() {
+ Assert.assertNotNull(repository.getCSS(ExampleLeagueDefinition.HTHL.getLeague().getId()));
+ Assert.assertNotNull(repository.getCSS(ExampleLeagueDefinition.KFL.getLeague().getId()));
+ Assert.assertNotNull(repository.getCSS(ExampleLeagueDefinition.MHL.getLeague().getId()));
+ Assert.assertNotNull(repository.getCSS(ExampleLeagueDefinition.OSL.getLeague().getId()));
+ }
+
+ @Test
+ public void getInValidCSS() {
+ try {
+ repository.getCSS("XXX");
+ } catch (IllegalArgumentException e) {
+ return;
+ }
+ Assert.fail("IllegalArgumentException expected but not thrown");
+ }
+
+ @Test
+ public void getValidORM() {
+ Assert.assertNotNull(repository.getORM(ExampleLeagueDefinition.HTHL.getLeague().getId()));
+ Assert.assertNotNull(repository.getORM(ExampleLeagueDefinition.KFL.getLeague().getId()));
+ Assert.assertNotNull(repository.getORM(ExampleLeagueDefinition.MHL.getLeague().getId()));
+ Assert.assertNotNull(repository.getORM(ExampleLeagueDefinition.OSL.getLeague().getId()));
+ }
+
+ @Test
+ public void getInvalidORM() {
+ try {
+ repository.getORM("XXX");
+ } catch (IllegalArgumentException e) {
+ return;
+ }
+ Assert.fail("IllegalArgumentException expected but not thrown");
+ }
+
+ private static HostedLeagueRepository repository;
+
+ @BeforeClass
+ public static void createRespository() {
+ repository = AdminPersistenceTesting.createTestRepository(true, false);
+ ExampleLeagueDefinition.populateAll(repository);
+ }
+
+ @AfterClass
+ public static void closeRepository() {
+ AdminPersistenceTesting.closeTestingRepository(repository, true);
+ }
+
+}
diff --git a/mysports/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/VerifyModelAndMappingsTest.java b/mysports/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/VerifyModelAndMappingsTest.java
new file mode 100644
index 0000000..8bed71e
--- /dev/null
+++ b/mysports/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/VerifyModelAndMappingsTest.java
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.admin.services.test;
+
+import javax.persistence.EntityManagerFactory;
+
+import org.eclipse.persistence.descriptors.ClassDescriptor;
+import org.eclipse.persistence.internal.helper.Helper;
+import org.eclipse.persistence.jpa.JpaHelper;
+import org.eclipse.persistence.sessions.server.Server;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import eclipselink.example.mysports.admin.model.Extension;
+import eclipselink.example.mysports.admin.model.HostedLeague;
+import eclipselink.example.mysports.admin.model.Style;
+import eclipselink.example.mysports.admin.services.HostedLeagueRepository;
+
+/**
+ * @author dclarke
+ * @since EclipseLink 2.3.0
+ */
+public class VerifyModelAndMappingsTest {
+
+ @Test
+ public void verifySession() {
+ EntityManagerFactory emf = AdminPersistenceTesting.getEMF(repository);
+ Assert.assertNotNull(emf);
+
+ Server session = JpaHelper.getServerSession(emf);
+ Assert.assertNotNull(session);
+ Assert.assertTrue(session.isServerSession());
+ }
+
+ @Test
+ public void verifyLeague() {
+ EntityManagerFactory emf = AdminPersistenceTesting.getEMF(repository);
+ Server session = JpaHelper.getServerSession(emf);
+ ClassDescriptor descriptor = session.getClassDescriptor(HostedLeague.class);
+
+ Assert.assertNotNull(descriptor);
+ Assert.assertEquals(Helper.getShortClassName(descriptor.getJavaClass()), descriptor.getAlias());
+ }
+
+ @Test
+ public void verifyStyle() {
+ EntityManagerFactory emf = AdminPersistenceTesting.getEMF(repository);
+ Server session = JpaHelper.getServerSession(emf);
+ ClassDescriptor descriptor = session.getClassDescriptor(Style.class);
+
+ Assert.assertNotNull(descriptor);
+ Assert.assertEquals(Helper.getShortClassName(descriptor.getJavaClass()), descriptor.getAlias());
+ }
+
+ @Test
+ public void verifyExtension() {
+ EntityManagerFactory emf = AdminPersistenceTesting.getEMF(repository);
+ Server session = JpaHelper.getServerSession(emf);
+ ClassDescriptor descriptor = session.getClassDescriptor(Extension.class);
+
+ Assert.assertNotNull(descriptor);
+ //Assert.assertTrue(descriptor.isAggregateDescriptor());
+ }
+
+ private static HostedLeagueRepository repository;
+
+ @BeforeClass
+ public static void createRespository() {
+ repository = AdminPersistenceTesting.createTestRepository(true);
+ }
+
+ @AfterClass
+ public static void closeRepository() {
+ AdminPersistenceTesting.closeTestingRepository(repository, true);
+ }
+
+}
diff --git a/mysports/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/extensions/TestCreateOrmXml.java b/mysports/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/extensions/TestCreateOrmXml.java
new file mode 100644
index 0000000..7b2af57
--- /dev/null
+++ b/mysports/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/extensions/TestCreateOrmXml.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.admin.services.test.extensions;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLEntityMappings;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLEntityMappingsWriter;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import eclipselink.example.mysports.admin.services.HostedLeagueRepository;
+import eclipselink.example.mysports.admin.services.MappingsLoader;
+import eclipselink.example.mysports.admin.services.test.AdminPersistenceTesting;
+
+public class TestCreateOrmXml {
+
+ @Test
+ public void createEmpty() {
+ XMLEntityMappings mappings = new XMLEntityMappings();
+ mappings.setVersion("2.3");
+
+ XMLEntityMappingsWriter.write(mappings, System.out);
+ }
+
+ @Test
+ public void createFromDB() {
+ EntityManagerFactory emf = AdminPersistenceTesting.getEMF(repository);
+ EntityManager em = emf.createEntityManager();
+
+ try {
+ String xml = MappingsLoader.getORMapping(em, "OSL");
+ System.out.println(xml);
+
+ xml = MappingsLoader.getORMapping(em, "HTHL");
+ System.out.println(xml);
+ } finally {
+ em.close();
+ }
+ }
+
+ private static HostedLeagueRepository repository;
+
+ @BeforeClass
+ public static void createRespository() {
+ repository = AdminPersistenceTesting.createTestRepository(true);
+ }
+
+ @AfterClass
+ public static void closeRepository() {
+ AdminPersistenceTesting.closeTestingRepository(repository, false);
+ }
+}
diff --git a/mysports/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/league/TestDynamicJAXB.java b/mysports/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/league/TestDynamicJAXB.java
new file mode 100644
index 0000000..d5307d3
--- /dev/null
+++ b/mysports/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/league/TestDynamicJAXB.java
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.admin.services.test.league;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.List;
+
+import javax.xml.bind.JAXBException;
+
+import org.junit.Assert;
+
+import org.eclipse.persistence.dynamic.DynamicEntity;
+import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
+import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContextFactory;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import eclipselink.example.mysports.admin.services.test.services.ServerTests;
+
+/**
+ *
+ * @author dclarke
+ * @since EclipseLink 2.3.0
+ */
+@Category(ServerTests.class)
+public class TestDynamicJAXB {
+
+ @Test
+ public void verifyContext() throws Exception {
+ DynamicJAXBContext jaxbContext = createContext();
+
+ Assert.assertNotNull(jaxbContext);
+ }
+
+ @Test
+ public void verifyReadFromAdminServer() throws Exception {
+ DynamicJAXBContext jaxbContext = createContext();
+ URL url = new URL("http://localhost:8080/MySportsAdmin/rest/leagues");
+
+ DynamicEntity allLeagues = (DynamicEntity) jaxbContext.createUnmarshaller().unmarshal(url);
+
+ Assert.assertNotNull(allLeagues);
+ List<DynamicEntity> leagues = allLeagues.<List<DynamicEntity>>get("league");
+ Assert.assertNotNull(leagues);
+
+ for (DynamicEntity league: leagues) {
+ System.out.println("League(" + league.<String>get("id") + ", " + league.get("value") + ")");
+ }
+ }
+
+ private DynamicJAXBContext createContext() throws IOException, JAXBException {
+ URL url = new URL("http://localhost:8080/MySportsAdmin/xsds/leagues.xsd");
+ InputStream in = url.openStream();
+
+ try {
+ return DynamicJAXBContextFactory.createContextFromXSD(in, null, null, null);
+ } finally {
+ in.close();
+ }
+
+ }
+}
diff --git a/mysports/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/services/ServerTests.java b/mysports/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/services/ServerTests.java
new file mode 100644
index 0000000..77ab4b3
--- /dev/null
+++ b/mysports/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/services/ServerTests.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.4 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.admin.services.test.services;
+
+
+/**
+ * JUnit test category for tests that require a server to be run. these are
+ * excluded form the default tests.
+ *
+ * @author dclarke
+ * @since EclipseLink 2.4.2
+ */
+public interface ServerTests {
+}
\ No newline at end of file
diff --git a/mysports/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/services/glassfish/TestBaseJsonRest.java b/mysports/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/services/glassfish/TestBaseJsonRest.java
new file mode 100644
index 0000000..3bc32f1
--- /dev/null
+++ b/mysports/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/services/glassfish/TestBaseJsonRest.java
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.4 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.admin.services.test.services.glassfish;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.net.ConnectException;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.namespace.QName;
+import javax.xml.transform.stream.StreamSource;
+
+import org.junit.Assert;
+
+import org.eclipse.persistence.oxm.MediaType;
+
+import com.sun.jersey.api.client.ClientHandlerException;
+
+import eclipselink.example.mysports.admin.services.glassfish.MOXyContextHelper;
+import eclipselink.example.mysports.admin.services.glassfish.RESTOperations;
+import eclipselink.example.mysports.admin.services.glassfish.Result;
+
+/**
+ * Base class to simplify file and GlassFish admin REST calls.
+ *
+ * @author dclarke
+ * @since EclipseLink 2.4
+ */
+public abstract class TestBaseJsonRest {
+
+ protected Unmarshaller createJsonUnmarshaller() throws JAXBException {
+ return MOXyContextHelper.createUnmarshaller(MediaType.APPLICATION_JSON);
+ }
+
+ protected Marshaller createJsonMarshaller() throws JAXBException {
+ return MOXyContextHelper.createMarshaller(MediaType.APPLICATION_JSON);
+ }
+
+ protected StreamSource openSource(String fileName) throws FileNotFoundException {
+ String filePath = "src/" + getClass().getPackage().getName().replace(".", "/") + "/" + fileName;
+ return new StreamSource(new FileInputStream(filePath));
+ }
+
+ protected <T> T getResultFromServer(String server, String resourceURL, Class<T> resultClass) throws JAXBException {
+ RESTOperations ops = new RESTOperations(server);
+
+ try {
+ return ops.get(resourceURL, MediaType.APPLICATION_JSON, resultClass);
+ } catch (ClientHandlerException e) {
+ if (e.getCause() instanceof ConnectException) {
+ Assert.fail("GlassFish server on localhost not running");
+ }
+ throw e;
+ }
+ }
+
+ protected Result getResultFromServer(String server, String resourceURL) throws JAXBException {
+ return getResultFromServer(server, resourceURL, Result.class);
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ protected void printAsJson(Result result) throws JAXBException {
+ Marshaller marshaller = createJsonMarshaller();
+ marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+ JAXBElement<?> element = new JAXBElement(new QName(""), result.getClass(), result);
+ marshaller.marshal(element, System.out);
+ }
+}
\ No newline at end of file
diff --git a/mysports/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/services/glassfish/TestMOXyContext.java b/mysports/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/services/glassfish/TestMOXyContext.java
new file mode 100644
index 0000000..8dc233d
--- /dev/null
+++ b/mysports/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/services/glassfish/TestMOXyContext.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.4 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.admin.services.test.services.glassfish;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.transform.stream.StreamSource;
+
+import org.junit.Assert;
+
+import org.eclipse.persistence.oxm.MediaType;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import eclipselink.example.mysports.admin.services.glassfish.JDBCResource;
+import eclipselink.example.mysports.admin.services.glassfish.MOXyContextHelper;
+import eclipselink.example.mysports.admin.services.test.services.ServerTests;
+
+/**
+ * @author dclarke
+ * @since EclipseLink 2.4
+ */
+@Category(ServerTests.class)
+public class TestMOXyContext {
+
+ @Test
+ public void createContext() throws JAXBException {
+ JAXBContext context = MOXyContextHelper.createContext();
+
+ Assert.assertNotNull(context);
+ Assert.assertTrue(context instanceof org.eclipse.persistence.jaxb.JAXBContext);
+ }
+
+ // @Test
+ public void marshalJDBCResourceAsJSON() throws JAXBException {
+ JDBCResource resource = new JDBCResource();
+ resource.setJndiName("jdbc/MySportsX");
+ resource.setPoolName("mysports");
+
+ Marshaller marshaller = MOXyContextHelper.createMarshaller(MediaType.APPLICATION_JSON);
+
+ StringWriter writer = new StringWriter();
+ marshaller.marshal(resource, writer);
+
+ Assert.assertEquals("{\"id\":\"jdbc/MySportsX\",\"poolName\":\"mysports\"}", writer.toString());
+ }
+
+ // @Test
+ public void unmarshalJDBCResourceAsJSON() throws JAXBException {
+ Unmarshaller unmarshaller = MOXyContextHelper.createUnmarshaller(MediaType.APPLICATION_JSON);
+ unmarshaller.setProperty("eclipselink.json.include-root", false);
+
+ JAXBElement<JDBCResource> resourceElement = unmarshaller.unmarshal(new StreamSource(new StringReader("{\"id\":\"jdbc/MySportsX\",\"poolName\":\"mysports\"}}")), JDBCResource.class);
+ JDBCResource resource = resourceElement.getValue();
+
+ Assert.assertNotNull(resource);
+ Assert.assertEquals("jdbc/MySportsX", resource.getJndiName());
+ Assert.assertEquals("mysports", resource.getPoolName());
+ }
+}
diff --git a/mysports/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/services/glassfish/TestParseJDBCConnectPool_mysports.java b/mysports/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/services/glassfish/TestParseJDBCConnectPool_mysports.java
new file mode 100644
index 0000000..6da4be0
--- /dev/null
+++ b/mysports/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/services/glassfish/TestParseJDBCConnectPool_mysports.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.4 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.admin.services.test.services.glassfish;
+
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import eclipselink.example.mysports.admin.services.glassfish.Message;
+import eclipselink.example.mysports.admin.services.test.services.ServerTests;
+
+@Category(ServerTests.class)
+public class TestParseJDBCConnectPool_mysports extends TestBaseJsonRest{
+
+ @Test
+ public void parse() throws Exception {
+ Unmarshaller unmarshaller = createJsonUnmarshaller();
+ Marshaller marshaller = createJsonMarshaller();
+ marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+
+ Message message = unmarshaller.unmarshal(openSource("jdbc-connection-pool_mysports.json"), Message.class).getValue();
+
+
+ marshaller.marshal(message, System.out);
+ }
+
+}
\ No newline at end of file
diff --git a/mysports/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/services/glassfish/TestParseJDBCConnectPool_mysports_property.java b/mysports/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/services/glassfish/TestParseJDBCConnectPool_mysports_property.java
new file mode 100644
index 0000000..b58bfc0
--- /dev/null
+++ b/mysports/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/services/glassfish/TestParseJDBCConnectPool_mysports_property.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.4 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.admin.services.test.services.glassfish;
+
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import eclipselink.example.mysports.admin.services.glassfish.Result;
+import eclipselink.example.mysports.admin.services.test.services.ServerTests;
+
+@Category(ServerTests.class)
+public class TestParseJDBCConnectPool_mysports_property extends TestBaseJsonRest {
+
+ @Test
+ public void parseJSON() throws Exception {
+ Unmarshaller unmarshaller = createJsonUnmarshaller();
+ Marshaller marshaller = createJsonMarshaller();
+ marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+
+ Result result = unmarshaller.unmarshal(openSource("jdbc-connection-pool_mysports_property.json"), Result.class).getValue();
+
+ marshaller.marshal(result, System.out);
+
+ }
+
+}
\ No newline at end of file
diff --git a/mysports/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/services/glassfish/TestParseJDBCResources.java b/mysports/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/services/glassfish/TestParseJDBCResources.java
new file mode 100644
index 0000000..32a9e0d
--- /dev/null
+++ b/mysports/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/services/glassfish/TestParseJDBCResources.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.4 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.admin.services.test.services.glassfish;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.namespace.QName;
+
+import org.junit.Assert;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import eclipselink.example.mysports.admin.services.glassfish.JDBCResource;
+import eclipselink.example.mysports.admin.services.test.services.ServerTests;
+
+@Category(ServerTests.class)
+public class TestParseJDBCResources extends TestBaseJsonRest {
+
+ @Test
+ public void parseFromFile() throws Exception {
+ Unmarshaller unmarshaller = createJsonUnmarshaller();
+ Marshaller marshaller = createJsonMarshaller();
+ marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+
+ JDBCResource resource = unmarshaller.unmarshal(openSource("jdbc-resource.json"), JDBCResource.class).getValue();
+
+ Assert.assertNotNull(resource);
+
+ JAXBElement<JDBCResource> element = new JAXBElement<JDBCResource>(new QName(""), JDBCResource.class, resource);
+ marshaller.marshal(element, System.out);
+ }
+
+ @Test
+ public void getJDBCResourceFromServer() throws Exception {
+ JDBCResource result = getResultFromServer("localhost", JDBCResource.RESOURCE_URI + "jdbc%2FMySports", JDBCResource.class);
+
+ Assert.assertNotNull(result);
+
+ System.out.println("RESULT:\n" + result);
+
+ printAsJson(result);
+ }
+
+ @Test
+ public void getJDBCResourceFromServer2() throws Exception {
+ JDBCResource result = getResultFromServer("localhost", JDBCResource.RESOURCE_URI + "jdbc%2FMySports", JDBCResource.class);
+
+ Assert.assertNotNull(result);
+
+ System.out.println("RESULT:\n" + result);
+
+ printAsJson(result);
+ }
+}
\ No newline at end of file
diff --git a/mysports/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/services/glassfish/TestParseListJDBCConnectionPools.java b/mysports/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/services/glassfish/TestParseListJDBCConnectionPools.java
new file mode 100644
index 0000000..ff80960
--- /dev/null
+++ b/mysports/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/services/glassfish/TestParseListJDBCConnectionPools.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.4 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.admin.services.test.services.glassfish;
+
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import eclipselink.example.mysports.admin.services.glassfish.Message;
+import eclipselink.example.mysports.admin.services.glassfish.Result;
+import eclipselink.example.mysports.admin.services.test.services.ServerTests;
+
+@Category(ServerTests.class)
+public class TestParseListJDBCConnectionPools extends TestBaseJsonRest {
+
+ @Test
+ public void parse() throws Exception {
+ Unmarshaller unmarshaller = createJsonUnmarshaller();
+ Marshaller marshaller = createJsonMarshaller();
+ marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+
+ Message message = unmarshaller.unmarshal(openSource("list-jdbc-connection-pools.json"), Message.class).getValue();
+
+ marshaller.marshal(message, System.out);
+ }
+
+ @Test
+ public void getJDBCResourceFromServer() throws Exception {
+ Result result = getResultFromServer("localhost", "/domain/resources/list-jdbc-connection-pools");
+
+ System.out.println("RESULT:\n" + result);
+
+ for (String name : result.getChildrenMessages()) {
+ System.out.println("JDBC Connection Pool: \"" + name + "\"");
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/mysports/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/services/glassfish/TestParseListJDBCResources.java b/mysports/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/services/glassfish/TestParseListJDBCResources.java
new file mode 100644
index 0000000..0eab303
--- /dev/null
+++ b/mysports/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/services/glassfish/TestParseListJDBCResources.java
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.4 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.admin.services.test.services.glassfish;
+
+import java.net.ConnectException;
+
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+
+import org.junit.Assert;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.sun.jersey.api.client.ClientHandlerException;
+
+import eclipselink.example.mysports.admin.services.glassfish.JDBCResource;
+import eclipselink.example.mysports.admin.services.glassfish.RESTOperations;
+import eclipselink.example.mysports.admin.services.glassfish.Result;
+import eclipselink.example.mysports.admin.services.test.services.ServerTests;
+
+@Category(ServerTests.class)
+public class TestParseListJDBCResources extends TestBaseJsonRest {
+
+ @Test
+ public void unmarshalMarshal() throws Exception {
+ Unmarshaller unmarshaller = createJsonUnmarshaller();
+ Marshaller marshaller = createJsonMarshaller();
+ marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+
+ Result resources = unmarshaller.unmarshal(openSource("list-jdbc-resources.json"), Result.class).getValue();
+
+ Assert.assertNotNull(resources);
+ marshaller.marshal(resources, System.out);
+ }
+
+ @Test
+ public void getJDBCResourceNames() throws Exception {
+ Unmarshaller unmarshaller = createJsonUnmarshaller();
+ Marshaller marshaller = createJsonMarshaller();
+ marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+
+ Result resources = unmarshaller.unmarshal(openSource("list-jdbc-resources.json"), Result.class).getValue();
+
+ Assert.assertNotNull(resources);
+
+ String[] names = resources.getChildrenMessages();
+
+ Assert.assertNotNull(names);
+ Assert.assertEquals(3, names.length);
+
+ for (String name : names) {
+ System.out.println("JDBC Resource: \"" + name + "\"");
+ }
+ }
+
+ @Test
+ public void getJDBCResourceListFromServer() throws Exception {
+ Result result = getResultFromServer("localhost", JDBCResource.LIST_URI);
+
+ Assert.assertNotNull(result);
+
+ System.out.println("RESULT:\n" + result);
+ for (String name : result.getChildrenMessages()) {
+ System.out.println("JDBC Resource: \"" + name + "\"");
+ }
+ }
+
+ @Test
+ public void getJDBCResourceNamesFromServer() throws Exception {
+ RESTOperations ops = new RESTOperations("localhost");
+ String[] names = null;
+
+ try {
+ names = JDBCResource.getJDBCResourceNames(ops);
+ } catch (ClientHandlerException e) {
+ if (e.getCause() instanceof ConnectException) {
+ Assert.fail("GlassFish server on localhost not running");
+ }
+ throw e;
+ }
+
+ Assert.assertNotNull(names);
+ Assert.assertTrue(names.length > 0);
+
+ for (String name : names) {
+ System.out.println("JDBC Resource: \"" + name + "\"");
+ }
+ }
+}
\ No newline at end of file
diff --git a/mysports/admin.services/src/test/resource/eclipselink-example-mysports.properties b/mysports/admin.services/src/test/resource/eclipselink-example-mysports.properties
new file mode 100644
index 0000000..e3c5237
--- /dev/null
+++ b/mysports/admin.services/src/test/resource/eclipselink-example-mysports.properties
@@ -0,0 +1,19 @@
+javax.persistence.jdbc.url=jdbc:derby:target/derby/mysports;create=true
+javax.persistence.jdbc.user=app
+javax.persistence.jdbc.password=app
+javax.persistence.jdbc.driver=org.apache.derby.jdbc.EmbeddedDriver
+
+# Ensure that the data source info in persistence.xml is replaced
+javax.persistence.jtaDataSource=
+javax.persistence.nonJtaDataSource=
+javax.persistence.transactionType=RESOURCE_LOCAL
+
+eclipselink.logging.level=FINE
+eclipselink.logging.connection=false
+eclipselink.logging.timestamp=false
+eclipselink.logging.thread=false
+eclipselink.logging.session=false
+eclipselink.logging.exceptions=false
+eclipselink.logging.level.sql=FINE
+eclipselink.logging.level.metadata=WARNING
+eclipselink.logging.parameters=true
\ No newline at end of file
diff --git a/mysports/admin.services/src/test/resource/eclipselink/example/mysports/admin/services/test/services/glassfish/eclipselink-example-mysports.properties b/mysports/admin.services/src/test/resource/eclipselink/example/mysports/admin/services/test/services/glassfish/eclipselink-example-mysports.properties
new file mode 100644
index 0000000..07f4600
--- /dev/null
+++ b/mysports/admin.services/src/test/resource/eclipselink/example/mysports/admin/services/test/services/glassfish/eclipselink-example-mysports.properties
@@ -0,0 +1,19 @@
+javax.persistence.jdbc.url=jdbc:derby:testmysports;create=true
+javax.persistence.jdbc.user=app
+javax.persistence.jdbc.password=app
+javax.persistence.jdbc.driver=org.apache.derby.jdbc.EmbeddedDriver
+
+# Ensure that the data source info in persistence.xml is replaced
+javax.persistence.jtaDataSource=
+javax.persistence.nonJtaDataSource=
+javax.persistence.transactionType=RESOURCE_LOCAL
+
+eclipselink.logging.level=FINE
+eclipselink.logging.connection=false
+eclipselink.logging.timestamp=false
+eclipselink.logging.thread=false
+eclipselink.logging.session=false
+eclipselink.logging.exceptions=false
+eclipselink.logging.level.sql=FINE
+eclipselink.logging.level.metadata=WARNING
+eclipselink.logging.parameters=true
\ No newline at end of file
diff --git a/mysports/admin.services/src/test/resource/eclipselink/example/mysports/admin/services/test/services/glassfish/jdbc-connection-pool_mysports.json b/mysports/admin.services/src/test/resource/eclipselink/example/mysports/admin/services/test/services/glassfish/jdbc-connection-pool_mysports.json
new file mode 100644
index 0000000..0f9f933
--- /dev/null
+++ b/mysports/admin.services/src/test/resource/eclipselink/example/mysports/admin/services/test/services/glassfish/jdbc-connection-pool_mysports.json
@@ -0,0 +1,304 @@
+{
+ "message": "",
+ "command": "jdbc-connection-pool",
+ "exit_code": "SUCCESS",
+ "extraProperties": {
+ "commands": [],
+ "methods": [
+ {
+ "name": "GET"
+ },
+ {},
+ {
+ "name": "POST",
+ "messageParameters": {
+ "allowNonComponentCallers": {
+ "optional": "true",
+ "type": "boolean",
+ "defaultValue": "false",
+ "key": "false"
+ },
+ "associateWithThread": {
+ "optional": "true",
+ "type": "boolean",
+ "defaultValue": "false",
+ "key": "false"
+ },
+ "connectionCreationRetryAttempts": {
+ "optional": "true",
+ "type": "string",
+ "defaultValue": "0",
+ "key": "false"
+ },
+ "connectionCreationRetryIntervalInSeconds": {
+ "optional": "true",
+ "type": "string",
+ "defaultValue": "10",
+ "key": "false"
+ },
+ "connectionLeakReclaim": {
+ "optional": "true",
+ "type": "boolean",
+ "defaultValue": "false",
+ "key": "false"
+ },
+ "connectionLeakTimeoutInSeconds": {
+ "optional": "true",
+ "type": "string",
+ "defaultValue": "0",
+ "key": "false"
+ },
+ "connectionValidationMethod": {
+ "optional": "true",
+ "type": "string",
+ "defaultValue": "table",
+ "key": "false"
+ },
+ "datasourceClassname": {
+ "optional": "true",
+ "type": "string",
+ "key": "false"
+ },
+ "description": {
+ "optional": "true",
+ "type": "string",
+ "key": "false"
+ },
+ "driverClassname": {
+ "optional": "true",
+ "type": "string",
+ "key": "false"
+ },
+ "failAllConnections": {
+ "optional": "true",
+ "type": "boolean",
+ "defaultValue": "false",
+ "key": "false"
+ },
+ "idleTimeoutInSeconds": {
+ "optional": "true",
+ "type": "string",
+ "defaultValue": "300",
+ "key": "false"
+ },
+ "initSql": {
+ "optional": "true",
+ "type": "string",
+ "key": "false"
+ },
+ "isConnectionValidationRequired": {
+ "optional": "true",
+ "type": "boolean",
+ "defaultValue": "false",
+ "key": "false"
+ },
+ "isIsolationLevelGuaranteed": {
+ "optional": "true",
+ "type": "boolean",
+ "defaultValue": "true",
+ "key": "false"
+ },
+ "lazyConnectionAssociation": {
+ "optional": "true",
+ "type": "boolean",
+ "defaultValue": "false",
+ "key": "false"
+ },
+ "lazyConnectionEnlistment": {
+ "optional": "true",
+ "type": "boolean",
+ "defaultValue": "false",
+ "key": "false"
+ },
+ "matchConnections": {
+ "optional": "true",
+ "type": "boolean",
+ "defaultValue": "false",
+ "key": "false"
+ },
+ "maxConnectionUsageCount": {
+ "optional": "true",
+ "type": "string",
+ "defaultValue": "0",
+ "key": "false"
+ },
+ "maxPoolSize": {
+ "optional": "true",
+ "type": "string",
+ "defaultValue": "32",
+ "key": "false"
+ },
+ "maxWaitTimeInMillis": {
+ "optional": "true",
+ "type": "string",
+ "defaultValue": "60000",
+ "key": "false"
+ },
+ "name": {
+ "optional": "true",
+ "type": "string",
+ "key": "true"
+ },
+ "nonTransactionalConnections": {
+ "optional": "true",
+ "type": "boolean",
+ "defaultValue": "false",
+ "key": "false"
+ },
+ "objectType": {
+ "optional": "true",
+ "type": "string",
+ "defaultValue": "user",
+ "key": "false"
+ },
+ "ping": {
+ "optional": "true",
+ "type": "boolean",
+ "defaultValue": "false",
+ "key": "false"
+ },
+ "poolResizeQuantity": {
+ "optional": "true",
+ "type": "string",
+ "defaultValue": "2",
+ "key": "false"
+ },
+ "pooling": {
+ "optional": "true",
+ "type": "boolean",
+ "defaultValue": "true",
+ "key": "false"
+ },
+ "resType": {
+ "optional": "true",
+ "type": "string",
+ "key": "false"
+ },
+ "sqlTraceListeners": {
+ "optional": "true",
+ "type": "string",
+ "key": "false"
+ },
+ "statementCacheSize": {
+ "optional": "true",
+ "type": "string",
+ "defaultValue": "0",
+ "key": "false"
+ },
+ "statementLeakReclaim": {
+ "optional": "true",
+ "type": "boolean",
+ "defaultValue": "false",
+ "key": "false"
+ },
+ "statementLeakTimeoutInSeconds": {
+ "optional": "true",
+ "type": "string",
+ "defaultValue": "0",
+ "key": "false"
+ },
+ "statementTimeoutInSeconds": {
+ "optional": "true",
+ "type": "int",
+ "defaultValue": "-1",
+ "key": "false"
+ },
+ "steadyPoolSize": {
+ "optional": "true",
+ "type": "string",
+ "defaultValue": "8",
+ "key": "false"
+ },
+ "transactionIsolationLevel": {
+ "optional": "true",
+ "type": "string",
+ "key": "false"
+ },
+ "validateAtmostOncePeriodInSeconds": {
+ "optional": "true",
+ "type": "string",
+ "defaultValue": "0",
+ "key": "false"
+ },
+ "validationClassname": {
+ "optional": "true",
+ "type": "string",
+ "key": "false"
+ },
+ "validationTableName": {
+ "optional": "true",
+ "type": "string",
+ "key": "false"
+ },
+ "wrapJdbcObjects": {
+ "optional": "true",
+ "type": "boolean",
+ "defaultValue": "true",
+ "key": "false"
+ }
+ }
+ },
+ {
+ "name": "DELETE",
+ "messageParameters": {
+ "cascade": {
+ "acceptableValues": "",
+ "optional": "true",
+ "type": "boolean",
+ "defaultValue": "false"
+ },
+ "target": {
+ "acceptableValues": "",
+ "optional": "true",
+ "type": "string",
+ "defaultValue": ""
+ }
+ }
+ }
+ ],
+ "entity": {
+ "allowNonComponentCallers": "false",
+ "associateWithThread": "false",
+ "connectionCreationRetryAttempts": "0",
+ "connectionCreationRetryIntervalInSeconds": "10",
+ "connectionLeakReclaim": "false",
+ "connectionLeakTimeoutInSeconds": "0",
+ "connectionValidationMethod": "table",
+ "datasourceClassname": "com.mysql.jdbc.jdbc2.optional.MysqlDataSource",
+ "description": "",
+ "driverClassname": "",
+ "failAllConnections": "false",
+ "idleTimeoutInSeconds": "300",
+ "initSql": null,
+ "isConnectionValidationRequired": "false",
+ "isIsolationLevelGuaranteed": "true",
+ "lazyConnectionAssociation": "false",
+ "lazyConnectionEnlistment": "false",
+ "matchConnections": "false",
+ "maxConnectionUsageCount": "0",
+ "maxPoolSize": "32",
+ "maxWaitTimeInMillis": "60000",
+ "name": "mysports",
+ "nonTransactionalConnections": "false",
+ "objectType": "user",
+ "ping": "false",
+ "poolResizeQuantity": "2",
+ "pooling": "true",
+ "resType": "javax.sql.DataSource",
+ "sqlTraceListeners": null,
+ "statementCacheSize": "0",
+ "statementLeakReclaim": "false",
+ "statementLeakTimeoutInSeconds": "0",
+ "statementTimeoutInSeconds": "-1",
+ "steadyPoolSize": "8",
+ "transactionIsolationLevel": null,
+ "validateAtmostOncePeriodInSeconds": "0",
+ "validationClassname": null,
+ "validationTableName": null,
+ "wrapJdbcObjects": "true"
+ },
+ "childResources": {
+ "property": "http://localhost:4848/management/domain/resources/jdbc-connection-pool/mysports/property"
+ }
+ }
+}
\ No newline at end of file
diff --git a/mysports/admin.services/src/test/resource/eclipselink/example/mysports/admin/services/test/services/glassfish/jdbc-connection-pool_mysports_property.json b/mysports/admin.services/src/test/resource/eclipselink/example/mysports/admin/services/test/services/glassfish/jdbc-connection-pool_mysports_property.json
new file mode 100644
index 0000000..1147a5a
--- /dev/null
+++ b/mysports/admin.services/src/test/resource/eclipselink/example/mysports/admin/services/test/services/glassfish/jdbc-connection-pool_mysports_property.json
@@ -0,0 +1,29 @@
+{
+ "message": "",
+ "command": "property",
+ "exit_code": "SUCCESS",
+ "extraProperties": {
+ "properties": [
+ {
+ "name": "User",
+ "value": "root"
+ },
+ {
+ "name": "ServerName",
+ "value": "localhost"
+ },
+ {
+ "name": "Port",
+ "value": "3306"
+ },
+ {
+ "name": "DatabaseName",
+ "value": "mysports"
+ },
+ {
+ "name": "Password",
+ "value": "password"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/mysports/admin.services/src/test/resource/eclipselink/example/mysports/admin/services/test/services/glassfish/jdbc-resource.json b/mysports/admin.services/src/test/resource/eclipselink/example/mysports/admin/services/test/services/glassfish/jdbc-resource.json
new file mode 100644
index 0000000..6b792e3
--- /dev/null
+++ b/mysports/admin.services/src/test/resource/eclipselink/example/mysports/admin/services/test/services/glassfish/jdbc-resource.json
@@ -0,0 +1,71 @@
+{
+ "message":"",
+ "command":"jdbc-resource",
+ "exit_code":"SUCCESS",
+ "extraProperties":{
+ "commands":[
+
+ ],
+ "methods":[
+ {
+ "name":"GET"
+ },
+ {
+
+ },
+ {
+ "name":"POST",
+ "messageParameters":{
+ "description":{
+ "optional":"true",
+ "type":"string",
+ "key":"false"
+ },
+ "enabled":{
+ "optional":"true",
+ "type":"boolean",
+ "defaultValue":"true",
+ "key":"false"
+ },
+ "jndiName":{
+ "optional":"true",
+ "type":"string",
+ "key":"true"
+ },
+ "objectType":{
+ "optional":"true",
+ "type":"string",
+ "defaultValue":"user",
+ "key":"false"
+ },
+ "poolName":{
+ "optional":"true",
+ "type":"string",
+ "key":"false"
+ }
+ }
+ },
+ {
+ "name":"DELETE",
+ "messageParameters":{
+ "target":{
+ "acceptableValues":"",
+ "optional":"true",
+ "type":"string",
+ "defaultValue":""
+ }
+ }
+ }
+ ],
+ "entity":{
+ "description":"",
+ "enabled":"true",
+ "jndiName":"jdbc\/MySports",
+ "objectType":"user",
+ "poolName":"mysports"
+ },
+ "childResources":{
+ "property":"http:\/\/localhost:4848\/management\/domain\/resources\/jdbc-resource\/jdb c%2FMySports\/property"
+ }
+ }
+}
\ No newline at end of file
diff --git a/mysports/admin.services/src/test/resource/eclipselink/example/mysports/admin/services/test/services/glassfish/list-jdbc-connection-pools.json b/mysports/admin.services/src/test/resource/eclipselink/example/mysports/admin/services/test/services/glassfish/list-jdbc-connection-pools.json
new file mode 100644
index 0000000..3836efc
--- /dev/null
+++ b/mysports/admin.services/src/test/resource/eclipselink/example/mysports/admin/services/test/services/glassfish/list-jdbc-connection-pools.json
@@ -0,0 +1,36 @@
+{
+ "message": "",
+ "command": "list-jdbc-connection-pools AdminCommand",
+ "exit_code": "SUCCESS",
+ "extraProperties": {
+ "methods": [
+ {
+ "name": "GET"
+ },
+ {
+ "messageParameters": {
+ "targetName": {
+ "acceptableValues": "",
+ "optional": "true",
+ "type": "string",
+ "defaultValue": "server"
+ }
+ }
+ }
+ ]
+ },
+ "children": [
+ {
+ "message": "__TimerPool",
+ "properties": {}
+ },
+ {
+ "message": "DerbyPool",
+ "properties": {}
+ },
+ {
+ "message": "mysports",
+ "properties": {}
+ }
+ ]
+}
\ No newline at end of file
diff --git a/mysports/admin.services/src/test/resource/eclipselink/example/mysports/admin/services/test/services/glassfish/list-jdbc-resources.json b/mysports/admin.services/src/test/resource/eclipselink/example/mysports/admin/services/test/services/glassfish/list-jdbc-resources.json
new file mode 100644
index 0000000..49e87bd
--- /dev/null
+++ b/mysports/admin.services/src/test/resource/eclipselink/example/mysports/admin/services/test/services/glassfish/list-jdbc-resources.json
@@ -0,0 +1,36 @@
+{
+ "message": "",
+ "command": "list-jdbc-resources AdminCommand",
+ "exit_code": "SUCCESS",
+ "extraProperties": {
+ "methods": [
+ {
+ "name": "GET"
+ },
+ {
+ "messageParameters": {
+ "targetName": {
+ "acceptableValues": "",
+ "optional": "true",
+ "type": "string",
+ "defaultValue": "server"
+ }
+ }
+ }
+ ]
+ },
+ "children": [
+ {
+ "message": "jdbc/__TimerPool",
+ "properties": {}
+ },
+ {
+ "message": "jdbc/__default",
+ "properties": {}
+ },
+ {
+ "message": "jdbc/MySports",
+ "properties": {}
+ }
+ ]
+}
\ No newline at end of file
diff --git a/mysports/admin.services/src/test/resource/eclipselink/example/mysports/admin/services/test/style/black.css b/mysports/admin.services/src/test/resource/eclipselink/example/mysports/admin/services/test/style/black.css
new file mode 100644
index 0000000..d646aa3
--- /dev/null
+++ b/mysports/admin.services/src/test/resource/eclipselink/example/mysports/admin/services/test/style/black.css
@@ -0,0 +1,209 @@
+#*******************************************************************************
+# * Copyright (c) 2010 Oracle. All rights reserved.
+# * This program and the accompanying materials are made available under the
+# * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+# * which accompanies this distribution.
+# * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+# * and the Eclipse Distribution License is available at
+# * http://www.eclipse.org/org/documents/edl-v10.php.
+# *
+# * Contributors:
+# * dclarke - MySports Example for EclipseLink 2.3
+# ******************************************************************************/
+BODY, P, LI, UL, OL {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 50%;
+ color:#000000;
+ list-style-position: outside;
+}
+
+A:link {
+ font-family: Arial, Helvetica, sans-serif;
+ color:#663300;
+}
+
+A:active {
+ font-family: Arial, Helvetica, sans-serif;
+ color:#ff6600;
+
+}
+
+A:visited {
+ font-family: Arial, Helvetica, sans-serif;
+ color:#996633;
+
+}
+
+A.navigation:link
+{
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:65%;
+ color:#996633;
+}
+
+A.navigation:active
+{
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:65%;
+ color:#996633;
+}
+
+A.navigation:visited
+{
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:65%;
+ color:#996633;
+}
+
+.clear { /* generic container (i.e. div) for floating buttons */
+ overflow: hidden;
+ width: 100%;
+}
+
+c.button {
+ background: transparent url('../images/bg_button_a.gif') no-repeat scroll top right;
+ color: #444;
+ display: block;
+ float: left;
+ font: normal 12px arial, sans-serif;
+ height: 24px;
+ margin-right: 6px;
+ padding-right: 18px; /* sliding doors padding */
+ text-decoration: none;
+}
+
+a.button span {
+ background: transparent url('../images/bg_button_span.gif') no-repeat;
+ display: block;
+ line-height: 14px;
+ padding: 5px 0 5px 18px;
+}
+
+a.button:active {
+ background-position: bottom right;
+ color: #000;
+ outline: none; /* hide dotted outline in Firefox */
+}
+
+a.button:active span {
+ background-position: bottom left;
+ padding: 6px 0 4px 18px; /* push text down 1px */
+}
+p.listpara
+{text-indent: 15%}
+
+H1 {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:200%;
+ color: red;
+ width : 100%;
+ border-width : 0px 0px 2px 0px;
+ margin-left: 20px;
+}
+
+H2 {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:130%;
+ font-style: italic;
+ color: white;
+ width : 100%;
+ margin-left: 20px;
+}
+
+H3 {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:110%;
+ color: red;
+ border : solid #CCCC99;
+ width : 100%;
+ border-width : 0px 0px 2px 0px;
+}
+
+H4 {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:92%;
+ color:#000000;
+ font-weight: bold;
+ width : 100%;
+}
+
+.code_no_color {
+ color : #000000;
+ font-family : "Courier New", "Courier", "monospace";
+}
+
+code {
+ color : #336699;
+ font-family : "Courier New", "Courier", "monospace";
+}
+
+P.indent {
+ text-indent: 9%;
+}
+
+table.borders {
+ border : 1% solid #BDB76B;
+}
+
+TR {
+ text-align : left;
+ vertical-align : top;
+}
+
+TH {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 11pt;
+ color:#000000;
+ font-weight: bold;
+}
+
+TD {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 11pt;
+ color:#000000;
+}
+
+.smalltext {
+ font-size:80%;
+}
+
+p.note {
+ display: block;
+ font-family: Arial, Helvetica, Geneva, sans-serif;
+ font-size: 95%;
+}
+
+p.warning {
+ display: block;
+ font-family: Arial, Helvetica, Geneva, sans-serif;
+ font-size: 95%;
+}
+
+pre {
+ font-family: "Courier New", Courier, mono;
+ font-size: 92%;
+ text-indent : 15%;
+}
+
+table.pretty {
+ background: whitesmoke;
+ border-collapse: collapse;
+}
+table.pretty th, table.pretty td {
+ border: 1px silver solid;
+ padding: 0.2em;
+ font-size: 10pt;
+}
+table.pretty th {
+ background: black;
+ text-align: left;
+ color: white;
+}
+table.pretty caption {
+ margin-left: inherit;
+ margin-right: inherit;
+}
+
+table.accent {
+ background: black;
+}
diff --git a/mysports/admin.services/src/test/resource/eclipselink/example/mysports/admin/services/test/style/blue.css b/mysports/admin.services/src/test/resource/eclipselink/example/mysports/admin/services/test/style/blue.css
new file mode 100644
index 0000000..7f228a4
--- /dev/null
+++ b/mysports/admin.services/src/test/resource/eclipselink/example/mysports/admin/services/test/style/blue.css
@@ -0,0 +1,212 @@
+#*******************************************************************************
+# * Copyright (c) 2010 Oracle. All rights reserved.
+# * This program and the accompanying materials are made available under the
+# * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+# * which accompanies this distribution.
+# * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+# * and the Eclipse Distribution License is available at
+# * http://www.eclipse.org/org/documents/edl-v10.php.
+# *
+# * Contributors:
+# * dclarke - MySports Example for EclipseLink 2.3
+# ******************************************************************************/
+BODY, P, LI, UL, OL {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 50%;
+ color:#000000;
+ list-style-position: outside;
+}
+
+A:link {
+ font-family: Arial, Helvetica, sans-serif;
+ color:#663300;
+
+}
+
+A:active {
+ font-family: Arial, Helvetica, sans-serif;
+ color:#ff6600;
+
+}
+
+A:visited {
+ font-family: Arial, Helvetica, sans-serif;
+ color:#996633;
+
+}
+
+A.navigation:link
+{
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:65%;
+ color:#996633;
+}
+
+A.navigation:active
+{
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:65%;
+ color:#996633;
+}
+
+A.navigation:visited
+{
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:65%;
+ color:#996633;
+}
+
+.clear { /* generic container (i.e. div) for floating buttons */
+ overflow: hidden;
+ width: 100%;
+}
+
+c.button {
+ background: transparent url('../images/bg_button_a.gif') no-repeat scroll top right;
+ color: #444;
+ display: block;
+ float: left;
+ font: normal 12px arial, sans-serif;
+ height: 24px;
+ margin-right: 6px;
+ padding-right: 18px; /* sliding doors padding */
+ text-decoration: none;
+}
+
+a.button span {
+ background: transparent url('../images/bg_button_span.gif') no-repeat;
+ display: block;
+ line-height: 14px;
+ padding: 5px 0 5px 18px;
+}
+
+a.button:active {
+ background-position: bottom right;
+ color: #000;
+ outline: none; /* hide dotted outline in Firefox */
+}
+
+a.button:active span {
+ background-position: bottom left;
+ padding: 6px 0 4px 18px; /* push text down 1px */
+}
+p.listpara
+{text-indent: 15%}
+
+H1 {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:170%;
+ color:#336699;
+ border : solid ##3333CC;
+ width : 100%;
+ border-width : 0px 0px 2px 0px;
+ margin-left: 20px;
+}
+
+H2 {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:130%;
+ font-style: italic;
+ color: white;
+ width : 100%;
+ margin-left: 20px;
+}
+
+H3 {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:110%;
+ color:#336699;
+ border : solid #CCCC99;
+ width : 100%;
+ border-width : 0px 0px 2px 0px;
+}
+
+H4 {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:92%;
+ color:#000000;
+ font-weight: bold;
+ width : 100%;
+}
+
+.code_no_color {
+ color : #000000;
+ font-family : "Courier New", "Courier", "monospace";
+}
+
+code {
+ color : #336699;
+ font-family : "Courier New", "Courier", "monospace";
+}
+
+P.indent {
+ text-indent: 9%;
+}
+
+table.borders {
+ border : 1% solid #BDB76B;
+}
+
+TR {
+ text-align : left;
+ vertical-align : top;
+}
+
+TH {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 11pt;
+ color:#000000;
+ font-weight: bold;
+}
+
+TD {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 11pt;
+ color:#000000;
+}
+
+.smalltext {
+ font-size:80%;
+}
+
+p.note {
+ display: block;
+ font-family: Arial, Helvetica, Geneva, sans-serif;
+ font-size: 95%;
+}
+
+p.warning {
+ display: block;
+ font-family: Arial, Helvetica, Geneva, sans-serif;
+ font-size: 95%;
+}
+
+pre {
+ font-family: "Courier New", Courier, mono;
+ font-size: 92%;
+ text-indent : 15%;
+}
+
+table.pretty {
+ background: whitesmoke;
+ border-collapse: collapse;
+}
+table.pretty th, table.pretty td {
+ border: 1px silver solid;
+ padding: 0.2em;
+ font-size: 10pt;
+}
+table.pretty th {
+ background: blue;
+ text-align: left;
+ color: white;
+}
+table.pretty caption {
+ margin-left: inherit;
+ margin-right: inherit;
+}
+
+table.accent {
+ background: blue;
+}
+
diff --git a/mysports/admin.services/src/test/resource/eclipselink/example/mysports/admin/services/test/style/default.css b/mysports/admin.services/src/test/resource/eclipselink/example/mysports/admin/services/test/style/default.css
new file mode 100644
index 0000000..8136a7a
--- /dev/null
+++ b/mysports/admin.services/src/test/resource/eclipselink/example/mysports/admin/services/test/style/default.css
@@ -0,0 +1,212 @@
+#*******************************************************************************
+# * Copyright (c) 2010 Oracle. All rights reserved.
+# * This program and the accompanying materials are made available under the
+# * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+# * which accompanies this distribution.
+# * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+# * and the Eclipse Distribution License is available at
+# * http://www.eclipse.org/org/documents/edl-v10.php.
+# *
+# * Contributors:
+# * dclarke - MySports Example for EclipseLink 2.3
+# ******************************************************************************/
+BODY, P, LI, UL, OL {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 50%;
+ color:#000000;
+ list-style-position: outside;
+}
+
+A:link {
+ font-family: Arial, Helvetica, sans-serif;
+ color:#663300;
+
+}
+
+A:active {
+ font-family: Arial, Helvetica, sans-serif;
+ color:#ff6600;
+
+}
+
+A:visited {
+ font-family: Arial, Helvetica, sans-serif;
+ color:#996633;
+
+}
+
+A.navigation:link
+{
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:65%;
+ color:#996633;
+}
+
+A.navigation:active
+{
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:65%;
+ color:#996633;
+}
+
+A.navigation:visited
+{
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:65%;
+ color:#996633;
+}
+
+.clear { /* generic container (i.e. div) for floating buttons */
+ overflow: hidden;
+ width: 100%;
+}
+
+c.button {
+ background: transparent url('../images/bg_button_a.gif') no-repeat scroll top right;
+ color: #444;
+ display: block;
+ float: left;
+ font: normal 12px arial, sans-serif;
+ height: 24px;
+ margin-right: 6px;
+ padding-right: 18px; /* sliding doors padding */
+ text-decoration: none;
+}
+
+a.button span {
+ background: transparent url('../images/bg_button_span.gif') no-repeat;
+ display: block;
+ line-height: 14px;
+ padding: 5px 0 5px 18px;
+}
+
+a.button:active {
+ background-position: bottom right;
+ color: #000;
+ outline: none; /* hide dotted outline in Firefox */
+}
+
+a.button:active span {
+ background-position: bottom left;
+ padding: 6px 0 4px 18px; /* push text down 1px */
+}
+p.listpara
+{text-indent: 15%}
+
+H1 {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:170%;
+ color:#336699;
+ border : solid ##3333CC;
+ width : 100%;
+ border-width : 0px 0px 2px 0px;
+ margin-left: 20px;
+}
+
+H2 {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:130%;
+ font-style: italic;
+ color: white;
+ width : 100%;
+ margin-left: 20px;
+}
+
+H3 {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:110%;
+ color:#336699;
+ border : solid #CCCC99;
+ width : 100%;
+ border-width : 0px 0px 2px 0px;
+}
+
+H4 {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:92%;
+ color:#000000;
+ font-weight: bold;
+ width : 100%;
+}
+
+.code_no_color {
+ color : #000000;
+ font-family : "Courier New", "Courier", "monospace";
+}
+
+code {
+ color : #336699;
+ font-family : "Courier New", "Courier", "monospace";
+}
+
+P.indent {
+ text-indent: 9%;
+}
+
+table.borders {
+ border : 1% solid #BDB76B;
+}
+
+TR {
+ text-align : left;
+ vertical-align : top;
+}
+
+TH {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 11pt;
+ color:#000000;
+ font-weight: bold;
+}
+
+TD {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 11pt;
+ color:#000000;
+}
+
+.smalltext {
+ font-size:80%;
+}
+
+p.note {
+ display: block;
+ font-family: Arial, Helvetica, Geneva, sans-serif;
+ font-size: 95%;
+}
+
+p.warning {
+ display: block;
+ font-family: Arial, Helvetica, Geneva, sans-serif;
+ font-size: 95%;
+}
+
+pre {
+ font-family: "Courier New", Courier, mono;
+ font-size: 92%;
+ text-indent : 15%;
+}
+
+table.pretty {
+ background: whitesmoke;
+ border-collapse: collapse;
+}
+table.pretty th, table.pretty td {
+ border: 1px silver solid;
+ padding: 0.2em;
+ font-size: 10pt;
+}
+table.pretty th {
+ background: green;
+ text-align: left;
+ color: white;
+}
+table.pretty caption {
+ margin-left: inherit;
+ margin-right: inherit;
+}
+
+table.accent {
+ background: green;
+}
+
diff --git a/mysports/admin.services/src/test/resource/eclipselink/example/mysports/admin/services/test/style/green.css b/mysports/admin.services/src/test/resource/eclipselink/example/mysports/admin/services/test/style/green.css
new file mode 100644
index 0000000..8136a7a
--- /dev/null
+++ b/mysports/admin.services/src/test/resource/eclipselink/example/mysports/admin/services/test/style/green.css
@@ -0,0 +1,212 @@
+#*******************************************************************************
+# * Copyright (c) 2010 Oracle. All rights reserved.
+# * This program and the accompanying materials are made available under the
+# * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+# * which accompanies this distribution.
+# * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+# * and the Eclipse Distribution License is available at
+# * http://www.eclipse.org/org/documents/edl-v10.php.
+# *
+# * Contributors:
+# * dclarke - MySports Example for EclipseLink 2.3
+# ******************************************************************************/
+BODY, P, LI, UL, OL {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 50%;
+ color:#000000;
+ list-style-position: outside;
+}
+
+A:link {
+ font-family: Arial, Helvetica, sans-serif;
+ color:#663300;
+
+}
+
+A:active {
+ font-family: Arial, Helvetica, sans-serif;
+ color:#ff6600;
+
+}
+
+A:visited {
+ font-family: Arial, Helvetica, sans-serif;
+ color:#996633;
+
+}
+
+A.navigation:link
+{
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:65%;
+ color:#996633;
+}
+
+A.navigation:active
+{
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:65%;
+ color:#996633;
+}
+
+A.navigation:visited
+{
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:65%;
+ color:#996633;
+}
+
+.clear { /* generic container (i.e. div) for floating buttons */
+ overflow: hidden;
+ width: 100%;
+}
+
+c.button {
+ background: transparent url('../images/bg_button_a.gif') no-repeat scroll top right;
+ color: #444;
+ display: block;
+ float: left;
+ font: normal 12px arial, sans-serif;
+ height: 24px;
+ margin-right: 6px;
+ padding-right: 18px; /* sliding doors padding */
+ text-decoration: none;
+}
+
+a.button span {
+ background: transparent url('../images/bg_button_span.gif') no-repeat;
+ display: block;
+ line-height: 14px;
+ padding: 5px 0 5px 18px;
+}
+
+a.button:active {
+ background-position: bottom right;
+ color: #000;
+ outline: none; /* hide dotted outline in Firefox */
+}
+
+a.button:active span {
+ background-position: bottom left;
+ padding: 6px 0 4px 18px; /* push text down 1px */
+}
+p.listpara
+{text-indent: 15%}
+
+H1 {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:170%;
+ color:#336699;
+ border : solid ##3333CC;
+ width : 100%;
+ border-width : 0px 0px 2px 0px;
+ margin-left: 20px;
+}
+
+H2 {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:130%;
+ font-style: italic;
+ color: white;
+ width : 100%;
+ margin-left: 20px;
+}
+
+H3 {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:110%;
+ color:#336699;
+ border : solid #CCCC99;
+ width : 100%;
+ border-width : 0px 0px 2px 0px;
+}
+
+H4 {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:92%;
+ color:#000000;
+ font-weight: bold;
+ width : 100%;
+}
+
+.code_no_color {
+ color : #000000;
+ font-family : "Courier New", "Courier", "monospace";
+}
+
+code {
+ color : #336699;
+ font-family : "Courier New", "Courier", "monospace";
+}
+
+P.indent {
+ text-indent: 9%;
+}
+
+table.borders {
+ border : 1% solid #BDB76B;
+}
+
+TR {
+ text-align : left;
+ vertical-align : top;
+}
+
+TH {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 11pt;
+ color:#000000;
+ font-weight: bold;
+}
+
+TD {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 11pt;
+ color:#000000;
+}
+
+.smalltext {
+ font-size:80%;
+}
+
+p.note {
+ display: block;
+ font-family: Arial, Helvetica, Geneva, sans-serif;
+ font-size: 95%;
+}
+
+p.warning {
+ display: block;
+ font-family: Arial, Helvetica, Geneva, sans-serif;
+ font-size: 95%;
+}
+
+pre {
+ font-family: "Courier New", Courier, mono;
+ font-size: 92%;
+ text-indent : 15%;
+}
+
+table.pretty {
+ background: whitesmoke;
+ border-collapse: collapse;
+}
+table.pretty th, table.pretty td {
+ border: 1px silver solid;
+ padding: 0.2em;
+ font-size: 10pt;
+}
+table.pretty th {
+ background: green;
+ text-align: left;
+ color: white;
+}
+table.pretty caption {
+ margin-left: inherit;
+ margin-right: inherit;
+}
+
+table.accent {
+ background: green;
+}
+
diff --git a/mysports/admin.services/src/test/resource/eclipselink/example/mysports/admin/services/test/style/red.css b/mysports/admin.services/src/test/resource/eclipselink/example/mysports/admin/services/test/style/red.css
new file mode 100644
index 0000000..23f0864
--- /dev/null
+++ b/mysports/admin.services/src/test/resource/eclipselink/example/mysports/admin/services/test/style/red.css
@@ -0,0 +1,209 @@
+#*******************************************************************************
+# * Copyright (c) 2010 Oracle. All rights reserved.
+# * This program and the accompanying materials are made available under the
+# * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+# * which accompanies this distribution.
+# * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+# * and the Eclipse Distribution License is available at
+# * http://www.eclipse.org/org/documents/edl-v10.php.
+# *
+# * Contributors:
+# * dclarke - MySports Example for EclipseLink 2.3
+# ******************************************************************************/
+BODY, P, LI, UL, OL {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 50%;
+ color:#000000;
+ list-style-position: outside;
+}
+
+A:link {
+ font-family: Arial, Helvetica, sans-serif;
+ color:#663300;
+}
+
+A:active {
+ font-family: Arial, Helvetica, sans-serif;
+ color:#ff6600;
+
+}
+
+A:visited {
+ font-family: Arial, Helvetica, sans-serif;
+ color:#996633;
+
+}
+
+A.navigation:link
+{
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:65%;
+ color:#996633;
+}
+
+A.navigation:active
+{
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:65%;
+ color:#996633;
+}
+
+A.navigation:visited
+{
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:65%;
+ color:#996633;
+}
+
+.clear { /* generic container (i.e. div) for floating buttons */
+ overflow: hidden;
+ width: 100%;
+}
+
+c.button {
+ background: transparent url('../images/bg_button_a.gif') no-repeat scroll top right;
+ color: #444;
+ display: block;
+ float: left;
+ font: normal 12px arial, sans-serif;
+ height: 24px;
+ margin-right: 6px;
+ padding-right: 18px; /* sliding doors padding */
+ text-decoration: none;
+}
+
+a.button span {
+ background: transparent url('../images/bg_button_span.gif') no-repeat;
+ display: block;
+ line-height: 14px;
+ padding: 5px 0 5px 18px;
+}
+
+a.button:active {
+ background-position: bottom right;
+ color: #000;
+ outline: none; /* hide dotted outline in Firefox */
+}
+
+a.button:active span {
+ background-position: bottom left;
+ padding: 6px 0 4px 18px; /* push text down 1px */
+}
+p.listpara
+{text-indent: 15%}
+
+H1 {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:200%;
+ color: red;
+ width : 100%;
+ border-width : 0px 0px 2px 0px;
+ margin-left: 20px;
+}
+
+H2 {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:130%;
+ font-style: italic;
+ color: white;
+ width : 100%;
+ margin-left: 20px;
+}
+
+H3 {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:110%;
+ color: red;
+ border : solid #CCCC99;
+ width : 100%;
+ border-width : 0px 0px 2px 0px;
+}
+
+H4 {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:92%;
+ color:#000000;
+ font-weight: bold;
+ width : 100%;
+}
+
+.code_no_color {
+ color : #000000;
+ font-family : "Courier New", "Courier", "monospace";
+}
+
+code {
+ color : #336699;
+ font-family : "Courier New", "Courier", "monospace";
+}
+
+P.indent {
+ text-indent: 9%;
+}
+
+table.borders {
+ border : 1% solid #BDB76B;
+}
+
+TR {
+ text-align : left;
+ vertical-align : top;
+}
+
+TH {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 11pt;
+ color:#000000;
+ font-weight: bold;
+}
+
+TD {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 11pt;
+ color:#000000;
+}
+
+.smalltext {
+ font-size:80%;
+}
+
+p.note {
+ display: block;
+ font-family: Arial, Helvetica, Geneva, sans-serif;
+ font-size: 95%;
+}
+
+p.warning {
+ display: block;
+ font-family: Arial, Helvetica, Geneva, sans-serif;
+ font-size: 95%;
+}
+
+pre {
+ font-family: "Courier New", Courier, mono;
+ font-size: 92%;
+ text-indent : 15%;
+}
+
+table.pretty {
+ background: whitesmoke;
+ border-collapse: collapse;
+}
+table.pretty th, table.pretty td {
+ border: 1px silver solid;
+ padding: 0.2em;
+ font-size: 10pt;
+}
+table.pretty th {
+ background: red;
+ text-align: left;
+ color: white;
+}
+table.pretty caption {
+ margin-left: inherit;
+ margin-right: inherit;
+}
+
+table.accent {
+ background: red;
+}
diff --git a/mysports/admin.web/.classpath b/mysports/admin.web/.classpath
new file mode 100644
index 0000000..6e7287b
--- /dev/null
+++ b/mysports/admin.web/.classpath
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" output="target/classes" path="src/main/java">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/java">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
+ <attributes>
+ <attribute name="owner.project.facets" value="java"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
diff --git a/mysports/admin.web/.project b/mysports/admin.web/.project
new file mode 100644
index 0000000..a8c095e
--- /dev/null
+++ b/mysports/admin.web/.project
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>mysports.admin.web</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.wst.common.project.facet.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.wst.validation.validationbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.m2e.core.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
+ <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.m2e.core.maven2Nature</nature>
+ <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+ <nature>org.eclipse.wst.jsdt.core.jsNature</nature>
+ </natures>
+</projectDescription>
diff --git a/mysports/admin.web/.settings/.jsdtscope b/mysports/admin.web/.settings/.jsdtscope
new file mode 100644
index 0000000..3a28de0
--- /dev/null
+++ b/mysports/admin.web/.settings/.jsdtscope
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="WebContent"/>
+ <classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject">
+ <attributes>
+ <attribute name="hide" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
+ <classpathentry kind="output" path=""/>
+</classpath>
diff --git a/mysports/admin.web/.settings/org.eclipse.jdt.core.prefs b/mysports/admin.web/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..69c31cd
--- /dev/null
+++ b/mysports/admin.web/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/mysports/admin.web/.settings/org.eclipse.m2e.core.prefs b/mysports/admin.web/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 0000000..2af59a6
--- /dev/null
+++ b/mysports/admin.web/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=mysql
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/mysports/admin.web/.settings/org.eclipse.wst.common.component b/mysports/admin.web/.settings/org.eclipse.wst.common.component
new file mode 100644
index 0000000..09499e2
--- /dev/null
+++ b/mysports/admin.web/.settings/org.eclipse.wst.common.component
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
+ <wb-module deploy-name="mysports.admin.web">
+ <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
+ <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
+ <wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
+ <wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
+ <dependent-module archiveName="admin.services-2.4.2-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/mysports.admin.services/mysports.admin.services">
+ <dependency-type>uses</dependency-type>
+ </dependent-module>
+ <property name="java-output-path" value="/mysports.admin.web/target/classes"/>
+ <property name="context-root" value="admin.web"/>
+ </wb-module>
+</project-modules>
diff --git a/mysports/admin.web/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml b/mysports/admin.web/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml
new file mode 100644
index 0000000..6d59853
--- /dev/null
+++ b/mysports/admin.web/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml
@@ -0,0 +1,12 @@
+<root>
+ <facet id="jst.jsf">
+ <node name="libprov">
+ <attribute name="provider-id" value="jsf-no-op-library-provider"/>
+ </node>
+ </facet>
+ <facet id="jst.jaxrs">
+ <node name="libprov">
+ <attribute name="provider-id" value="jaxrs-no-op-library-provider"/>
+ </node>
+ </facet>
+</root>
diff --git a/mysports/admin.web/.settings/org.eclipse.wst.common.project.facet.core.xml b/mysports/admin.web/.settings/org.eclipse.wst.common.project.facet.core.xml
new file mode 100644
index 0000000..92be70e
--- /dev/null
+++ b/mysports/admin.web/.settings/org.eclipse.wst.common.project.facet.core.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+ <fixed facet="wst.jsdt.web"/>
+ <installed facet="jst.web" version="3.0"/>
+ <installed facet="jst.jsf" version="2.1"/>
+ <installed facet="wst.jsdt.web" version="1.0"/>
+ <installed facet="jst.jaxrs" version="1.1"/>
+ <installed facet="java" version="1.6"/>
+</faceted-project>
diff --git a/mysports/admin.web/.settings/org.eclipse.wst.jsdt.ui.superType.container b/mysports/admin.web/.settings/org.eclipse.wst.jsdt.ui.superType.container
new file mode 100644
index 0000000..3bd5d0a
--- /dev/null
+++ b/mysports/admin.web/.settings/org.eclipse.wst.jsdt.ui.superType.container
@@ -0,0 +1 @@
+org.eclipse.wst.jsdt.launching.baseBrowserLibrary
\ No newline at end of file
diff --git a/mysports/admin.web/.settings/org.eclipse.wst.jsdt.ui.superType.name b/mysports/admin.web/.settings/org.eclipse.wst.jsdt.ui.superType.name
new file mode 100644
index 0000000..05bd71b
--- /dev/null
+++ b/mysports/admin.web/.settings/org.eclipse.wst.jsdt.ui.superType.name
@@ -0,0 +1 @@
+Window
\ No newline at end of file
diff --git a/mysports/admin.web/pom.xml b/mysports/admin.web/pom.xml
new file mode 100644
index 0000000..a4a2816
--- /dev/null
+++ b/mysports/admin.web/pom.xml
@@ -0,0 +1,79 @@
+<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/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>eclipselink.example.mysports</groupId>
+ <artifactId>bom</artifactId>
+ <version>2.4.2-SNAPSHOT</version>
+ <relativePath>..</relativePath>
+ </parent>
+
+ <artifactId>admin.web</artifactId>
+ <packaging>war</packaging>
+ <name>MySports Admin WebApp</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>admin.services</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse.persistence</groupId>
+ <artifactId>eclipselink</artifactId>
+ <version>${eclipselink.version}</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>commonj.sdo</artifactId>
+ <groupId>commonj.sdo</groupId>
+ </exclusion>
+ </exclusions>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>admin.services</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+
+
+ </dependencies>
+
+ <build>
+ <plugins>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.4</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+</project>
diff --git a/mysports/admin.web/src/main/java/eclipselink/example/mysports/admin/jaxrs/HostedLeaguesService.java b/mysports/admin.web/src/main/java/eclipselink/example/mysports/admin/jaxrs/HostedLeaguesService.java
new file mode 100644
index 0000000..7fb968a
--- /dev/null
+++ b/mysports/admin.web/src/main/java/eclipselink/example/mysports/admin/jaxrs/HostedLeaguesService.java
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.admin.jaxrs;
+
+import java.io.InputStream;
+import java.util.List;
+
+import javax.ejb.EJB;
+import javax.ejb.LocalBean;
+import javax.ejb.Stateless;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.UriInfo;
+
+import eclipselink.example.mysports.admin.model.HostedLeague;
+import eclipselink.example.mysports.admin.services.HostedLeagueRepository;
+
+/**
+ * Session bean exposing JAX-RS methods for defining and usage of league
+ * specific metadata.
+ *
+ * @author dclarke
+ * @since EclipseLink 2.3.0
+ */
+@Stateless
+@LocalBean
+@Path("league")
+public class HostedLeaguesService {
+
+ @EJB
+ private HostedLeagueRepository repository;
+
+ public HostedLeagueRepository getRepository() {
+ return repository;
+ }
+
+ public void setRepository(HostedLeagueRepository repository) {
+ this.repository = repository;
+ }
+
+ @GET
+ @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+ public List<HostedLeague> allLeagues(@Context UriInfo context) {
+ List<HostedLeague> allLeagues = getRepository().allSharedLeagues();
+
+ for (HostedLeague hl : allLeagues) {
+ hl.setUri(context.getAbsolutePath() + "/" + hl.getId());
+ }
+ return allLeagues;
+ }
+
+ @GET
+ @Path("{league}")
+ @Produces(MediaType.APPLICATION_XML)
+ public HostedLeague getLeague(@Context UriInfo context, @PathParam("league") String leagueId) {
+ System.err.println("HostedLeagueService::GET/"+leagueId);
+ HostedLeague league = getRepository().getLeague(leagueId);
+ if (league != null && context != null) {
+ league.setUri(context.getAbsolutePath() + "/" + league.getId());
+ }
+ return league;
+
+ }
+
+ @GET
+ @Path("{league}/orm")
+ @Produces(MediaType.APPLICATION_XML)
+ public String getORM(@PathParam("league") String leagueId) {
+ System.err.println("HostedLeagueService::orm-GET/"+leagueId);
+ return getRepository().getORM(leagueId);
+ }
+
+ @GET
+ @Path("{league}.css")
+ @Produces("text/css")
+ public String getCSS(@PathParam("league") String leagueId) {
+ System.err.println("HostedLeagueService::css-GET/"+leagueId);
+ return getRepository().getCSS(leagueId);
+ }
+
+ @GET
+ @Path("{league}.png")
+ @Produces("image/jpeg")
+ public InputStream getLogo(@PathParam("league") String leagueId) {
+ System.err.println("HostedLeagueService::logo-GET/"+leagueId);
+ return getRepository().getLogo(leagueId);
+ }
+
+}
\ No newline at end of file
diff --git a/mysports/admin.web/src/main/java/eclipselink/example/mysports/admin/jaxrs/MySportsContextResolver.java b/mysports/admin.web/src/main/java/eclipselink/example/mysports/admin/jaxrs/MySportsContextResolver.java
new file mode 100644
index 0000000..1caa471
--- /dev/null
+++ b/mysports/admin.web/src/main/java/eclipselink/example/mysports/admin/jaxrs/MySportsContextResolver.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.admin.jaxrs;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.ext.ContextResolver;
+import javax.ws.rs.ext.Provider;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+
+import org.eclipse.persistence.jaxb.JAXBContextFactory;
+import org.eclipse.persistence.jaxb.JAXBContextProperties;
+
+import eclipselink.example.mysports.admin.model.HostedLeague;
+
+/**
+ * {@link ContextResolver} to handle using EclipseLink MOXy as the JAXB provider
+ * to convert objects into XML when returned from the JAX-RS methods.
+ *
+ * @author dclarke
+ * @since EclipseLink 2.3.0
+ */
+@Provider
+@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
+public class MySportsContextResolver implements ContextResolver<JAXBContext> {
+
+ private JAXBContext jc;
+
+ public MySportsContextResolver() {
+ try {
+ jc = createContext();
+ } catch (JAXBException e) {
+ throw new RuntimeException("MySportsContextResolver<init> failed: " + e.getMessage(), e);
+ }
+ }
+
+ public JAXBContext getContext(Class<?> clazz) {
+ if (HostedLeague.class == clazz || HostedLeaguesService.class == clazz) {
+ return jc;
+ }
+ return null;
+ }
+
+ private static final String MAPPING_FILE = "META-INF/eclipselink-oxm.xml";
+
+ public static JAXBContext createContext() throws JAXBException {
+ Map<String, Object> props = new HashMap<String, Object>(1);
+ props.put(JAXBContextProperties.OXM_METADATA_SOURCE, MAPPING_FILE);
+ return JAXBContextFactory.createContext(new Class[] { HostedLeague.class }, props);
+ }
+
+}
\ No newline at end of file
diff --git a/mysports/admin.web/src/main/java/eclipselink/example/mysports/admin/jsf/CreateLeague.java b/mysports/admin.web/src/main/java/eclipselink/example/mysports/admin/jsf/CreateLeague.java
new file mode 100644
index 0000000..7ca5b96
--- /dev/null
+++ b/mysports/admin.web/src/main/java/eclipselink/example/mysports/admin/jsf/CreateLeague.java
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.4 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.admin.jsf;
+
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.ManagedProperty;
+import javax.faces.bean.RequestScoped;
+
+import eclipselink.example.mysports.admin.model.HostedLeague;
+
+/**
+ *
+ *
+ * @author dclarke
+ * @since EclipseLink 2.4
+ */
+@ManagedBean
+@RequestScoped
+public class CreateLeague {
+
+ private HostedLeague league = new HostedLeague("", "", "default");
+
+ @ManagedProperty("#{leagueRepository}")
+ private LeagueRepository repository;
+
+ @ManagedProperty("#{viewLeague}")
+ private ViewLeague viewLeague;
+
+ public LeagueRepository getRepository() {
+ return repository;
+ }
+
+ public void setRepository(LeagueRepository repository) {
+ this.repository = repository;
+ }
+
+ public HostedLeague getLeague() {
+ return league;
+ }
+
+ public String getId() {
+ return getLeague().getId();
+ }
+
+ public void setId(String id) {
+ getLeague().setId(id);
+ }
+
+ public String getName() {
+ return getLeague().getName();
+ }
+
+ public void setName(String name) {
+ getLeague().setName(name);
+ }
+
+ public ViewLeague getViewLeague() {
+ return viewLeague;
+ }
+
+ public void setViewLeague(ViewLeague viewLeague) {
+ this.viewLeague = viewLeague;
+ }
+
+ public String create() {
+ getRepository().getRepository().merge(getLeague());
+
+ return getViewLeague().view(getId());
+ }
+
+}
diff --git a/mysports/admin.web/src/main/java/eclipselink/example/mysports/admin/jsf/CurrentUser.java b/mysports/admin.web/src/main/java/eclipselink/example/mysports/admin/jsf/CurrentUser.java
new file mode 100644
index 0000000..590183f
--- /dev/null
+++ b/mysports/admin.web/src/main/java/eclipselink/example/mysports/admin/jsf/CurrentUser.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.4 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.admin.jsf;
+
+import javax.faces.bean.ManagedBean;
+
+
+@ManagedBean
+public class CurrentUser {
+
+ private String name = "Doug@" + System.currentTimeMillis();
+
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String doit() {
+ setName("Doug@" + System.currentTimeMillis());
+ return null;
+ }
+}
diff --git a/mysports/admin.web/src/main/java/eclipselink/example/mysports/admin/jsf/DatasourceRepositoryBean.java b/mysports/admin.web/src/main/java/eclipselink/example/mysports/admin/jsf/DatasourceRepositoryBean.java
new file mode 100644
index 0000000..b8cea6d
--- /dev/null
+++ b/mysports/admin.web/src/main/java/eclipselink/example/mysports/admin/jsf/DatasourceRepositoryBean.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.4 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.admin.jsf;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.RequestScoped;
+
+import eclipselink.example.mysports.admin.model.Datasource;
+import eclipselink.example.mysports.admin.services.glassfish.JDBCResource;
+import eclipselink.example.mysports.admin.services.glassfish.RESTOperations;
+
+@ManagedBean
+@RequestScoped
+public class DatasourceRepositoryBean {
+
+ private List<Datasource> datasources;
+
+ public List<Datasource> getDatasources() {
+ if (this.datasources == null) {
+ this.datasources = new ArrayList<Datasource>();
+ RESTOperations ops = new RESTOperations("localhost");
+ String[] resourceNames = JDBCResource.getJDBCResourceNames(ops);
+
+ for (String name : resourceNames) {
+ Datasource ds = new Datasource();
+ ds.setName(name);
+ this.datasources.add(ds);
+
+ }
+ }
+ return datasources;
+ }
+}
diff --git a/mysports/admin.web/src/main/java/eclipselink/example/mysports/admin/jsf/HostEnvironmentRepositoryBean.java b/mysports/admin.web/src/main/java/eclipselink/example/mysports/admin/jsf/HostEnvironmentRepositoryBean.java
new file mode 100644
index 0000000..e899880
--- /dev/null
+++ b/mysports/admin.web/src/main/java/eclipselink/example/mysports/admin/jsf/HostEnvironmentRepositoryBean.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.4 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.admin.jsf;
+
+import java.util.List;
+
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.RequestScoped;
+import javax.inject.Inject;
+
+import eclipselink.example.mysports.admin.model.HostEnvironment;
+import eclipselink.example.mysports.admin.services.HostEnvironmentRepository;
+
+@ManagedBean
+@RequestScoped
+public class HostEnvironmentRepositoryBean {
+
+ @Inject
+ private HostEnvironmentRepository repository;
+
+ public HostEnvironmentRepository getRepository() {
+ return repository;
+ }
+
+ public void setRepository(HostEnvironmentRepository repository) {
+ this.repository = repository;
+ }
+
+ public List<HostEnvironment> getEnvironments() {
+ return getRepository().getEnvironments();
+ }
+}
diff --git a/mysports/admin.web/src/main/java/eclipselink/example/mysports/admin/jsf/LeagueRepository.java b/mysports/admin.web/src/main/java/eclipselink/example/mysports/admin/jsf/LeagueRepository.java
new file mode 100644
index 0000000..299e65c
--- /dev/null
+++ b/mysports/admin.web/src/main/java/eclipselink/example/mysports/admin/jsf/LeagueRepository.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.4 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.admin.jsf;
+
+import java.util.List;
+
+import javax.ejb.EJB;
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.SessionScoped;
+
+import eclipselink.example.mysports.admin.model.HostedLeague;
+import eclipselink.example.mysports.admin.services.HostedLeagueRepository;
+
+@ManagedBean
+@SessionScoped
+public class LeagueRepository {
+
+ @EJB
+ private HostedLeagueRepository repository;
+
+ public HostedLeagueRepository getRepository() {
+ return repository;
+ }
+
+ public void setRepository(HostedLeagueRepository repository) {
+ this.repository = repository;
+ }
+
+ public List<HostedLeague> getLeagues() {
+ return getRepository().allLeagues();
+ }
+
+ public List<HostedLeague> getSharedLeagues() {
+ return getRepository().allSharedLeagues();
+ }
+
+ public HostedLeague getLeague(String id) {
+ return getRepository().getLeague(id);
+ }
+
+}
diff --git a/mysports/admin.web/src/main/java/eclipselink/example/mysports/admin/jsf/MySportsPhaseListener.java b/mysports/admin.web/src/main/java/eclipselink/example/mysports/admin/jsf/MySportsPhaseListener.java
new file mode 100644
index 0000000..9ef9495
--- /dev/null
+++ b/mysports/admin.web/src/main/java/eclipselink/example/mysports/admin/jsf/MySportsPhaseListener.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.admin.jsf;
+
+import java.io.IOException;
+
+import javax.faces.context.FacesContext;
+import javax.faces.event.PhaseEvent;
+import javax.faces.event.PhaseId;
+import javax.faces.event.PhaseListener;
+
+public class MySportsPhaseListener implements PhaseListener {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void afterPhase(PhaseEvent event) {
+ FacesContext facesContext = event.getFacesContext();
+ if(facesContext.getViewRoot()==null){
+ try{
+ facesContext.getExternalContext().redirect("/");
+ facesContext.responseComplete();
+ } catch (IOException e){
+ e.printStackTrace();
+ }
+ }
+ }
+
+ @Override
+ public void beforePhase(PhaseEvent arg0) {
+ }
+
+ @Override
+ public PhaseId getPhaseId() {
+ return null;
+ }
+
+}
diff --git a/mysports/admin.web/src/main/java/eclipselink/example/mysports/admin/jsf/NoCacheFilter.java b/mysports/admin.web/src/main/java/eclipselink/example/mysports/admin/jsf/NoCacheFilter.java
new file mode 100644
index 0000000..f35fb45
--- /dev/null
+++ b/mysports/admin.web/src/main/java/eclipselink/example/mysports/admin/jsf/NoCacheFilter.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.4 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.admin.jsf;
+
+import java.io.IOException;
+
+import javax.faces.application.ResourceHandler;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.annotation.WebFilter;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebFilter(servletNames = { "Faces Servlet" })
+public class NoCacheFilter implements Filter {
+
+ @Override
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
+ HttpServletRequest req = (HttpServletRequest) request;
+ HttpServletResponse res = (HttpServletResponse) response;
+ // Skip JSF resources (CSS/JS/Images/etc)
+ if (!req.getRequestURI().startsWith(req.getContextPath() + ResourceHandler.RESOURCE_IDENTIFIER)) {
+ // HTTP 1.1.
+ res.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
+ // HTTP 1.0.
+ res.setHeader("Pragma", "no-cache");
+ // Proxies.
+ res.setDateHeader("Expires", 0);
+ }
+
+ chain.doFilter(request, response);
+ }
+
+ @Override
+ public void destroy() {
+ }
+
+ @Override
+ public void init(FilterConfig arg0) throws ServletException {
+ }
+}
diff --git a/mysports/admin.web/src/main/java/eclipselink/example/mysports/admin/jsf/ViewLeague.java b/mysports/admin.web/src/main/java/eclipselink/example/mysports/admin/jsf/ViewLeague.java
new file mode 100644
index 0000000..6a59379
--- /dev/null
+++ b/mysports/admin.web/src/main/java/eclipselink/example/mysports/admin/jsf/ViewLeague.java
@@ -0,0 +1,191 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.4 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.admin.jsf;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.ManagedProperty;
+import javax.faces.bean.SessionScoped;
+import javax.faces.context.FacesContext;
+import javax.servlet.http.HttpServletRequest;
+
+import eclipselink.example.mysports.admin.model.DataIsolation;
+import eclipselink.example.mysports.admin.model.Extension;
+import eclipselink.example.mysports.admin.model.HostedLeague;
+
+/**
+ * TODO
+ *
+ * @author dclarke
+ * @since EclipseLink 2.4
+ */
+@ManagedBean
+@SessionScoped
+public class ViewLeague {
+
+ protected static final String PAGE = "league?faces-redirect=true";
+
+ private HostedLeague league;
+
+ private List<ExtensionDefinition> playerExtensions;
+
+ private String datasourceName;
+
+ @ManagedProperty("#{leagueRepository}")
+ private LeagueRepository repository;
+
+ public LeagueRepository getRepository() {
+ return repository;
+ }
+
+ public void setRepository(LeagueRepository repository) {
+ this.repository = repository;
+ }
+
+ public HostedLeague getLeague() {
+ return league;
+ }
+
+ public String view() {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ HttpServletRequest myRequest = (HttpServletRequest) facesContext.getExternalContext().getRequest();
+ String value = myRequest.getParameter("league-id");
+ return view(value);
+ }
+
+ public String view(String id) {
+ this.league = getRepository().getLeague(id);
+
+ if (getLeague() != null ) {
+ this.datasourceName = getLeague().getDatasourceName();
+ }
+
+ if (this.league == null) {
+ this.datasourceName = null;
+ return "index";
+ }
+
+ List<ExtensionDefinition> extensions = new ArrayList<ExtensionDefinition>(5);
+ for (int index = 1; index <= 5; index++) {
+ Extension ext = getLeague().getPlayerExtension("flex_" + index);
+ extensions.add(new ExtensionDefinition(ext, "flex_" + index));
+ }
+ this.playerExtensions = extensions;
+
+ return PAGE;
+ }
+
+ public String create() {
+ this.league = new HostedLeague();
+ this.datasourceName = null;
+ return PAGE;
+ }
+
+ public DataIsolation[] getDataIsolations() {
+ return DataIsolation.values();
+ }
+
+ public String[] getColourSchemes() {
+ // TODO: Load from database using query on Styles
+ return new String[] { "default", "red", "black", "blue", "green" };
+ }
+
+ public String getDatasourceName() {
+ return datasourceName;
+ }
+
+ public void setDatasourceName(String datasourceName) {
+ this.datasourceName = datasourceName;
+ getLeague().setDatasourceName(getDatasourceName());
+ }
+
+ public String apply() {
+ if (getPlayerExtensions() != null) {
+ for (ExtensionDefinition ed : getPlayerExtensions()) {
+ if (ed.isWriteable() && !ed.getName().isEmpty()) {
+ getLeague().addPlayerExtension(ed.getName(), "java.lang.String", ed.getColumn());
+ ed.setWriteable(false);
+ }
+ }
+ }
+
+ this.league = getRepository().getRepository().merge(getLeague());
+
+ return null;
+ }
+
+ public String cancel() {
+ this.league = null;
+ return "index";
+ }
+
+ public boolean isNew() {
+ return getLeague() != null && getLeague().getVersion() < 1;
+ }
+
+ public boolean isIdReadOnly() {
+ return getLeague() != null && getLeague().getVersion() > 1;
+ }
+
+ public List<ExtensionDefinition> getPlayerExtensions() {
+ return this.playerExtensions;
+ }
+
+ public class ExtensionDefinition {
+ private String column;
+ private String javaType;
+ private String name;
+ private boolean writeable = false;
+
+ public ExtensionDefinition(Extension ext, String column) {
+ super();
+ if (ext == null) {
+ this.writeable = true;
+ this.column = column;
+ this.javaType = "java.lang.String";
+ this.name = "";
+ } else {
+ this.writeable = false;
+ this.column = ext.getColumnName();
+ this.javaType = ext.getJavaType();
+ this.name = ext.getName();
+ }
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getColumn() {
+ return column;
+ }
+
+ public String getJavaType() {
+ return javaType;
+ }
+
+ public boolean isWriteable() {
+ return writeable;
+ }
+
+ public void setWriteable(boolean writeable) {
+ this.writeable = writeable;
+ }
+ }
+}
diff --git a/mysports/admin.web/src/main/resources/hthl.png b/mysports/admin.web/src/main/resources/hthl.png
new file mode 100644
index 0000000..2ce522d
--- /dev/null
+++ b/mysports/admin.web/src/main/resources/hthl.png
Binary files differ
diff --git a/mysports/admin.web/src/main/resources/kfl.png b/mysports/admin.web/src/main/resources/kfl.png
new file mode 100644
index 0000000..806e9b0
--- /dev/null
+++ b/mysports/admin.web/src/main/resources/kfl.png
Binary files differ
diff --git a/mysports/admin.web/src/main/resources/mha.png b/mysports/admin.web/src/main/resources/mha.png
new file mode 100644
index 0000000..8ddc28b
--- /dev/null
+++ b/mysports/admin.web/src/main/resources/mha.png
Binary files differ
diff --git a/mysports/admin.web/src/main/resources/osl.png b/mysports/admin.web/src/main/resources/osl.png
new file mode 100644
index 0000000..0315dfa
--- /dev/null
+++ b/mysports/admin.web/src/main/resources/osl.png
Binary files differ
diff --git a/mysports/admin.web/src/main/webapp/META-INF/MANIFEST.MF b/mysports/admin.web/src/main/webapp/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..254272e
--- /dev/null
+++ b/mysports/admin.web/src/main/webapp/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
diff --git a/mysports/admin.web/src/main/webapp/WEB-INF/faces-config.xml b/mysports/admin.web/src/main/webapp/WEB-INF/faces-config.xml
new file mode 100644
index 0000000..0639996
--- /dev/null
+++ b/mysports/admin.web/src/main/webapp/WEB-INF/faces-config.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_1.xsd"
+ version="2.1">
+
+</faces-config>
diff --git a/mysports/admin.web/src/main/webapp/WEB-INF/sun-web.xml b/mysports/admin.web/src/main/webapp/WEB-INF/sun-web.xml
new file mode 100644
index 0000000..ba2d6f2
--- /dev/null
+++ b/mysports/admin.web/src/main/webapp/WEB-INF/sun-web.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 Servlet 2.5//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_2_5-0.dtd">
+<sun-web-app error-url="/faces/error.xhtml">
+ <context-root>/MySportsAdmin</context-root>
+ <class-loader delegate="true" />
+ <jsp-config>
+ <property name="keepgenerated" value="true" />
+ </jsp-config>
+</sun-web-app>
diff --git a/mysports/admin.web/src/main/webapp/WEB-INF/template.xhtml b/mysports/admin.web/src/main/webapp/WEB-INF/template.xhtml
new file mode 100644
index 0000000..d5605a7
--- /dev/null
+++ b/mysports/admin.web/src/main/webapp/WEB-INF/template.xhtml
@@ -0,0 +1,41 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:fmt="http://java.sun.com/jstl/fmt">
+<head>
+<title><ui:insert name="title" /></title>
+
+<style type="text/css" media="all">
+@import "#{request.contextPath}/default.css";
+</style>
+</head>
+<body>
+ <f:view>
+ <div class="message-box">
+ <div class="header">
+ <div align="right">
+ <img src="#{request.contextPath}/images/mysports.png"></img>
+ </div>
+ <h1>
+ <ui:insert name="title" />
+ </h1>
+ </div>
+ <div class="body">
+ <table width="100%">
+ <tr>
+ <td height="400"><ui:insert name="body" /></td>
+ </tr>
+ </table>
+ <hr />
+ <div align="center">
+ <a href="http://www.eclipse.org/eclipselink"><h:graphicImage
+ url="#{request.contextPath}/images/eclipselink.png" alt="EclipseLink" /> </a>
+ </div>
+ </div>
+ </div>
+ </f:view>
+</body>
+</html>
diff --git a/mysports/admin.web/src/main/webapp/WEB-INF/web.xml b/mysports/admin.web/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..f97bbb4
--- /dev/null
+++ b/mysports/admin.web/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
+ <context-param>
+ <param-name>javax.faces.CONFIG_FILES</param-name>
+ <param-value>/WEB-INF/faces-config.xml</param-value>
+ </context-param>
+ <display-name>MySports Admin</display-name>
+ <welcome-file-list>
+ <welcome-file>faces/index.xhtml</welcome-file>
+ </welcome-file-list>
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>/faces/*</url-pattern>
+ </servlet-mapping>
+ <servlet>
+ <servlet-name>JAX-RS Servlet</servlet-name>
+ <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
+ <init-param>
+ <param-name>com.sun.jersey.config.property.packages</param-name>
+ <param-value>eclipselink.example.mysports.admin.jaxrs</param-value>
+ </init-param>
+ <load-on-startup>2</load-on-startup>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>JAX-RS Servlet</servlet-name>
+ <url-pattern>/rest/*</url-pattern>
+ </servlet-mapping>
+</web-app>
\ No newline at end of file
diff --git a/mysports/admin.web/src/main/webapp/WEB-INF/weblogic.xml b/mysports/admin.web/src/main/webapp/WEB-INF/weblogic.xml
new file mode 100644
index 0000000..799e995
--- /dev/null
+++ b/mysports/admin.web/src/main/webapp/WEB-INF/weblogic.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wls:weblogic-web-app xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.4/weblogic-web-app.xsd">
+ <wls:context-root>admin.web</wls:context-root>
+</wls:weblogic-web-app>
\ No newline at end of file
diff --git a/mysports/admin.web/src/main/webapp/about.xhtml b/mysports/admin.web/src/main/webapp/about.xhtml
new file mode 100644
index 0000000..751ae93
--- /dev/null
+++ b/mysports/admin.web/src/main/webapp/about.xhtml
@@ -0,0 +1,14 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core">
+
+<ui:composition template="/WEB-INF/template.xhtml">
+ <ui:define name="title">My Sports Admin: About</ui:define>
+ <ui:define name="body">
+ </ui:define>
+</ui:composition>
+</html>
diff --git a/mysports/admin.web/src/main/webapp/default.css b/mysports/admin.web/src/main/webapp/default.css
new file mode 100644
index 0000000..7956bf6
--- /dev/null
+++ b/mysports/admin.web/src/main/webapp/default.css
@@ -0,0 +1,93 @@
+body {
+ background-color: #D8DCE0;
+ font-family: Tahoma;
+ font-size: 14px;
+}
+
+div.message-box>div.header>h1 {
+ font-family: Tahoma;
+ color: #fff;
+ font-size: 18px;
+}
+
+h1 {
+ color: #3C5F87;
+ font-family: Tahoma;
+ font-size: 18px;
+}
+
+div.message-box {
+ padding: 0;
+ margin: 40px;
+ width: 90%;
+}
+
+div.message-box>div.header {
+ background-color: #3C5F87;
+ -moz-border-radius: 5px 5px 0 0;
+ -webkit-border-radius: 5px 5px 0 0;
+ padding: 10px 20px;
+ position: relative;
+}
+
+div.message-box>div.header>a {
+ position: absolute;
+ right: 20px;
+ background: url(images/mysports.png) no-repeat;
+ display: block;
+}
+
+div.message-box>div.body {
+ padding: 10px 20px;
+ background-color: #fff;
+ -moz-border-radius: 0 0 5px 5px;
+ -webkit-border-radius: 0 0 5px 5px;
+}
+
+table.borders {
+ border: 1% solid #BDB76B;
+}
+
+TR {
+ text-align: left;
+ vertical-align: top;
+}
+
+TH {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 11pt;
+ color: #000000;
+ font-weight: bold;
+}
+
+TD {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 11pt;
+ color: #000000;
+}
+
+table.pretty {
+ background: whitesmoke;
+ border-collapse: collapse;
+}
+
+table.pretty th,table.pretty td {
+ border: 1px silver solid;
+ padding: 0.2em;
+ font-size: 10pt;
+}
+
+table.pretty th {
+ background: #3C5F87;
+ text-align: left;
+ color: white;
+}
+
+table.pretty caption {
+ margin-left: inherit;
+ margin-right: inherit;
+}
+
+table.accent {
+ background: brown;
+}
\ No newline at end of file
diff --git a/mysports/admin.web/src/main/webapp/images/bg_button_a.gif b/mysports/admin.web/src/main/webapp/images/bg_button_a.gif
new file mode 100644
index 0000000..c8e740d
--- /dev/null
+++ b/mysports/admin.web/src/main/webapp/images/bg_button_a.gif
Binary files differ
diff --git a/mysports/admin.web/src/main/webapp/images/bg_button_span.gif b/mysports/admin.web/src/main/webapp/images/bg_button_span.gif
new file mode 100644
index 0000000..7da2e19
--- /dev/null
+++ b/mysports/admin.web/src/main/webapp/images/bg_button_span.gif
Binary files differ
diff --git a/mysports/admin.web/src/main/webapp/images/eclipselink.png b/mysports/admin.web/src/main/webapp/images/eclipselink.png
new file mode 100644
index 0000000..55b2a2f
--- /dev/null
+++ b/mysports/admin.web/src/main/webapp/images/eclipselink.png
Binary files differ
diff --git a/mysports/admin.web/src/main/webapp/images/mysports.png b/mysports/admin.web/src/main/webapp/images/mysports.png
new file mode 100644
index 0000000..5e9adff
--- /dev/null
+++ b/mysports/admin.web/src/main/webapp/images/mysports.png
Binary files differ
diff --git a/mysports/admin.web/src/main/webapp/index.xhtml b/mysports/admin.web/src/main/webapp/index.xhtml
new file mode 100644
index 0000000..e186635
--- /dev/null
+++ b/mysports/admin.web/src/main/webapp/index.xhtml
@@ -0,0 +1,63 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core">
+
+<ui:composition template="/WEB-INF/template.xhtml">
+ <ui:define name="title">My Sports Admin</ui:define>
+ <ui:define name="body">
+ <div align="center">
+ <h:form>
+
+ <table width="100%" cellpadding="25">
+ <tr>
+
+ <td width="50%" align="left">
+ <h2>Leagues</h2> <h:dataTable var="league"
+ value="#{leagueRepository.sharedLeagues}" border="1" width="100%"
+ class="pretty">
+ <f:facet name="header">
+ Shared Deployments (SaaS)
+ </f:facet>
+ <h:column>
+ <f:facet name="header">League</f:facet>
+ <h:commandLink value="#{league.id}" action="#{viewLeague.view}">
+ <f:param name="league-id" value="#{league.id}" />
+ </h:commandLink>
+ </h:column>
+ <h:column>
+ <f:facet name="header">Name</f:facet>
+ <h:outputText value="#{league.name}" />
+ </h:column>
+ <h:column>
+ <f:facet name="header">Data Isolation</f:facet>
+ <h:outputText value="#{league.dataIsolation}" />
+ </h:column>
+ <f:facet name="footer">
+ <div align="right">
+ <h:commandButton action="#{viewLeague.create}" value="Create"/>
+ </div>
+ </f:facet>
+ </h:dataTable>
+ <p />
+ <h3>REST Operations</h3>
+ <ul>
+ <li><h:outputLink
+ onclick="window.open('/MySportsAdmin/rest/league', 'popupWindowName', 'dependent=yes, menubar=no, toolbar=no'); return false;"
+ value="#">
+ <h:outputText value="Shared Leagues" />
+ </h:outputLink></li>
+ </ul>
+ </td>
+ </tr>
+ </table>
+
+
+ </h:form>
+ </div>
+ </ui:define>
+</ui:composition>
+</html>
diff --git a/mysports/admin.web/src/main/webapp/league.xhtml b/mysports/admin.web/src/main/webapp/league.xhtml
new file mode 100644
index 0000000..9200b79
--- /dev/null
+++ b/mysports/admin.web/src/main/webapp/league.xhtml
@@ -0,0 +1,117 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core">
+
+
+<ui:composition template="/WEB-INF/template.xhtml">
+ <ui:define name="title">My Sports Admin: Hosted League</ui:define>
+ <ui:define name="body">
+ <h:form>
+ <h:commandLink value="Home" action="index?faces-redirect=true" />
+ <p />
+ <table width="100%">
+ <tr>
+ <td width="50%" align="center"><h:panelGrid width="500"
+ columns="2" border="1" styleClass="pretty">
+ <f:facet name="header">
+ League Info
+ </f:facet>
+ <h:outputLabel value="League Id:" />
+ <h:panelGroup>
+ <h:inputText value="#{viewLeague.league.id}"
+ rendered="#{!viewLeague.idReadOnly}" />
+ <h:outputText value="#{viewLeague.league.id}"
+ rendered="#{viewLeague.idReadOnly}" />
+ </h:panelGroup>
+ <h:outputLabel value="Name:" />
+ <h:inputText value="#{viewLeague.league.name}" size="50" />
+ <h:outputLabel value="Logo:" />
+ <h:panelGroup>
+ <div align="center">
+ <h:graphicImage url="#{viewLeague.league.logoUrl}"></h:graphicImage>
+ </div>
+ URL: <h:inputText value="#{viewLeague.league.logoUrl}" />
+ <h:commandButton value="Update" />
+ </h:panelGroup>
+ <h:outputLabel value="Colour Scheme:" />
+ <h:selectOneMenu value="#{viewLeague.league.colourScheme}">
+ <f:selectItems value="#{viewLeague.colourSchemes}" />
+ </h:selectOneMenu>
+ <h:outputLabel value="Shared Deployment" />
+ <h:selectBooleanCheckbox value="#{viewLeague.league.shared}" />
+
+
+ <h:outputLabel value="Data Isolation:" />
+ <h:selectOneRadio layout="pageDirection"
+ value="#{viewLeague.league.dataIsolation}">
+ <f:selectItems value="#{viewLeague.dataIsolations}" var="di"
+ itemLabel="#{di}" itemValue="#{di}" />
+ </h:selectOneRadio>
+ <h:outputLabel value="Data Source:" />
+ <h:selectOneMenu value="#{viewLeague.datasourceName}">
+ <f:selectItems value="#{datasourceRepository.datasources}"
+ var="ds" itemLabel="#{ds.name}" itemValue="#{ds.name}" />
+ </h:selectOneMenu>
+ </h:panelGrid>
+
+
+
+ <p /> <h:dataTable width="500" styleClass="pretty"
+ value="#{viewLeague.playerExtensions}" var="ext">
+ <f:facet name="header">
+ Player Extensions
+ </f:facet>
+ <h:column>
+ <f:facet name="header">Column</f:facet>
+ <h:outputLabel value="#{ext.column}" />
+ </h:column>
+ <h:column>
+ <f:facet name="header">Type</f:facet>
+ <h:outputLabel value="#{ext.javaType}" />
+ </h:column>
+ <h:column>
+ <f:facet name="header">Name</f:facet>
+ <h:inputText value="#{ext.name}" rendered="#{ext.writeable}" />
+ <h:outputLabel value="#{ext.name}" rendered="#{!ext.writeable}" />
+ </h:column>
+ </h:dataTable>
+ <p /></td>
+
+ <td width="50%" valign="top"><h:commandButton value="Apply"
+ action="#{viewLeague.apply}" /> <h:commandButton value="Cancel"
+ action="#{viewLeague.cancel}" /> <h:commandButton value="Delete"
+ action="#{viewLeague.delete}" />
+
+ <h2>
+ <h:outputLabel value="REST Operations" />
+ </h2>
+ <ul>
+ <li><h:outputLink
+ onclick="window.open('/MySportsAdmin/rest/league/#{viewLeague.league.id}.css', 'popupWindowName', 'dependent=yes, menubar=no, toolbar=no'); return false;"
+ value="#">
+ <h:outputText value="CSS" />
+ </h:outputLink></li>
+ <li><h:outputLink
+ onclick="window.open('/MySportsAdmin/rest/league/#{viewLeague.league.id}/orm', 'popupWindowName', 'dependent=yes, menubar=no, toolbar=no'); return false;"
+ value="#">
+ <h:outputText
+ value="Object-Relational
+ Overrides and Extensions" />
+ </h:outputLink></li>
+ <li><h:outputLink
+ onclick="window.open('/MySportsAdmin#{viewLeague.league.logoUrl}', 'popupWindowName', 'dependent=yes, menubar=no, toolbar=no'); return false;"
+ value="#">
+ <h:outputText value="Logo: #{viewLeague.league.logoUrl}" />
+ </h:outputLink></li>
+ </ul></td>
+ </tr>
+ </table>
+
+ </h:form>
+ </ui:define>
+</ui:composition>
+</html>
diff --git a/mysports/admin.web/src/main/webapp/logos/hthl.png b/mysports/admin.web/src/main/webapp/logos/hthl.png
new file mode 100644
index 0000000..2ce522d
--- /dev/null
+++ b/mysports/admin.web/src/main/webapp/logos/hthl.png
Binary files differ
diff --git a/mysports/admin.web/src/main/webapp/logos/kfl.png b/mysports/admin.web/src/main/webapp/logos/kfl.png
new file mode 100644
index 0000000..806e9b0
--- /dev/null
+++ b/mysports/admin.web/src/main/webapp/logos/kfl.png
Binary files differ
diff --git a/mysports/admin.web/src/main/webapp/logos/osl.png b/mysports/admin.web/src/main/webapp/logos/osl.png
new file mode 100644
index 0000000..0315dfa
--- /dev/null
+++ b/mysports/admin.web/src/main/webapp/logos/osl.png
Binary files differ
diff --git a/mysports/admin.web/src/main/webapp/xsds/leagues.xsd b/mysports/admin.web/src/main/webapp/xsds/leagues.xsd
new file mode 100644
index 0000000..8f3c566
--- /dev/null
+++ b/mysports/admin.web/src/main/webapp/xsds/leagues.xsd
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+ <xs:element name="leagues">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="league" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:element name="league">
+ <xs:complexType>
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute name="id" type="xs:string"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+
+ </xs:element>
+
+</xs:schema>
\ No newline at end of file
diff --git a/mysports/admin.web/src/test/java/eclipselink/example/mysports/admin/test/CreateOrmXML.java b/mysports/admin.web/src/test/java/eclipselink/example/mysports/admin/test/CreateOrmXML.java
new file mode 100644
index 0000000..42a207d
--- /dev/null
+++ b/mysports/admin.web/src/test/java/eclipselink/example/mysports/admin/test/CreateOrmXML.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.admin.test;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLEntityMappings;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLEntityMappingsWriter;
+import org.junit.Test;
+
+import eclipselink.example.mysports.admin.services.MappingsLoader;
+import eclipselink.example.mysports.admin.services.test.AdminPersistenceTesting;
+
+public class CreateOrmXML {
+
+ @Test
+ public void createEmpty() {
+ XMLEntityMappings mappings = new XMLEntityMappings();
+ mappings.setVersion("2.3");
+
+ XMLEntityMappingsWriter.write(mappings, System.out);
+ }
+
+ @Test
+ public void createFromDB() {
+ EntityManagerFactory emf = Persistence.createEntityManagerFactory("MySportsAdmin", AdminPersistenceTesting.get());
+ EntityManager em = emf.createEntityManager();
+
+ try {
+ String xml = MappingsLoader.getORMapping(em, "OSL");
+ System.out.println(xml);
+
+ xml = MappingsLoader.getORMapping(em, "HTHL");
+ System.out.println(xml);
+ } finally {
+ em.close();
+ emf.close();
+ }
+ }
+
+}
diff --git a/mysports/admin.web/src/test/java/eclipselink/example/mysports/admin/test/CreateStyles.java b/mysports/admin.web/src/test/java/eclipselink/example/mysports/admin/test/CreateStyles.java
new file mode 100644
index 0000000..27fbac6
--- /dev/null
+++ b/mysports/admin.web/src/test/java/eclipselink/example/mysports/admin/test/CreateStyles.java
@@ -0,0 +1,98 @@
+/**
+ * *****************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved. This program and the
+ * accompanying materials are made available under the terms of the Eclipse
+ * Public License v1.0 and Eclipse Distribution License v. 1.0 which accompanies
+ * this distribution. The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html and the Eclipse Distribution
+ * License is available at http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors: dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ *****************************************************************************
+ */
+package eclipselink.example.mysports.admin.test;
+
+import java.io.InputStream;
+import java.io.StringWriter;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+
+import org.eclipse.persistence.jpa.JpaHelper;
+import org.eclipse.persistence.sessions.server.Server;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import eclipselink.example.mysports.admin.model.Style;
+import eclipselink.example.mysports.admin.services.test.AdminPersistenceTesting;
+
+/**
+ * Create initial styles.
+ *
+ * @author dclarke
+ * @since EclipseLink 2.3.0
+ */
+public class CreateStyles {
+
+ private static EntityManagerFactory emf;
+
+ @Test
+ public void verifySession() {
+ Assert.assertNotNull(emf);
+
+ Server session = JpaHelper.getServerSession(emf);
+ Assert.assertNotNull(session);
+ Assert.assertTrue(session.isServerSession());
+ }
+
+ @Test
+ public void createStyles() throws Exception {
+ EntityManager em = emf.createEntityManager();
+
+ try {
+ em.getTransaction().begin();
+
+ em.persist(new Style("default", load("default")));
+ em.persist(new Style("red", load("red")));
+ em.persist(new Style("black", load("black")));
+ em.persist(new Style("blue", load("blue")));
+ em.persist(new Style("green", load("green")));
+
+ em.getTransaction().commit();
+ } finally {
+ em.close();
+ }
+ }
+
+ @BeforeClass
+ public static void createEMF() {
+ emf = Persistence.createEntityManagerFactory("MySportsAdmin", AdminPersistenceTesting.get());
+
+ EntityManager em = emf.createEntityManager();
+ try {
+ em.getTransaction().begin();
+ em.createQuery("DELETE FROM Style").executeUpdate();
+ em.getTransaction().commit();
+ } finally {
+ em.close();
+ }
+ }
+
+ @AfterClass
+ public static void closeEMF() {
+ emf.close();
+ }
+
+ private String load(String name) throws Exception {
+ InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream("example/mysports/tests/admin/style/" + name + ".css");
+ StringWriter writer = new StringWriter(in.available());
+ for (int ch = in.read(); ch >= 0; ch = in.read()) {
+ writer.write(ch);
+ }
+ in.close();
+ return writer.toString();
+ }
+}
diff --git a/mysports/admin.web/src/test/java/eclipselink/example/mysports/admin/test/CreateXMLBindingsTests.java b/mysports/admin.web/src/test/java/eclipselink/example/mysports/admin/test/CreateXMLBindingsTests.java
new file mode 100644
index 0000000..234fde3
--- /dev/null
+++ b/mysports/admin.web/src/test/java/eclipselink/example/mysports/admin/test/CreateXMLBindingsTests.java
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.admin.test;
+
+public class CreateXMLBindingsTests {
+ // TODO
+}
diff --git a/mysports/admin.web/src/test/java/eclipselink/example/mysports/admin/test/LeagueJAXBTests.java b/mysports/admin.web/src/test/java/eclipselink/example/mysports/admin/test/LeagueJAXBTests.java
new file mode 100644
index 0000000..18dbd0f
--- /dev/null
+++ b/mysports/admin.web/src/test/java/eclipselink/example/mysports/admin/test/LeagueJAXBTests.java
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.admin.test;
+
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import eclipselink.example.mysports.admin.jaxrs.MySportsContextResolver;
+import eclipselink.example.mysports.admin.model.HostedLeague;
+import eclipselink.example.mysports.admin.services.test.AdminPersistenceTesting;
+
+/**
+ *
+ * @author dclarke
+ * @since EclipseLink 2.3.0
+ */
+public class LeagueJAXBTests {
+
+ private JAXBContext jaxbContext;
+
+ private static EntityManagerFactory emf;
+
+ @Test
+ public void verifyCreateContext() throws Exception {
+ JAXBContext jc = getJaxbContext();
+
+ Assert.assertNotNull(jc);
+ }
+
+ @Test
+ public void verifyMarshallHostedLeagues() throws Exception {
+ EntityManager em = emf.createEntityManager();
+
+ List<HostedLeague> leagues = em.createNamedQuery("HostedLeague.findAll", HostedLeague.class).getResultList();
+
+ Marshaller marshaller = getJaxbContext().createMarshaller();
+ marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+
+ for (HostedLeague hl: leagues) {
+ hl.setUri("TEST");
+ marshaller.marshal(hl, System.out);
+ }
+ }
+
+ private JAXBContext getJaxbContext() throws JAXBException {
+ if (this.jaxbContext == null) {
+ this.jaxbContext = MySportsContextResolver.createContext();
+ }
+ return this.jaxbContext;
+ }
+
+ @BeforeClass
+ public static void createEMF() {
+ emf = Persistence.createEntityManagerFactory("MySportsAdmin", AdminPersistenceTesting.get());
+ }
+
+ @AfterClass
+ public static void closeEMF() {
+ if (emf != null && emf.isOpen()) {
+ emf.close();
+ }
+ emf = null;
+ }
+}
diff --git a/mysports/admin.web/src/test/java/eclipselink/example/mysports/admin/test/SchemaGenerator.java b/mysports/admin.web/src/test/java/eclipselink/example/mysports/admin/test/SchemaGenerator.java
new file mode 100644
index 0000000..c53334d
--- /dev/null
+++ b/mysports/admin.web/src/test/java/eclipselink/example/mysports/admin/test/SchemaGenerator.java
@@ -0,0 +1,33 @@
+package eclipselink.example.mysports.admin.test;
+
+import java.io.File;
+import java.io.IOException;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.SchemaOutputResolver;
+import javax.xml.transform.Result;
+import javax.xml.transform.stream.StreamResult;
+
+import org.junit.Test;
+
+import eclipselink.example.mysports.admin.jaxrs.MySportsContextResolver;
+
+public class SchemaGenerator {
+
+ @Test
+ public void generateLeaguesXSD() throws Exception {
+ JAXBContext context = MySportsContextResolver.createContext();
+ SchemaOutputResolver sor = new MySchemaOutputResolver();
+ context.generateSchema(sor);
+ }
+
+ private class MySchemaOutputResolver extends SchemaOutputResolver {
+
+ public Result createOutput(String namespaceURI, String suggestedFileName) throws IOException {
+ File file = new File(suggestedFileName);
+ StreamResult result = new StreamResult(file);
+ result.setSystemId(file.toURI().toURL().toString());
+ return result;
+ }
+
+ }}
diff --git a/mysports/application/.classpath b/mysports/application/.classpath
new file mode 100644
index 0000000..c99cf86
--- /dev/null
+++ b/mysports/application/.classpath
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" output="target/classes" path="src/main/java">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/java">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
diff --git a/mysports/application/.project b/mysports/application/.project
new file mode 100644
index 0000000..c940312
--- /dev/null
+++ b/mysports/application/.project
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>mysports.app</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.wst.common.project.facet.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.wst.validation.validationbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.m2e.core.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
+ <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.m2e.core.maven2Nature</nature>
+ <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+ <nature>org.eclipse.wst.jsdt.core.jsNature</nature>
+ </natures>
+</projectDescription>
diff --git a/mysports/application/.settings/.jsdtscope b/mysports/application/.settings/.jsdtscope
new file mode 100644
index 0000000..b46b920
--- /dev/null
+++ b/mysports/application/.settings/.jsdtscope
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/main/webapp"/>
+ <classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject">
+ <attributes>
+ <attribute name="hide" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
+ <classpathentry kind="output" path=""/>
+</classpath>
diff --git a/mysports/application/.settings/oracle.eclipse.tools.webtier.ui.prefs b/mysports/application/.settings/oracle.eclipse.tools.webtier.ui.prefs
new file mode 100644
index 0000000..fe451cf
--- /dev/null
+++ b/mysports/application/.settings/oracle.eclipse.tools.webtier.ui.prefs
@@ -0,0 +1,22 @@
+//_hiddenCategory_\:http\://java.sun.com/jsf/composite=false
+//_hiddenCategory_\:http\://java.sun.com/jsf/core=false
+//_hiddenCategory_\:http\://java.sun.com/jsf/facelets=false
+//_hiddenCategory_\:http\://java.sun.com/jsf/html=false
+//_hiddenCategory_\:http\://java.sun.com/jsp/jstl/core=false
+//_hiddenCategory_\:http\://java.sun.com/jsp/jstl/fmt=false
+//_hiddenCategory_\:http\://java.sun.com/jsp/jstl/sql=false
+//_hiddenCategory_\:http\://java.sun.com/jsp/jstl/xml=false
+//_hiddenCategory_\:http\://java.sun.com/jstl/core=false
+//_hiddenCategory_\:http\://java.sun.com/jstl/core_rt=false
+//_hiddenCategory_\:http\://java.sun.com/jstl/fmt=false
+//_hiddenCategory_\:http\://java.sun.com/jstl/fmt_rt=false
+//_hiddenCategory_\:http\://java.sun.com/jstl/sql=false
+//_hiddenCategory_\:http\://java.sun.com/jstl/sql_rt=false
+//_hiddenCategory_\:http\://java.sun.com/jstl/xml=false
+//_hiddenCategory_\:http\://java.sun.com/jstl/xml_rt=false
+//_hiddenCategory_\:http\://mojarra.dev.java.net/mojarra_ext=true
+_hiddenCategory_\:HTML=false
+_hiddenCategory_\:ManagedBeans=false
+_hiddenCategory_\:PageVariables=false
+_hiddenCategory_\:jsp11=false
+eclipse.preferences.version=1
diff --git a/mysports/application/.settings/org.eclipse.jdt.core.prefs b/mysports/application/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..107056a
--- /dev/null
+++ b/mysports/application/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,12 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/mysports/application/.settings/org.eclipse.jpt.core.prefs b/mysports/application/.settings/org.eclipse.jpt.core.prefs
new file mode 100644
index 0000000..f225875
--- /dev/null
+++ b/mysports/application/.settings/org.eclipse.jpt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jpt.core.platform=eclipselink2_4
+org.eclipse.jpt.jpa.core.discoverAnnotatedClasses=false
+org.eclipse.jpt.jpa.core.metamodelSourceFolderName=src/main/java
+problem.PROJECT_INACTIVE_CONNECTION=info
+problem.PROJECT_NO_CONNECTION=info
+workspace_preferences_overriden=true
diff --git a/mysports/application/.settings/org.eclipse.m2e.core.prefs b/mysports/application/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 0000000..2af59a6
--- /dev/null
+++ b/mysports/application/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=mysql
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/mysports/application/.settings/org.eclipse.wst.common.component b/mysports/application/.settings/org.eclipse.wst.common.component
new file mode 100644
index 0000000..95e165f
--- /dev/null
+++ b/mysports/application/.settings/org.eclipse.wst.common.component
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
+ <wb-module deploy-name="mysports.app">
+ <wb-resource deploy-path="/WEB-INF/web.xml" source-path="/src/main/webapp/WEB-INF/web.xml"/>
+ <wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
+ <wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
+ <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
+ <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
+ <dependent-module archiveName="persistence-2.4.2-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/mysports.persistence/mysports.persistence">
+ <dependency-type>uses</dependency-type>
+ </dependent-module>
+ <property name="java-output-path" value="/mysports.app/target/classes"/>
+ <property name="context-root" value="application"/>
+ </wb-module>
+</project-modules>
diff --git a/mysports/application/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml b/mysports/application/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml
new file mode 100644
index 0000000..d564e65
--- /dev/null
+++ b/mysports/application/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml
@@ -0,0 +1,17 @@
+<root>
+ <facet id="jpt.jpa">
+ <node name="libprov">
+ <attribute name="provider-id" value="jpa-no-op-library-provider"/>
+ </node>
+ </facet>
+ <facet id="jst.jaxrs">
+ <node name="libprov">
+ <attribute name="provider-id" value="jaxrs-no-op-library-provider"/>
+ </node>
+ </facet>
+ <facet id="jst.jsf">
+ <node name="libprov">
+ <attribute name="provider-id" value="jsf-no-op-library-provider"/>
+ </node>
+ </facet>
+</root>
diff --git a/mysports/application/.settings/org.eclipse.wst.common.project.facet.core.xml b/mysports/application/.settings/org.eclipse.wst.common.project.facet.core.xml
new file mode 100644
index 0000000..6fa65b6
--- /dev/null
+++ b/mysports/application/.settings/org.eclipse.wst.common.project.facet.core.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+ <fixed facet="wst.jsdt.web"/>
+ <installed facet="jst.web" version="3.0"/>
+ <installed facet="wst.jsdt.web" version="1.0"/>
+ <installed facet="java" version="1.6"/>
+ <installed facet="jpt.jpa" version="2.0"/>
+ <installed facet="jst.jaxrs" version="1.1"/>
+ <installed facet="jst.jsf" version="2.0"/>
+</faceted-project>
diff --git a/mysports/application/.settings/org.eclipse.wst.jsdt.ui.superType.container b/mysports/application/.settings/org.eclipse.wst.jsdt.ui.superType.container
new file mode 100644
index 0000000..3bd5d0a
--- /dev/null
+++ b/mysports/application/.settings/org.eclipse.wst.jsdt.ui.superType.container
@@ -0,0 +1 @@
+org.eclipse.wst.jsdt.launching.baseBrowserLibrary
\ No newline at end of file
diff --git a/mysports/application/.settings/org.eclipse.wst.jsdt.ui.superType.name b/mysports/application/.settings/org.eclipse.wst.jsdt.ui.superType.name
new file mode 100644
index 0000000..05bd71b
--- /dev/null
+++ b/mysports/application/.settings/org.eclipse.wst.jsdt.ui.superType.name
@@ -0,0 +1 @@
+Window
\ No newline at end of file
diff --git a/mysports/application/eclipse-config/TestCreateTenantEMF.launch b/mysports/application/eclipse-config/TestCreateTenantEMF.launch
new file mode 100644
index 0000000..1bf4cf0
--- /dev/null
+++ b/mysports/application/eclipse-config/TestCreateTenantEMF.launch
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/application/src/test/java/eclipselink/example/mysports/application/test/TestCreateTenantEMF.java"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="1"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
+<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
+<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
+<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="eclipselink.example.mysports.application.test.TestCreateTenantEMF"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="application"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-javaagent:${system_property:user.home}/.m2/repository/eclipselink/example/mysports/persistence/2.4.2-SNAPSHOT/persistence-2.4.2-SNAPSHOT.jar"/>
+</launchConfiguration>
diff --git "a/mysports/application/eclipse-config/TestExampleLeagues \0501\051.launch" "b/mysports/application/eclipse-config/TestExampleLeagues \0501\051.launch"
new file mode 100644
index 0000000..69b3e5c
--- /dev/null
+++ "b/mysports/application/eclipse-config/TestExampleLeagues \0501\051.launch"
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/MySports Application/src/test/java/eclipselink/example/mysports/application/test/TestExampleLeagues.java"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="1"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
+<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
+<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
+<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="eclipselink.example.mysports.application.test.TestExampleLeagues"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="MySports Application"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-javaagent:${system_property:user.home}/.m2/repository/org/eclipse/persistence/eclipselink/2.4.2-SNAPSHOT/eclipselink-2.4.2-SNAPSHOT.jar"/>
+</launchConfiguration>
diff --git a/mysports/application/eclipse-config/TestExampleLeagues.launch b/mysports/application/eclipse-config/TestExampleLeagues.launch
new file mode 100644
index 0000000..48ee848
--- /dev/null
+++ b/mysports/application/eclipse-config/TestExampleLeagues.launch
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/application/src/test/java/eclipselink/example/mysports/application/test/TestExampleLeagues.java"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="1"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
+<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
+<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
+<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="eclipselink.example.mysports.application.test.TestExampleLeagues"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="application"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-javaagent:${system_property:user.home}/.m2/repository/eclipselink/example/mysports/persistence/2.4.2-SNAPSHOT/persistence-2.4.2-SNAPSHOT.jar"/>
+</launchConfiguration>
diff --git a/mysports/application/eclipse-config/TestModelAndMappings.launch b/mysports/application/eclipse-config/TestModelAndMappings.launch
new file mode 100644
index 0000000..e3f8b0f
--- /dev/null
+++ b/mysports/application/eclipse-config/TestModelAndMappings.launch
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/application/src/test/java/eclipselink/example/mysports/application/test/TestModelAndMappings.java"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="1"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
+<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
+<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
+<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="eclipselink.example.mysports.application.test.TestModelAndMappings"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="application"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-javaagent:${system_property:user.home}/.m2/repository/eclipselink/example/mysports/persistence/2.4.2-SNAPSHOT/persistence-2.4.2-SNAPSHOT.jar"/>
+</launchConfiguration>
diff --git "a/mysports/application/eclipse-config/TestSchemaCreation \0501\051.launch" "b/mysports/application/eclipse-config/TestSchemaCreation \0501\051.launch"
new file mode 100644
index 0000000..6a2a140
--- /dev/null
+++ "b/mysports/application/eclipse-config/TestSchemaCreation \0501\051.launch"
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/MySports Application/src/test/java/eclipselink/example/mysports/application/test/TestSchemaCreation.java"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="1"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
+<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
+<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
+<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="eclipselink.example.mysports.application.test.TestSchemaCreation"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="MySports Application"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-javaagent:${system_property:user.home}/.m2/repository/org/eclipse/persistence/eclipselink/2.4.2-SNAPSHOT/eclipselink-2.4.2-SNAPSHOT.jar"/>
+</launchConfiguration>
diff --git a/mysports/application/pom.xml b/mysports/application/pom.xml
new file mode 100644
index 0000000..79f86cf
--- /dev/null
+++ b/mysports/application/pom.xml
@@ -0,0 +1,184 @@
+<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>
+
+ <parent>
+ <groupId>eclipselink.example.mysports</groupId>
+ <artifactId>bom</artifactId>
+ <version>2.4.2-SNAPSHOT</version>
+ <relativePath>..</relativePath>
+ </parent>
+
+ <artifactId>application</artifactId>
+ <packaging>war</packaging>
+ <name>MySports WebApp</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>persistence</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse.persistence</groupId>
+ <artifactId>eclipselink</artifactId>
+ <version>${eclipselink.version}</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>commonj.sdo</artifactId>
+ <groupId>commonj.sdo</groupId>
+ </exclusion>
+ </exclusions>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- EclipseLink JPA-RS Web Fragment -->
+ <dependency>
+ <groupId>org.eclipse.persistence</groupId>
+ <artifactId>org.eclipse.persistence.jpars</artifactId>
+ <version>${eclipselink.version}</version>
+ </dependency>
+
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>admin.services</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>admin.services</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.derby</groupId>
+ <artifactId>derby</artifactId>
+ <version>10.9.1.0</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-impl</artifactId>
+ <version>1.2_15</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>persistence</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.0</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-war-plugin</artifactId>
+ <version>2.3</version>
+ <configuration>
+ <webXml>src/main/webapp/WEB-INF/web.xml</webXml>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.12.4</version>
+ <configuration>
+ <argLine>-javaagent:../persistence/target/persistence-${eclipselink.version}.jar</argLine>
+ <systemProperties>
+ <property>
+ <name>derby.stream.error.file</name>
+ <value>target/derby.log</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>mysql</id>
+ <activation>
+ <property>
+ <name>mysql</name>
+ </property>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <version>5.1.22</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.12.4</version>
+ <configuration>
+ <systemProperties>
+ <property>
+ <name>javax.persistence.jdbc.url</name>
+ <value>jdbc:mysql://localhost:3306/mysports</value>
+ </property>
+ <property>
+ <name>javax.persistence.jdbc.driver</name>
+ <value>com.mysql.jdbc.Driver</value>
+ </property>
+ <property>
+ <name>javax.persistence.jdbc.user</name>
+ <value>mysports</value>
+ </property>
+ <property>
+ <name>javax.persistence.jdbc.password</name>
+ <value>mysports</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+</project>
diff --git a/mysports/application/src/main/java/eclipselink/example/mysports/application/MySportsConfig.java b/mysports/application/src/main/java/eclipselink/example/mysports/application/MySportsConfig.java
new file mode 100644
index 0000000..9e2f5ec
--- /dev/null
+++ b/mysports/application/src/main/java/eclipselink/example/mysports/application/MySportsConfig.java
@@ -0,0 +1,44 @@
+/**
+ * *****************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved. This program and the
+ * accompanying materials are made available under the terms of the Eclipse
+ * Public License v1.0 and Eclipse Distribution License v. 1.0 which accompanies
+ * this distribution. The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html and the Eclipse Distribution
+ * License is available at http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors: dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ *****************************************************************************
+ */
+package eclipselink.example.mysports.application;
+
+import org.eclipse.persistence.annotations.Multitenant;
+
+import eclipselink.example.mysports.application.services.LeagueRepository;
+
+/**
+ * Responsible for managing application context configuration. For now this is
+ * hard coded for local deployment but will be made more flexible in the future.
+ *
+ * @author dclarke
+ * @since EclipseLink 2.3.0
+ */
+public class MySportsConfig {
+
+ /**
+ * Context property used to specify the tenant configuration within the
+ * persistence unit. A value for this property must be available within the
+ * persistence context to access the {@link Multitenant} types.
+ */
+ public static final String LEAGUE_CONTEXT = "league";
+
+ /**
+ * Template persistence unit name. This is the base PU which is used as a
+ * template for each tenant's persistence unit.
+ *
+ * @see LeagueRepository#setLeagueId(String, java.util.Map) for details of
+ * how the PUs are created from template.
+ */
+ public static final String PU_NAME = "mysports";
+
+}
diff --git a/mysports/application/src/main/java/eclipselink/example/mysports/application/admin/AdminMetadataSource.java b/mysports/application/src/main/java/eclipselink/example/mysports/application/admin/AdminMetadataSource.java
new file mode 100644
index 0000000..76f6ec6
--- /dev/null
+++ b/mysports/application/src/main/java/eclipselink/example/mysports/application/admin/AdminMetadataSource.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.application.admin;
+
+import static eclipselink.example.mysports.application.MySportsConfig.LEAGUE_CONTEXT;
+
+import java.util.Map;
+
+import org.eclipse.persistence.config.PersistenceUnitProperties;
+import org.eclipse.persistence.exceptions.ValidationException;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLEntityMappings;
+import org.eclipse.persistence.jpa.metadata.MetadataSource;
+import org.eclipse.persistence.jpa.metadata.XMLMetadataSource;
+import org.eclipse.persistence.logging.SessionLog;
+
+/**
+ * {@link MetadataSource} which using REST calls to retrieve the league (tenant)
+ * specific mappings from the MySports Admin application.
+ * <p>
+ * If the Admin application can not be reached a warning message is logged and
+ * the contained 'local-eclipselink-orm.xml' is returned.
+ *
+ * @author dclarke
+ * @since EclipseLink 2.3.0
+ */
+public class AdminMetadataSource extends XMLMetadataSource {
+
+ private AdminServerConnector connector;
+
+ public AdminMetadataSource(AdminServerConnector connector) {
+ super();
+ this.connector = connector;
+ }
+
+ AdminServerConnector getConnector() {
+ return connector;
+ }
+
+ /**
+ * Default local resource. Only used when admin service cannot be accessed.
+ */
+ public static final String LOCAL_ECLIPSELINK_ORM = "META-INF/local-eclipselink-orm.xml";
+
+ @Override
+ public XMLEntityMappings getEntityMappings(Map<String, Object> properties, ClassLoader classLoader, SessionLog log) {
+ String leagueId = (String) properties.get(LEAGUE_CONTEXT);
+
+ if (leagueId != null) {
+ if (connector != null) {
+ properties.put(PersistenceUnitProperties.METADATA_SOURCE_XML_URL, getConnector().getOrmURL(leagueId));
+ }
+ try {
+ return super.getEntityMappings(properties, classLoader, log);
+ } catch (ValidationException ve) {
+ } catch (NullPointerException npe) {
+
+ }
+
+ properties.remove(PersistenceUnitProperties.METADATA_SOURCE_XML_URL);
+ properties.put(PersistenceUnitProperties.METADATA_SOURCE_XML_FILE, LOCAL_ECLIPSELINK_ORM);
+ return super.getEntityMappings(properties, classLoader, log);
+ }
+ return null;
+ }
+
+}
diff --git a/mysports/application/src/main/java/eclipselink/example/mysports/application/admin/AdminServerConnector.java b/mysports/application/src/main/java/eclipselink/example/mysports/application/admin/AdminServerConnector.java
new file mode 100644
index 0000000..a0996b1
--- /dev/null
+++ b/mysports/application/src/main/java/eclipselink/example/mysports/application/admin/AdminServerConnector.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.application.admin;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * Interface to access the admin server. This abstraction is provided so the
+ * runtime can use the default {@link RESTAdminServerConnector} while testing
+ * outside the container can provide a local version.
+ *
+ * @author dclarke
+ * @since EclipseLink 2.3.0
+ */
+public interface AdminServerConnector {
+
+ /**
+ * Return the list of leagues (tenants) available.
+ */
+ HostedLeagues getLeagues();
+
+ /**
+ * Retrieve the league (name and version) from the admin server.
+ */
+ League getLeague(String leagueId);
+
+ String getOrmURL(String leagueId);
+
+ InputStream getCss(String leagueId) throws IOException;
+
+ InputStream getLogo(String leagueId) throws IOException;
+
+}
\ No newline at end of file
diff --git a/mysports/application/src/main/java/eclipselink/example/mysports/application/admin/HostedLeagues.java b/mysports/application/src/main/java/eclipselink/example/mysports/application/admin/HostedLeagues.java
new file mode 100644
index 0000000..596d1b2
--- /dev/null
+++ b/mysports/application/src/main/java/eclipselink/example/mysports/application/admin/HostedLeagues.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.application.admin;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Represents the list of leagues returned form the Admin service's REST call as
+ * an XML document.
+ *
+ * @author dclarke
+ * @since EclipseLink 2.3.0
+ */
+public class HostedLeagues {
+
+ private List<League> leagues = new ArrayList<League>();
+
+ public List<League> getLeagues() {
+ return leagues;
+ }
+
+}
diff --git a/mysports/application/src/main/java/eclipselink/example/mysports/application/admin/League.java b/mysports/application/src/main/java/eclipselink/example/mysports/application/admin/League.java
new file mode 100644
index 0000000..270ec6a
--- /dev/null
+++ b/mysports/application/src/main/java/eclipselink/example/mysports/application/admin/League.java
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.application.admin;
+
+
+/**
+ * League as defined on the admin server.
+ *
+ * @author dclarke
+ * @since EclipseLink 2.3.0
+ */
+public class League {
+ private String id;
+ private long version;
+ private String name;
+ private String colourScheme;
+ private String logoUrl;
+ private String uri;
+ private String datasource;
+
+ public String getId() {
+ return id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public long getVersion() {
+ return version;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public void setVersion(long version) {
+ this.version = version;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getColourScheme() {
+ return colourScheme;
+ }
+
+ public void setColourScheme(String colourScheme) {
+ this.colourScheme = colourScheme;
+ }
+
+ public String getLogoUrl() {
+ return logoUrl;
+ }
+
+ public void setLogoUrl(String logoUrl) {
+ this.logoUrl = logoUrl;
+ }
+
+ public String getUri() {
+ return uri;
+ }
+
+ public void setUri(String uri) {
+ this.uri = uri;
+ }
+
+ public String getDatasource() {
+ return datasource;
+ }
+
+ public void setDatasource(String datasource) {
+ this.datasource = datasource;
+ }
+}
diff --git a/mysports/application/src/main/java/eclipselink/example/mysports/application/admin/MoxyContextHelper.java b/mysports/application/src/main/java/eclipselink/example/mysports/application/admin/MoxyContextHelper.java
new file mode 100644
index 0000000..c3aedb3
--- /dev/null
+++ b/mysports/application/src/main/java/eclipselink/example/mysports/application/admin/MoxyContextHelper.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.application.admin;
+
+import static org.eclipse.persistence.jaxb.MarshallerProperties.MEDIA_TYPE;
+import static org.eclipse.persistence.jaxb.UnmarshallerProperties.JSON_INCLUDE_ROOT;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+
+import org.eclipse.persistence.jaxb.JAXBContextFactory;
+import org.eclipse.persistence.jaxb.JAXBContextProperties;
+import org.eclipse.persistence.oxm.MediaType;
+
+/**
+ * Utility class that provides access to the admin server using JAX-RS calls.
+ *
+ * @author dclarke
+ * @since EclipseLink 2.4
+ */
+public class MoxyContextHelper {
+
+ /**
+ * Cached {@link JAXBContext} for marshaling {@link HostedLeagues} and
+ * {@link League} from the admin server requests.
+ */
+ private static JAXBContext jaxbContext;
+
+ public static JAXBContext getContext() throws JAXBException {
+ if (jaxbContext == null) {
+ Map<String, Object> props = new HashMap<String, Object>(1);
+ props.put(JAXBContextProperties.OXM_METADATA_SOURCE, "eclipselink/example/mysports/application/admin/leagues-oxm.xml");
+ jaxbContext = JAXBContextFactory.createContext(new Class[] { HostedLeagues.class }, props);
+ }
+ return jaxbContext;
+ }
+
+ public static Marshaller createMarshaller(MediaType mediaType) throws JAXBException {
+ Marshaller marshaller = getContext().createMarshaller();
+ marshaller.setProperty(MEDIA_TYPE, mediaType.getMediaType());
+ return marshaller;
+ }
+
+ public static Unmarshaller createUnmarshaller(MediaType mediaType) throws JAXBException {
+ Unmarshaller unmarshaller = getContext().createUnmarshaller();
+ unmarshaller.setProperty(MEDIA_TYPE, mediaType.getMediaType());
+ unmarshaller.setProperty(JSON_INCLUDE_ROOT, false);
+ return unmarshaller;
+ }
+
+
+}
diff --git a/mysports/application/src/main/java/eclipselink/example/mysports/application/admin/RESTAdminServerConnector.java b/mysports/application/src/main/java/eclipselink/example/mysports/application/admin/RESTAdminServerConnector.java
new file mode 100644
index 0000000..53eef18
--- /dev/null
+++ b/mysports/application/src/main/java/eclipselink/example/mysports/application/admin/RESTAdminServerConnector.java
@@ -0,0 +1,132 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.application.admin;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+import javax.xml.bind.JAXBException;
+
+import org.eclipse.persistence.oxm.MediaType;
+
+/**
+ * Utility class that provides access to the admin server using JAX-RS calls.
+ *
+ * @author dclarke
+ * @since EclipseLink 2.3.0
+ */
+public class RESTAdminServerConnector implements AdminServerConnector {
+
+ /**
+ * Default Root URI for the Admin application. Assumed to be hosted on the same container.
+ */
+ public static final String DEFAULT_ROOT_URI = "http://localhost:7001/mysportsadmin/rest/league";
+
+ private String rootURI = DEFAULT_ROOT_URI;
+
+ String getRootURI() {
+ return rootURI;
+ }
+
+ void setRootURI(String rootURI) {
+ this.rootURI = rootURI;
+ }
+
+ public HostedLeagues getLeagues() {
+ InputStream in = null;
+
+ try {
+ in = open(null, MediaType.APPLICATION_XML.getMediaType(), null);
+ return (HostedLeagues) MoxyContextHelper.createUnmarshaller(MediaType.APPLICATION_XML).unmarshal(in);
+ } catch (IOException e) {
+ throw new RuntimeException("Failure to retieve Leagues", e);
+ } catch (JAXBException e) {
+ throw new RuntimeException("Failure to unmarshal Leagues", e);
+ } finally {
+ if (in != null) {
+ try {
+ in.close();
+ } catch (IOException e) {
+ }
+ }
+ }
+ }
+
+ public League getLeague(String leagueId) {
+ InputStream in = null;
+
+ try {
+ in = open(leagueId, MediaType.APPLICATION_XML.getMediaType(), null);
+ return (League) MoxyContextHelper.createUnmarshaller(org.eclipse.persistence.oxm.MediaType.APPLICATION_XML).unmarshal(in);
+ } catch (IOException e) {
+ throw new RuntimeException("Failure to retieve League", e);
+ } catch (JAXBException e) {
+ throw new RuntimeException("Failure to unmarshal League", e);
+ } finally {
+ if (in != null) {
+ try {
+ in.close();
+ } catch (IOException e) {
+ }
+ }
+ }
+ }
+
+ /**
+ * Construct a URL to access the admin server for a specified league and
+ * resource result type.
+ *
+ * @param leagueId
+ * represents an expected league or null if requesting all
+ * leagues.
+ * @param result
+ * result resource type being requested. If null with a valid
+ * league identifier then the league is being accessed. If
+ * leagueId is null this should be null as well.
+ */
+ private String buildURL(String leagueId, String result) {
+ String urlString = getRootURI();
+
+ if (leagueId != null) {
+ urlString = urlString + "/" + leagueId;
+ }
+ if (result != null) {
+ urlString = urlString + "/" + result.toLowerCase();
+ }
+
+ return urlString;
+ }
+
+ private InputStream open(String leagueId, String mediaType, String result) throws IOException {
+ URL url = new URL(buildURL(leagueId, result));
+ HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+ connection.setRequestProperty("Accept", mediaType);
+
+ return connection.getInputStream();
+ }
+
+ public InputStream getCss(String leagueId) throws IOException {
+ return open(leagueId, "text/css", "css");
+ }
+
+ public String getOrmURL(String leagueId) {
+ return buildURL(leagueId, "orm");
+ }
+
+ public InputStream getLogo(String leagueId) throws IOException {
+ return open(leagueId, "?", "logo");
+ }
+
+}
diff --git a/mysports/application/src/main/java/eclipselink/example/mysports/application/admin/leagues-oxm.xml b/mysports/application/src/main/java/eclipselink/example/mysports/application/admin/leagues-oxm.xml
new file mode 100644
index 0000000..41b6546
--- /dev/null
+++ b/mysports/application/src/main/java/eclipselink/example/mysports/application/admin/leagues-oxm.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<xml-bindings version="2.3"
+ xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm"
+ package-name="eclipselink.example.mysports.application.admin" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.eclipse.org/eclipselink/xsds/persistence/oxm http://www.eclipse.org/eclipselink/xsds/eclipselink_oxm_2_3.xsd">
+ <java-types>
+ <java-type name="HostedLeagues" xml-accessor-type="FIELD">
+ <xml-root-element name="hostedLeagues"/>
+ <java-attributes>
+ <xml-element java-attribute="leagues" name="league" />
+ </java-attributes>
+ </java-type>
+ <java-type name="League" xml-accessor-type="FIELD">
+ <xml-root-element />
+ <java-attributes>
+ <xml-attribute java-attribute="id" />
+ <xml-attribute java-attribute="version" />
+ <xml-element java-attribute="name" />
+ <xml-element java-attribute="colourScheme" name="scheme"/>
+ <xml-element java-attribute="logoUrl" name="logo"/>
+ <xml-element java-attribute="datasource" name="data-source"/>
+ <xml-element java-attribute="uri" xml-path="link/@href"/>
+ </java-attributes>
+ </java-type>
+ </java-types>
+</xml-bindings>
\ No newline at end of file
diff --git a/mysports/application/src/main/java/eclipselink/example/mysports/application/model/Division.java b/mysports/application/src/main/java/eclipselink/example/mysports/application/model/Division.java
new file mode 100644
index 0000000..d0a9a92
--- /dev/null
+++ b/mysports/application/src/main/java/eclipselink/example/mysports/application/model/Division.java
@@ -0,0 +1,139 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.application.model;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.OneToMany;
+import javax.persistence.QueryHint;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+import javax.persistence.Version;
+
+import org.eclipse.persistence.annotations.Multitenant;
+import org.eclipse.persistence.annotations.TenantDiscriminatorColumn;
+import org.eclipse.persistence.config.HintValues;
+import org.eclipse.persistence.config.QueryHints;
+
+import eclipselink.example.mysports.application.MySportsConfig;
+
+@Entity
+@Table(name = "MYS_DIV")
+@NamedQueries({
+ @NamedQuery(name="Division.findAll", query="SELECT d FROM Division d ORDER BY d.name",
+ hints={@QueryHint(name=QueryHints.QUERY_RESULTS_CACHE, value=HintValues.TRUE)}),
+ @NamedQuery(name="Division.findByName", query="SELECT d FROM Division d WHERE d.name = :NAME")
+})
+@Multitenant
+@TenantDiscriminatorColumn(name="LEAGUE_ID", contextProperty=MySportsConfig.LEAGUE_CONTEXT, length=5)
+public class Division implements Extensible {
+
+ @Id
+ @GeneratedValue
+ @Column(name = "ID")
+ private int id;
+
+ /**
+ * Flag to indicate default division for use when a league has only one
+ * division.
+ */
+ @Column(name = "DEF_DIV")
+ private boolean defaultDivision = false;
+
+ @Column(name = "NAME")
+ private String name;
+
+ @OneToMany(mappedBy = "division", cascade = CascadeType.ALL)
+ private List<Team> teams;
+
+ @Version
+ private long version;
+
+ public long getVersion() {
+ return version;
+ }
+
+ @Transient
+ private Map<String, Object> attributes = new HashMap<String, Object>();
+
+ public Division() {
+ this.teams = new ArrayList<Team>();
+ }
+
+ public Division(String name) {
+ this();
+ this.name = name;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ protected void setId(int id) {
+ this.id = id;
+ }
+
+ protected void setVersion(long version) {
+ this.version = version;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public List<Team> getTeams() {
+ return teams;
+ }
+
+ public boolean isDefaultDivision() {
+ return defaultDivision;
+ }
+
+ public void setDefaultDivision(boolean defaultDivision) {
+ this.defaultDivision = defaultDivision;
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> T get(String attributeName) {
+ return (T) this.attributes.get(attributeName);
+ }
+
+ public Object set(String attributeName, Object value) {
+ return this.attributes.put(attributeName, value);
+ }
+
+ public void addTeam(Team team) {
+ getTeams().add(team);
+ team.setDivision(this);
+
+ }
+
+ @Override
+ public String toString() {
+ return "Division [id=" + id + ", name=" + name + "]";
+ }
+}
diff --git a/mysports/application/src/main/java/eclipselink/example/mysports/application/model/Division_.java b/mysports/application/src/main/java/eclipselink/example/mysports/application/model/Division_.java
new file mode 100644
index 0000000..6b49b9c
--- /dev/null
+++ b/mysports/application/src/main/java/eclipselink/example/mysports/application/model/Division_.java
@@ -0,0 +1,16 @@
+package eclipselink.example.mysports.application.model;
+
+import javax.annotation.Generated;
+import javax.persistence.metamodel.ListAttribute;
+import javax.persistence.metamodel.SingularAttribute;
+import javax.persistence.metamodel.StaticMetamodel;
+
+@Generated(value="Dali", date="2013-01-08T16:39:46.133-0500")
+@StaticMetamodel(Division.class)
+public class Division_ {
+ public static volatile SingularAttribute<Division, Integer> id;
+ public static volatile SingularAttribute<Division, Boolean> defaultDivision;
+ public static volatile SingularAttribute<Division, String> name;
+ public static volatile ListAttribute<Division, Team> teams;
+ public static volatile SingularAttribute<Division, Long> version;
+}
diff --git a/mysports/application/src/main/java/eclipselink/example/mysports/application/model/Extensible.java b/mysports/application/src/main/java/eclipselink/example/mysports/application/model/Extensible.java
new file mode 100644
index 0000000..6be1ecf
--- /dev/null
+++ b/mysports/application/src/main/java/eclipselink/example/mysports/application/model/Extensible.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.application.model;
+
+import eclipselink.example.mysports.application.view.ExtensibleEntity;
+
+/**
+ * Application specific marker interface for an extensible type. Not required for EclipseLink JPA.
+ *
+ * @see ExtensibleEntity for usage in JSF
+ * @author dclarke
+ * @since EclipseLink 2.3.0
+ */
+public interface Extensible {
+
+ public <T> T get(String attributeName);
+
+ public Object set(String attributeName, Object value);
+}
diff --git a/mysports/application/src/main/java/eclipselink/example/mysports/application/model/MOXyHelper.java b/mysports/application/src/main/java/eclipselink/example/mysports/application/model/MOXyHelper.java
new file mode 100644
index 0000000..24a445b
--- /dev/null
+++ b/mysports/application/src/main/java/eclipselink/example/mysports/application/model/MOXyHelper.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.4 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.application.model;
+
+import static org.eclipse.persistence.jaxb.MarshallerProperties.MEDIA_TYPE;
+import static org.eclipse.persistence.jaxb.UnmarshallerProperties.JSON_INCLUDE_ROOT;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+
+import org.eclipse.persistence.jaxb.JAXBContextFactory;
+import org.eclipse.persistence.oxm.MediaType;
+
+public class MOXyHelper {
+
+ private static JAXBContext context;
+
+ public static JAXBContext getContext() throws JAXBException {
+ if (context == null) {
+ context = JAXBContextFactory.createContext(new Class[] { Division.class, Team.class, Player.class }, null);
+ }
+ return context;
+ }
+
+ public static Marshaller createMarshaller(MediaType mediaType) throws JAXBException {
+ Marshaller marshaller = getContext().createMarshaller();
+ marshaller.setProperty(MEDIA_TYPE, mediaType.getMediaType());
+ return marshaller;
+ }
+
+ public static Unmarshaller createUnmarshaller(MediaType mediaType) throws JAXBException {
+ Unmarshaller unmarshaller = getContext().createUnmarshaller();
+ unmarshaller.setProperty(MEDIA_TYPE, mediaType.getMediaType());
+ unmarshaller.setProperty(JSON_INCLUDE_ROOT, false);
+ return unmarshaller;
+ }
+
+}
diff --git a/mysports/application/src/main/java/eclipselink/example/mysports/application/model/Player.java b/mysports/application/src/main/java/eclipselink/example/mysports/application/model/Player.java
new file mode 100644
index 0000000..5e2990d
--- /dev/null
+++ b/mysports/application/src/main/java/eclipselink/example/mysports/application/model/Player.java
@@ -0,0 +1,185 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.application.model;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+import javax.persistence.Version;
+
+import org.eclipse.persistence.annotations.Multitenant;
+import org.eclipse.persistence.annotations.TenantDiscriminatorColumn;
+import org.eclipse.persistence.annotations.VirtualAccessMethods;
+
+import eclipselink.example.mysports.application.MySportsConfig;
+
+/**
+ * In the MySports demo a Player entity represents an individual member of a
+ * team.
+ *
+ * @author dclarke
+ * @since EclipseLink 2.3.0
+ */
+@Entity
+@Table(name = "MYS_PLAYER")
+@NamedQueries({
+ @NamedQuery(name="Player.findByTeam", query="SELECT p FROM Player p WHERE p.team.id = :team ORDER BY p.lastName, p.firstName"),
+ @NamedQuery(name="Player.findAll", query="SELECT p FROM Player p ORDER BY p.lastName, p.firstName")
+})
+@VirtualAccessMethods
+@Multitenant
+@TenantDiscriminatorColumn(name="LEAGUE_ID", contextProperty=MySportsConfig.LEAGUE_CONTEXT, length=5)
+public class Player implements Extensible {
+
+ @Id
+ @GeneratedValue
+ @Column(name = "ID")
+ private int id;
+
+ @Column(name = "USER_ID")
+ private String userid;
+
+ @Column(name = "F_NAME")
+ private String firstName;
+
+ @Column(name = "L_NAME")
+ private String lastName;
+
+ @Column(name = "EMAIL")
+ private String email;
+
+ @ManyToOne(fetch=FetchType.EAGER)
+ @JoinColumn(name = "TEAM_ID")
+ private Team team;
+
+ @Column(name = "NUM")
+ private int number;
+
+ @Version
+ private long version;
+
+ /**
+ * Extended attributes
+ */
+ @Transient
+ private Map<String, Object> attributes = new HashMap<String, Object>();
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ public Team getTeam() {
+ return team;
+ }
+
+ public void setTeam(Team team) {
+ this.team = team;
+ }
+
+ public int getNumber() {
+ return number;
+ }
+
+ public void setNumber(int number) {
+ this.number = number;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public String getUserid() {
+ return userid;
+ }
+
+ public void setUserid(String userid) {
+ this.userid = userid;
+ }
+
+ public long getVersion() {
+ return version;
+ }
+
+ protected void setId(int id) {
+ this.id = id;
+ }
+
+ protected void setVersion(long version) {
+ this.version = version;
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> T get(String attributeName) {
+ return (T) this.attributes.get(attributeName);
+ }
+
+ public Object set(String attributeName, Object value) {
+ return this.attributes.put(attributeName, value);
+ }
+
+ /**
+ * Determine if player instance is valid to be added to a team. This is true
+ * if the player has a number and both names.
+ *
+ * @return
+ */
+ public boolean isValid() {
+ if (getNumber() <= 0) {
+ return false;
+ }
+ if (getFirstName() == null || getFirstName().isEmpty()) {
+ return false;
+ }
+ if (getLastName() == null || getLastName().isEmpty()) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "Player [id=" + id + ", firstName=" + firstName + ", lastName=" + lastName + "]";
+ }
+
+}
diff --git a/mysports/application/src/main/java/eclipselink/example/mysports/application/model/Player_.java b/mysports/application/src/main/java/eclipselink/example/mysports/application/model/Player_.java
new file mode 100644
index 0000000..f03b13f
--- /dev/null
+++ b/mysports/application/src/main/java/eclipselink/example/mysports/application/model/Player_.java
@@ -0,0 +1,18 @@
+package eclipselink.example.mysports.application.model;
+
+import javax.annotation.Generated;
+import javax.persistence.metamodel.SingularAttribute;
+import javax.persistence.metamodel.StaticMetamodel;
+
+@Generated(value="Dali", date="2013-01-08T16:39:46.138-0500")
+@StaticMetamodel(Player.class)
+public class Player_ {
+ public static volatile SingularAttribute<Player, Integer> id;
+ public static volatile SingularAttribute<Player, String> userid;
+ public static volatile SingularAttribute<Player, String> firstName;
+ public static volatile SingularAttribute<Player, String> lastName;
+ public static volatile SingularAttribute<Player, String> email;
+ public static volatile SingularAttribute<Player, Team> team;
+ public static volatile SingularAttribute<Player, Integer> number;
+ public static volatile SingularAttribute<Player, Long> version;
+}
diff --git a/mysports/application/src/main/java/eclipselink/example/mysports/application/model/Team.java b/mysports/application/src/main/java/eclipselink/example/mysports/application/model/Team.java
new file mode 100644
index 0000000..c730bd6
--- /dev/null
+++ b/mysports/application/src/main/java/eclipselink/example/mysports/application/model/Team.java
@@ -0,0 +1,134 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.application.model;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.OneToMany;
+import javax.persistence.OrderBy;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+import javax.persistence.Version;
+
+import org.eclipse.persistence.annotations.Multitenant;
+import org.eclipse.persistence.annotations.TenantDiscriminatorColumn;
+
+import eclipselink.example.mysports.application.MySportsConfig;
+
+@Entity
+@Table(name = "MYS_TEAM")
+@NamedQueries({ @NamedQuery(name = "Team.findAll", query = "SELECT t FROM Team t ORDER BY t.name"), @NamedQuery(name = "Team.findByDivisionAndName", query = "SELECT t FROM Team t WHERE t.name = :NAME AND t.division.name = :DIV") })
+@Multitenant
+@TenantDiscriminatorColumn(name = "LEAGUE_ID", contextProperty = MySportsConfig.LEAGUE_CONTEXT, length = 5)
+public class Team implements Extensible {
+
+ @Id
+ @GeneratedValue
+ @Column(name = "ID")
+ private int id;
+
+ @Column(name = "NAME")
+ private String name;
+
+ @ManyToOne(fetch = FetchType.LAZY)
+ @JoinColumn(name = "DIVISION_ID")
+ private Division division;
+
+ @OneToMany(mappedBy = "team", cascade = CascadeType.ALL)
+ @OrderBy("number ASC")
+ private List<Player> players;
+
+ @Version
+ private long version;
+ @Transient
+ private Map<String, Object> attributes = new HashMap<String, Object>();
+
+ public Team() {
+ this.players = new ArrayList<Player>();
+ this.attributes = new HashMap<String, Object>();
+ }
+
+ public Team(String name) {
+ this();
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Division getDivision() {
+ return division;
+ }
+
+ public void setDivision(Division division) {
+ this.division = division;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ protected void setId(int id) {
+ this.id = id;
+ }
+
+ protected void setVersion(long version) {
+ this.version = version;
+ }
+
+ public List<Player> getPlayers() {
+ return players;
+ }
+
+ public long getVersion() {
+ return version;
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> T get(String attributeName) {
+ return (T) this.attributes.get(attributeName);
+ }
+
+ public Object set(String attributeName, Object value) {
+ return this.attributes.put(attributeName, value);
+ }
+
+ public void addPlayer(Player player) {
+ getPlayers().add(player);
+ player.setTeam(this);
+ }
+
+ @Override
+ public String toString() {
+ return "Team [id=" + id + ", name=" + name + "]";
+ }
+
+}
diff --git a/mysports/application/src/main/java/eclipselink/example/mysports/application/model/Team_.java b/mysports/application/src/main/java/eclipselink/example/mysports/application/model/Team_.java
new file mode 100644
index 0000000..dd38f30
--- /dev/null
+++ b/mysports/application/src/main/java/eclipselink/example/mysports/application/model/Team_.java
@@ -0,0 +1,16 @@
+package eclipselink.example.mysports.application.model;
+
+import javax.annotation.Generated;
+import javax.persistence.metamodel.ListAttribute;
+import javax.persistence.metamodel.SingularAttribute;
+import javax.persistence.metamodel.StaticMetamodel;
+
+@Generated(value="Dali", date="2013-01-08T16:39:46.140-0500")
+@StaticMetamodel(Team.class)
+public class Team_ {
+ public static volatile SingularAttribute<Team, Integer> id;
+ public static volatile SingularAttribute<Team, String> name;
+ public static volatile SingularAttribute<Team, Division> division;
+ public static volatile ListAttribute<Team, Player> players;
+ public static volatile SingularAttribute<Team, Long> version;
+}
diff --git a/mysports/application/src/main/java/eclipselink/example/mysports/application/model/User.java b/mysports/application/src/main/java/eclipselink/example/mysports/application/model/User.java
new file mode 100644
index 0000000..2342cdb
--- /dev/null
+++ b/mysports/application/src/main/java/eclipselink/example/mysports/application/model/User.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.application.model;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Entity
+@Table(name="MYS_USER")
+public class User {
+
+ @Id
+ @Column(name="USER_ID")
+ private String id;
+
+ private String firstName;
+
+ private String lastName;
+
+ private String email;
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+}
diff --git a/mysports/application/src/main/java/eclipselink/example/mysports/application/model/User_.java b/mysports/application/src/main/java/eclipselink/example/mysports/application/model/User_.java
new file mode 100644
index 0000000..afeafcd
--- /dev/null
+++ b/mysports/application/src/main/java/eclipselink/example/mysports/application/model/User_.java
@@ -0,0 +1,14 @@
+package eclipselink.example.mysports.application.model;
+
+import javax.annotation.Generated;
+import javax.persistence.metamodel.SingularAttribute;
+import javax.persistence.metamodel.StaticMetamodel;
+
+@Generated(value="Dali", date="2013-01-08T16:39:46.142-0500")
+@StaticMetamodel(User.class)
+public class User_ {
+ public static volatile SingularAttribute<User, String> id;
+ public static volatile SingularAttribute<User, String> firstName;
+ public static volatile SingularAttribute<User, String> lastName;
+ public static volatile SingularAttribute<User, String> email;
+}
diff --git a/mysports/application/src/main/java/eclipselink/example/mysports/application/services/LeagueRepository.java b/mysports/application/src/main/java/eclipselink/example/mysports/application/services/LeagueRepository.java
new file mode 100644
index 0000000..b4cce98
--- /dev/null
+++ b/mysports/application/src/main/java/eclipselink/example/mysports/application/services/LeagueRepository.java
@@ -0,0 +1,483 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.application.services;
+
+import static eclipselink.example.mysports.application.MySportsConfig.LEAGUE_CONTEXT;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.annotation.PreDestroy;
+import javax.ejb.PostActivate;
+import javax.ejb.PrePassivate;
+import javax.ejb.Remove;
+import javax.ejb.Stateful;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+import javax.persistence.TypedQuery;
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Predicate;
+import javax.persistence.criteria.Root;
+import javax.persistence.metamodel.Attribute;
+import javax.persistence.metamodel.ManagedType;
+import javax.persistence.metamodel.Metamodel;
+
+import org.eclipse.persistence.annotations.Multitenant;
+import org.eclipse.persistence.config.PersistenceUnitProperties;
+import org.eclipse.persistence.config.QueryHints;
+import org.eclipse.persistence.internal.jpa.metamodel.AttributeImpl;
+import org.eclipse.persistence.jpa.JpaHelper;
+import org.eclipse.persistence.logging.SessionLog;
+import org.eclipse.persistence.mappings.AttributeAccessor;
+import org.eclipse.persistence.queries.FetchGroup;
+import org.eclipse.persistence.sessions.server.Server;
+import org.eclipse.persistence.sessions.server.ServerSession;
+import org.eclipse.persistence.tools.schemaframework.SchemaManager;
+
+import eclipselink.example.mysports.application.MySportsConfig;
+import eclipselink.example.mysports.application.admin.AdminServerConnector;
+import eclipselink.example.mysports.application.admin.League;
+import eclipselink.example.mysports.application.admin.RESTAdminServerConnector;
+import eclipselink.example.mysports.application.model.Division;
+import eclipselink.example.mysports.application.model.Division_;
+import eclipselink.example.mysports.application.model.Player;
+import eclipselink.example.mysports.application.model.Player_;
+import eclipselink.example.mysports.application.model.Team;
+import eclipselink.example.mysports.application.model.Team_;
+import eclipselink.example.mysports.persistence.TenantPerEMFProvider;
+
+/**
+ * MySports Domain Model Repository providing simplified persistence facade for
+ * managing the application bootstrapped {@link EntityManagerFactory} that are
+ * tenant aware.
+ *
+ * @author dclarke
+ * @since EclipseLink 2.3.0
+ */
+@Stateful
+//@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
+public class LeagueRepository implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * TODO
+ */
+ public static final String PU_NAME = "mysports";
+
+ /**
+ * Current league being viewed. This value MUST be configured using
+ * {@link #setLeagueId(String)} before any persistence operations can be
+ * performed.
+ */
+ private String leagueId;
+
+ /**
+ * Current league's name
+ */
+ private String name;
+
+ /**
+ * Tenant specific {@link EntityManagerFactory} used to access application entities.
+ *
+ * @see TenantPerEMFProvider
+ * @see MySportsConfig#LEAGUE_CONTEXT
+ */
+ private transient EntityManagerFactory emf;
+
+ /**
+ * TODO
+ */
+ private AdminServerConnector adminConnector;
+
+ /**
+ * Cache the current division to simplify operations within the division.
+ */
+ private transient Division currentDivision;
+
+ protected LeagueRepository(AdminServerConnector adminConnector) {
+ super();
+ this.adminConnector = adminConnector;
+ }
+
+ public LeagueRepository() {
+ this(new RESTAdminServerConnector());
+ }
+
+ public String getLeagueId() {
+ return this.leagueId;
+ }
+
+ public String getName() {
+ if (this.name == null) {
+ return getLeagueId();
+ }
+ return name;
+ }
+
+ public AdminServerConnector getAdminConnector() {
+ return adminConnector;
+ }
+
+ /**
+ * Initialize this repository for a specific tenant. This method must be
+ * called before accessing any of the other methods.
+ *
+ * @param leagueId
+ * @param properties
+ */
+ public void setLeagueId(String leagueId, Map<String, Object> properties) {
+ League league = null;
+
+ if (leagueId != null && !leagueId.isEmpty()) {
+ league = getAdminConnector().getLeague(leagueId);
+ }
+ if (league == null) {
+ throw new IllegalArgumentException("Invalid league identifier: " + leagueId);
+ }
+
+ this.name = league.getName();
+
+ if (this.emf == null || !leagueId.equals(getLeagueId())) {
+ Map<String, Object> props = properties;
+ if (props == null) {
+ props = new HashMap<String, Object>();
+ }
+
+ // Override with the league specific data source if the properties
+ // does not include one.
+ if (!props.containsKey(PersistenceUnitProperties.NON_JTA_DATASOURCE)) {
+ props.put(PersistenceUnitProperties.NON_JTA_DATASOURCE, league.getDatasource());
+ }
+
+ createEMF(leagueId, props);
+ } else {
+ Long preValue = (Long) JpaHelper.getServerSession(getEMF()).getProperty("league-version");
+
+ // Check to see if the league version has changed
+ if (preValue != null && preValue.longValue() < league.getVersion()) {
+ // Create a new EMF
+ createEMF(leagueId, properties);
+ // Refresh the new EMF's metadata
+ JpaHelper.getEntityManagerFactory(getEMF()).refreshMetadata(properties);
+ }
+ }
+ JpaHelper.getServerSession(getEMF()).setProperty("league-version", league.getVersion());
+ }
+
+ public boolean hasLeague() {
+ return getLeagueId() != null;
+ }
+
+ /**
+ * Retrieve all of the divisions in this league and optionally force the
+ * lazily loaded teams to be returned within the {@link Division}s.
+ */
+ public List<Division> getDivisions() {
+ EntityManager em = getEMF().createEntityManager();
+
+ try {
+ TypedQuery<Division> q = em.createNamedQuery("Division.findAll", Division.class);
+ return q.getResultList();
+ } finally {
+ em.close();
+ }
+ }
+
+ public Division getCurrentDivision() {
+ return currentDivision;
+ }
+
+ public void setCurrentDivision(Division currentDivision) {
+ this.currentDivision = currentDivision;
+ }
+
+ public <T> T find(Class<T> entityClass, int id) {
+ EntityManager em = getEMF().createEntityManager();
+
+ try {
+ return em.find(entityClass, id);
+ } finally {
+ em.close();
+ }
+ }
+
+ public Division addDivision(String name) {
+ EntityManager em = getEMF().createEntityManager();
+
+ try {
+ em.getTransaction().begin();
+ Division div = new Division(name);
+ em.persist(div);
+ em.getTransaction().commit();
+ return div;
+ } finally {
+ em.close();
+ }
+ }
+
+ public Team addTeam(String name, List<Player> players, Division division) {
+ EntityManager em = getEMF().createEntityManager();
+ Division div = division == null ? getCurrentDivision() : division;
+
+ try {
+ em.getTransaction().begin();
+
+ Division managedDiv = em.merge(div);
+ Team team = new Team(name);
+ if (players != null) {
+ for (Player player : players) {
+ team.addPlayer(player);
+ }
+ }
+ em.persist(team);
+ managedDiv.addTeam(team);
+
+ em.getTransaction().commit();
+
+ this.currentDivision = managedDiv;
+ return team;
+ } finally {
+ em.close();
+ }
+ }
+
+ public Team mergeTeam(Team team) {
+ EntityManager em = getEMF().createEntityManager();
+
+ try {
+ em.getTransaction().begin();
+
+ Team managedTeam = em.merge(team);
+
+ em.getTransaction().commit();
+
+ this.currentDivision = managedTeam.getDivision();
+ return managedTeam;
+ } finally {
+ em.close();
+ }
+ }
+
+ public Division getDivision(String name) {
+ EntityManager em = getEMF().createEntityManager();
+
+ try {
+ TypedQuery<Division> q = em.createNamedQuery("Division.findByName", Division.class);
+ q.setParameter("NAME", name);
+
+ // Specify that all teams and all team's players should be loaded
+ FetchGroup fg = new FetchGroup();
+ fg.addAttribute("teams.players");
+ fg.setShouldLoadAll(true);
+ q.setHint(QueryHints.FETCH_GROUP, fg);
+
+ return q.getSingleResult();
+ } finally {
+ em.close();
+ }
+ }
+
+ public Team getTeam(String division, String name) {
+ EntityManager em = getEMF().createEntityManager();
+
+ try {
+ TypedQuery<Team> q = em.createNamedQuery("Team.findByDivisionAndName", Team.class);
+ q.setParameter("DIV", division);
+ q.setParameter("NAME", name);
+ return q.getSingleResult();
+ } finally {
+ em.close();
+ }
+ }
+
+ /**
+ * Retrieve a player using its division, team name, and jersey number using
+ * JPA 2.0 criteria.
+ */
+ public Player getPlayerByNumber(String division, String teamId, int number) {
+ EntityManager em = getEMF().createEntityManager();
+
+ try {
+ CriteriaBuilder qb = em.getCriteriaBuilder();
+ CriteriaQuery<Player> query = qb.createQuery(Player.class);
+ Root<Player> player = query.from(Player.class);
+ Predicate numEqual = qb.equal(player.get(Player_.number), number);
+ Predicate teamEqual = qb.equal(player.get(Player_.team).get(Team_.name), teamId);
+ Predicate divEqual = qb.equal(player.get(Player_.team).get(Team_.division).get(Division_.name), division);
+ query.where(qb.and(numEqual, teamEqual, divEqual));
+ return em.createQuery(query).getSingleResult();
+ } finally {
+ em.close();
+ }
+ }
+
+ public void remove(Object entity) {
+ EntityManager em = getEMF().createEntityManager();
+
+ try {
+ Object managedEntity = em.merge(entity);
+
+ em.getTransaction().begin();
+ em.remove(managedEntity);
+ em.getTransaction().commit();
+ } finally {
+ em.close();
+ }
+ }
+
+ /*
+ * JPA API
+ */
+
+ /**
+ * @throws IllegalStateException
+ * if the
+ */
+ protected EntityManagerFactory getEMF() {
+ if (this.emf == null) {
+ throw new IllegalStateException("LeagueRepository not initialized");
+ }
+ return this.emf;
+ }
+
+ /**
+ * Determine which mapped attributes are virtual/extended attributes. Used
+ * to provide dynamic access to these attributes in presentation layer.
+ *
+ * @return list of extended (virtual) JPA meta-model attributes
+ * @throws IllegalArgumentException
+ * if entityType is not a managed type
+ */
+ public List<Attribute<?, ?>> getAdditionalAttributes(Class<?> entityType) {
+ Metamodel metamodel = getEMF().getMetamodel();
+ ManagedType<?> type = metamodel.managedType(entityType);
+ List<Attribute<?, ?>> addnAttrs = new ArrayList<Attribute<?, ?>>();
+
+ for (Attribute<?, ?> attr : type.getAttributes()) {
+ AttributeImpl<?, ?> attrImpl = (AttributeImpl<?, ?>) attr;
+ AttributeAccessor accessor = attrImpl.getMapping().getAttributeAccessor();
+ if (accessor.isVirtualAttributeAccessor()) {
+ addnAttrs.add(attr);
+ }
+ }
+
+ return addnAttrs;
+ }
+
+ /**
+ * Provide access to internals of repository similar to
+ * {@link EntityManager#unwrap(Class)}. Provided for access to advanced
+ * capabilities of the underlying EclipseLink persistence unit as well as
+ * for testing access to internals.
+ */
+ @SuppressWarnings("unchecked")
+ public <T> T unwrap(Class<T> cls) {
+ if (EntityManagerFactory.class.equals(cls)) {
+ return (T) getEMF();
+ } else if (cls.equals(Server.class) || cls.equals(ServerSession.class)) {
+ return (T) JpaHelper.getServerSession(getEMF());
+ } else if (cls.equals(SchemaManager.class)) {
+ return (T) new SchemaManager(JpaHelper.getServerSession(getEMF()));
+ }
+ throw new RuntimeException("LeagueRepository cannot be unwrapped to: " + cls);
+ }
+
+ /**
+ * Close this league repository forcing the underlying
+ * {@link EntityManagerFactory} to be closed as well.
+ */
+ @PreDestroy
+ @PrePassivate
+ @Remove
+ public void close() {
+ if (this.emf != null && this.emf.isOpen()) {
+ this.emf.close();
+ }
+ this.emf = null;
+ this.currentDivision = null;
+ this.leagueId = null;
+ }
+
+ /**
+ * After the stateful session bean is activated after passivation the
+ * {@link #createEMF(String, Map)}is called with the stored
+ * {@link #leagueId} to populate the persistence state necessary for use.
+ */
+ @PostActivate
+ public void initialize() {
+ createEMF(getLeagueId(), null);
+ }
+
+ /**
+ * Create the league (tenant) specific {@link EntityManagerFactory}. In
+ * order to use the same persistence unit definition (persistence.xml) as a
+ * template the {@link PersistenceUnitProperties#SESSION_NAME} property is
+ * supplied to indicate that the backing shared EclipseLink session should
+ * be cached based on the league identifier.
+ *
+ * The {@value MySportsConfig#LEAGUE_CONTEXT} property is supplied to
+ * indicate the required context property as required by the use of
+ * {@link Multitenant} on the persistent entities.
+ *
+ * @param leagueId
+ * league (tenant) identifier
+ * @param properties
+ * additional {@link EntityManagerFactory} properties.
+ */
+ protected void createEMF(String leagueId, Map<String, Object> properties) {
+ Map<String, Object> emfProps = new HashMap<String, Object>();
+
+ if (properties != null) {
+ emfProps.putAll(properties);
+ }
+
+ emfProps.put(LEAGUE_CONTEXT, leagueId);
+
+ String puName = MySportsConfig.PU_NAME;
+ if (leagueId != null && !"ALL".equals(leagueId)) {
+ puName = getSessionName(leagueId);
+ }
+
+ this.emf = Persistence.createEntityManagerFactory(puName, emfProps);
+ this.leagueId = leagueId;
+
+ // Clear cached state
+ setCurrentDivision(null);
+
+ Server session = JpaHelper.getServerSession(getEMF());
+ session.getSessionLog().log(SessionLog.CONFIG, "LeagueRepository[" + hashCode() + "] initialized with session named: " + session.getName());
+ }
+
+ public String getSessionName(String leagueId) {
+ if (isMultitenant()) {
+ if (leagueId == null || leagueId.isEmpty()) {
+ throw new IllegalArgumentException("Multitenant instance requires leagueId");
+ }
+ return PU_NAME + ";league=" + leagueId;
+ }
+ return null;
+ }
+
+ /*
+ * TODO - make it possible for the app to be deployed with a single fixed tenant
+ */
+ public boolean isMultitenant() {
+ return true;
+ }
+
+}
diff --git a/mysports/application/src/main/java/eclipselink/example/mysports/application/services/PersistenceWeavingBean.java b/mysports/application/src/main/java/eclipselink/example/mysports/application/services/PersistenceWeavingBean.java
new file mode 100644
index 0000000..813d1f2
--- /dev/null
+++ b/mysports/application/src/main/java/eclipselink/example/mysports/application/services/PersistenceWeavingBean.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.application.services;
+
+import javax.ejb.Singleton;
+import javax.ejb.Startup;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceUnit;
+
+import eclipselink.example.mysports.application.MySportsConfig;
+
+
+/**
+ * This utility class will cause the container to weave the persistence unit.
+ * Since the {@link LeagueRepository} uses the persistence unit through the
+ * application bootstrap API the container will not instrument/weave the entity
+ * classes. This class is ONLY required in the application to force the weaving
+ * to occur.
+ *
+ * @author dclarke
+ * @since EclipseLink 2.3.0
+ */
+@Startup
+@Singleton
+public class PersistenceWeavingBean {
+
+ @PersistenceUnit(unitName = MySportsConfig.PU_NAME)
+ private EntityManagerFactory emf;
+
+}
diff --git a/mysports/application/src/main/java/eclipselink/example/mysports/application/view/BaseManagedBean.java b/mysports/application/src/main/java/eclipselink/example/mysports/application/view/BaseManagedBean.java
new file mode 100644
index 0000000..3a8889b
--- /dev/null
+++ b/mysports/application/src/main/java/eclipselink/example/mysports/application/view/BaseManagedBean.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.application.view;
+
+import javax.faces.bean.ManagedProperty;
+
+import eclipselink.example.mysports.application.services.LeagueRepository;
+
+/**
+ * Common managed bean to provide access required across the application.
+ *
+ * @author dclarke
+ * @since EclipseLink 2.3.0
+ */
+public abstract class BaseManagedBean {
+
+ @ManagedProperty(value = "#{leagueRepositoryBean}")
+ private LeagueRepositoryBean repositoryBean;
+
+ public LeagueRepositoryBean getRepositoryBean() {
+ return repositoryBean;
+ }
+
+ public void setRepositoryBean(LeagueRepositoryBean repositoryBean) {
+ this.repositoryBean = repositoryBean;
+ }
+
+ public LeagueRepository getRepository() {
+ return getRepositoryBean().getRepository();
+ }
+
+ public String getLeagueId() {
+ return getRepository().getLeagueId();
+ }
+
+ public boolean isMultitenant() {
+ return getRepositoryBean().getRepository().isMultitenant();
+ }
+
+ public String home() {
+ return LeaguesList.PAGE;
+ }
+
+}
diff --git a/mysports/application/src/main/java/eclipselink/example/mysports/application/view/BaseTeamBean.java b/mysports/application/src/main/java/eclipselink/example/mysports/application/view/BaseTeamBean.java
new file mode 100644
index 0000000..4058df7
--- /dev/null
+++ b/mysports/application/src/main/java/eclipselink/example/mysports/application/view/BaseTeamBean.java
@@ -0,0 +1,193 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.application.view;
+
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.el.ValueExpression;
+import javax.faces.application.FacesMessage;
+import javax.faces.component.html.HtmlColumn;
+import javax.faces.component.html.HtmlDataTable;
+import javax.faces.component.html.HtmlInputText;
+import javax.faces.component.html.HtmlOutputText;
+import javax.faces.context.FacesContext;
+import javax.persistence.metamodel.Attribute;
+import javax.servlet.http.HttpServletRequest;
+
+import eclipselink.example.mysports.application.model.Division;
+import eclipselink.example.mysports.application.model.Player;
+import eclipselink.example.mysports.application.model.Team;
+import eclipselink.example.mysports.application.services.LeagueRepository;
+
+/**
+ * Base managed bean for Team operations.
+ *
+ * @author dclarke
+ * @since EclipseLink 2.3.0
+ */
+public abstract class BaseTeamBean extends BaseManagedBean {
+
+ private Team team;
+
+ private List<ExtensibleEntity<Player>> players;
+
+ private HtmlDataTable dataTable;
+
+ /**
+ * Default page that will be navigated to on successful call to
+ * {@link #setTeam())}
+ */
+ public abstract String getPage();
+
+ public String getPage(String pageName) {
+ return pageName + "?faces-redirect=true";
+ }
+
+ public Division getCurrentDivision() {
+ return getRepository().getCurrentDivision();
+ }
+
+ public Team getTeam() {
+ return this.team;
+ }
+
+ protected void setTeam(Team team) {
+ this.team = team;
+ this.dataTable = null;
+
+ this.players = new ArrayList<ExtensibleEntity<Player>>();
+ for (Player player : getTeam().getPlayers()) {
+ this.players.add(new ExtensibleEntity<Player>(player));
+ }
+ }
+
+ public String setTeam() {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ HttpServletRequest myRequest = (HttpServletRequest) facesContext.getExternalContext().getRequest();
+ String value = myRequest.getParameter("team-id");
+ if (value != null && !value.isEmpty()) {
+ Team newTeam = getRepository().find(Team.class, Integer.valueOf(value));
+ if (newTeam == null) {
+ facesContext.addMessage(null, new FacesMessage("No Team found for id: " + value));
+ return null;
+ }
+ setTeam(newTeam);
+ }
+
+ return getPage();
+ }
+
+ public List<ExtensibleEntity<Player>> getPlayers() {
+ return this.players;
+ }
+
+ public abstract HtmlDataTable getDataTable();
+
+ /**
+ * Construct a data table for {@link Player} including its extended attributes.
+ *
+ * @see LeagueRepository#getAdditionalAttributes(Class)
+ */
+ public HtmlDataTable getDataTable(String beanName, boolean writeable) {
+ if (this.dataTable == null) {
+ HtmlDataTable table = new HtmlDataTable();
+ table.setValueExpression("value", createValueExpression("#{" + beanName + ".players}", List.class));
+ table.setVar("player");
+ table.setWidth("100%");
+ table.setBorder(1);
+ table.setStyleClass("pretty");
+
+ addColumn(table, "Number", "#{player.entity.number}", Integer.class, writeable);
+ addColumn(table, "First Name", "#{player.entity.firstName}", String.class, writeable);
+ addColumn(table, "Last Name", "#{player.entity.lastName}", String.class, writeable);
+
+ for (Attribute<?, ?> attr : getRepository().getAdditionalAttributes(Player.class)) {
+ addColumn(table, label(attr.getName()), "#{player.get('" + attr.getName() + "').value}", attr.getJavaType(), writeable);
+ }
+
+ this.dataTable = table;
+ }
+ return this.dataTable;
+ }
+
+ public void setDataTable(HtmlDataTable dataTable) {
+ this.dataTable = dataTable;
+ }
+
+ /**
+ * Helper method to add a column to the {@link #dataTable}
+ */
+ private void addColumn(HtmlDataTable table, String name, String valueExpression, Class<?> valueType, boolean writeable) {
+ HtmlColumn column = new HtmlColumn();
+ table.getChildren().add(column);
+
+ HtmlOutputText header = new HtmlOutputText();
+ header.setValue(name);
+ column.setHeader(header);
+
+ if (writeable) {
+ HtmlInputText input = new HtmlInputText();
+ input.setValueExpression("value", createValueExpression(valueExpression, valueType));
+ column.getChildren().add(input);
+ } else {
+ HtmlOutputText output = new HtmlOutputText();
+ output.setValueExpression("value", createValueExpression(valueExpression, valueType));
+ column.getChildren().add(output);
+ }
+ }
+
+ private ValueExpression createValueExpression(String valueExpression, Class<?> valueType) {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ return facesContext.getApplication().getExpressionFactory().createValueExpression(facesContext.getELContext(), valueExpression, valueType);
+ }
+
+ /**
+ * Convert attributeName into String name based on Camel casing
+ */
+ public static String label(String attrName) {
+ if (attrName == null || attrName.isEmpty()) {
+ return attrName;
+ }
+
+ String name = attrName.substring(0, 1).toUpperCase() + attrName.substring(1);
+
+ String[] lowerSegements = name.split("[A-Z_]");
+ String[] upperStrings = name.split("[a-z_]");
+
+ StringWriter writer = new StringWriter();
+ int upperIndex = 0;
+ int lowerIndex = 0;
+
+ writer.write(upperStrings[upperIndex++]);
+
+ while (lowerIndex < lowerSegements.length) {
+ if (lowerSegements[lowerIndex].isEmpty()) {
+ lowerIndex++;
+ } else {
+ writer.write(lowerSegements[lowerIndex++]);
+ writer.write(" ");
+
+ while (upperIndex < upperStrings.length && upperStrings[upperIndex].isEmpty()) {
+ upperIndex++;
+ }
+ if (upperIndex < upperStrings.length) {
+ writer.write(upperStrings[upperIndex++]);
+ }
+ }
+ }
+
+ return writer.toString().trim();
+ }
+}
diff --git a/mysports/application/src/main/java/eclipselink/example/mysports/application/view/CreateDivision.java b/mysports/application/src/main/java/eclipselink/example/mysports/application/view/CreateDivision.java
new file mode 100644
index 0000000..f3510ea
--- /dev/null
+++ b/mysports/application/src/main/java/eclipselink/example/mysports/application/view/CreateDivision.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.application.view;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.RequestScoped;
+import javax.faces.context.FacesContext;
+
+import eclipselink.example.mysports.application.model.Division;
+
+/**
+ * Managed JSF bean used to create a new {@link Division}
+ *
+ * @author dclarke
+ * @since EclipseLink 2.3.0
+ */
+@ManagedBean
+@RequestScoped
+public class CreateDivision extends BaseManagedBean {
+
+ private String name;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String create() {
+ FacesContext facesCtxt = FacesContext.getCurrentInstance();
+
+ if (getName() == null || getName().isEmpty()) {
+ facesCtxt.addMessage(null, new FacesMessage("Invalid Name"));
+ return null;
+ }
+
+ getRepository().addDivision(getName());
+ return cancel();
+ }
+
+ public String cancel() {
+ return ViewLeague.PAGE + "?faces-redirect=true";
+ }
+}
diff --git a/mysports/application/src/main/java/eclipselink/example/mysports/application/view/CreateTeam.java b/mysports/application/src/main/java/eclipselink/example/mysports/application/view/CreateTeam.java
new file mode 100644
index 0000000..a2da175
--- /dev/null
+++ b/mysports/application/src/main/java/eclipselink/example/mysports/application/view/CreateTeam.java
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.application.view;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.SessionScoped;
+import javax.faces.component.html.HtmlDataTable;
+import javax.faces.context.FacesContext;
+
+import eclipselink.example.mysports.application.model.Player;
+import eclipselink.example.mysports.application.model.Team;
+
+/**
+ * JSF managed bean used to create a new {@link Team}. An empty {@link Team}
+ * instance is created and used as the target in the {@link BaseTeamBean} with a
+ * default set of empty {@link Player}
+ *
+ * @author dclarke
+ * @since EclipseLink 2.3.0
+ */
+@ManagedBean(name = CreateTeam.NAME)
+@SessionScoped
+public class CreateTeam extends BaseTeamBean {
+
+ protected static final String NAME = "createTeam";
+
+ protected static final String PAGE = "create-team?faces-redirect=true";
+
+ @Override
+ public String getPage() {
+ return PAGE;
+ }
+
+ @Override
+ public HtmlDataTable getDataTable() {
+ return getDataTable(NAME, true);
+ }
+
+ @Override
+ public String setTeam() {
+ Team team = new Team();
+ team.setName("");
+ team.setDivision(getRepository().getCurrentDivision());
+ team.getPlayers().clear();
+ for (int index = 0; index < 12; index++) {
+ team.addPlayer(new Player());
+ }
+ setTeam(team);
+ return getPage();
+ }
+
+ public String create() {
+ return setTeam();
+ }
+
+ public String save() {
+ FacesContext facesCtxt = FacesContext.getCurrentInstance();
+
+ if (getTeam().getName() == null || getTeam().getName().isEmpty()) {
+ facesCtxt.addMessage(null, new FacesMessage("Invalid team Name"));
+ }
+
+ List<Player> validPlayers = getValidPlayers();
+ if (validPlayers.isEmpty()) {
+ facesCtxt.addMessage(null, new FacesMessage("Must have at least one player"));
+ }
+
+ if (!facesCtxt.getMessageList().isEmpty()) {
+ return null;
+ }
+
+ getRepository().addTeam(getTeam().getName(), getValidPlayers(), null);
+ return ViewDivision.PAGE;
+ }
+
+ /**
+ * @return a list of players who have numbers and names
+ */
+ private List<Player> getValidPlayers() {
+ List<Player> validPlayers = new ArrayList<Player>();
+ for (Player player : getTeam().getPlayers()) {
+ if (player.isValid()) {
+ validPlayers.add(player);
+ }
+ }
+ return validPlayers;
+ }
+
+}
diff --git a/mysports/application/src/main/java/eclipselink/example/mysports/application/view/EditDivision.java b/mysports/application/src/main/java/eclipselink/example/mysports/application/view/EditDivision.java
new file mode 100644
index 0000000..f9fe711
--- /dev/null
+++ b/mysports/application/src/main/java/eclipselink/example/mysports/application/view/EditDivision.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.application.view;
+
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.RequestScoped;
+import javax.faces.context.FacesContext;
+import javax.servlet.http.HttpServletRequest;
+
+import eclipselink.example.mysports.application.model.Division;
+
+/**
+ *
+ * @author dclarke
+ * @since EclipseLink 2.3
+ */
+@ManagedBean
+@RequestScoped
+public class EditDivision extends BaseManagedBean {
+
+ protected static final String PAGE = "edit-division";
+
+ public Division getDivision() {
+ return getRepository().getCurrentDivision();
+ }
+
+ public String edit() {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ HttpServletRequest myRequest = (HttpServletRequest) facesContext.getExternalContext().getRequest();
+ String value = myRequest.getParameter("division-id");
+
+ if (value != null && !value.isEmpty()) {
+ Division div = getRepository().find(Division.class, Integer.valueOf(value));
+ getRepository().setCurrentDivision(div);
+ }
+
+ return PAGE;
+ }
+
+ public String save() {
+ return null;
+ }
+
+ public String cancel() {
+ return ViewDivision.PAGE;
+ }
+}
diff --git a/mysports/application/src/main/java/eclipselink/example/mysports/application/view/EditTeam.java b/mysports/application/src/main/java/eclipselink/example/mysports/application/view/EditTeam.java
new file mode 100644
index 0000000..b056294
--- /dev/null
+++ b/mysports/application/src/main/java/eclipselink/example/mysports/application/view/EditTeam.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.application.view;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.ManagedProperty;
+import javax.faces.bean.SessionScoped;
+import javax.faces.component.html.HtmlDataTable;
+import javax.faces.context.FacesContext;
+
+import eclipselink.example.mysports.application.model.Team;
+
+@ManagedBean(name = EditTeam.NAME)
+@SessionScoped
+public class EditTeam extends BaseTeamBean {
+
+ protected static final String PAGE = "edit-team?faces-redirect=true";
+
+ protected static final String NAME = "editTeam";
+
+ @ManagedProperty(value = "#{viewTeam}")
+ private ViewTeam viewTeam;
+
+ @Override
+ public String getPage() {
+ return PAGE;
+ }
+
+ @Override
+ public HtmlDataTable getDataTable() {
+ return getDataTable(NAME, true);
+ }
+
+ public ViewTeam getViewTeam() {
+ return viewTeam;
+ }
+
+ public void setViewTeam(ViewTeam viewTeam) {
+ this.viewTeam = viewTeam;
+ }
+
+ public String save() {
+ FacesContext facesCtxt = FacesContext.getCurrentInstance();
+
+ if (getTeam().getName() == null || getTeam().getName().isEmpty()) {
+ facesCtxt.addMessage(null, new FacesMessage("Invalid Team Name"));
+ return null;
+ }
+
+ Team team = getRepository().mergeTeam(getTeam());
+ getViewTeam().setTeam(team);
+
+ return ViewTeam.PAGE;
+ }
+
+ public String cancel() {
+ return ViewTeam.PAGE;
+ }
+}
diff --git a/mysports/application/src/main/java/eclipselink/example/mysports/application/view/ExtensibleEntity.java b/mysports/application/src/main/java/eclipselink/example/mysports/application/view/ExtensibleEntity.java
new file mode 100644
index 0000000..9d84e9d
--- /dev/null
+++ b/mysports/application/src/main/java/eclipselink/example/mysports/application/view/ExtensibleEntity.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.application.view;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import eclipselink.example.mysports.application.model.Extensible;
+
+/**
+ * {@link Extensible} type wrapper used in JSF pages to allow access to the
+ * extended attributes through standard JSP EL.
+ * <p>
+ * Static Attribute: #{player.entity.firstName}
+ * <p>
+ * Extended Attribute: #{player.get('middleName').value}
+ *
+ * @author dclarke
+ * @since EclipseLink 2.3.0
+ */
+public class ExtensibleEntity<T> {
+
+ private Extensible entity;
+
+ private Map<String, AttributeValue> values;
+
+ public ExtensibleEntity(Extensible entity) {
+ this.entity = entity;
+ this.values = new HashMap<String, AttributeValue>();
+ }
+
+ @SuppressWarnings("unchecked")
+ public T getEntity() {
+ return (T) entity;
+ }
+
+ public AttributeValue get(String attributeName) {
+ AttributeValue value = this.values.get(attributeName);
+ if (value == null) {
+ value = new AttributeValue(attributeName);
+ this.values.put(attributeName, value);
+ }
+ return value;
+ }
+
+ public class AttributeValue {
+
+ private String attribute;
+
+ AttributeValue(String attribute) {
+ this.attribute = attribute;
+ }
+
+ String getAttributeName() {
+ return attribute;
+ }
+
+ public Object getValue() {
+ return ExtensibleEntity.this.entity.get(getAttributeName());
+ }
+
+ public void setValue(Object value) {
+ ExtensibleEntity.this.entity.set(getAttributeName(), value);
+ }
+ }
+
+}
diff --git a/mysports/application/src/main/java/eclipselink/example/mysports/application/view/LeagueRepositoryBean.java b/mysports/application/src/main/java/eclipselink/example/mysports/application/view/LeagueRepositoryBean.java
new file mode 100644
index 0000000..39bb396
--- /dev/null
+++ b/mysports/application/src/main/java/eclipselink/example/mysports/application/view/LeagueRepositoryBean.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.application.view;
+
+import javax.ejb.EJB;
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.SessionScoped;
+import javax.faces.context.FacesContext;
+import javax.servlet.http.HttpServletRequest;
+
+import eclipselink.example.mysports.application.services.LeagueRepository;
+
+/**
+ * JSF session scoped managed bean which looks after access to the stateful
+ * {@link LeagueRepository} EJB.
+ *
+ * @author dclarke
+ * @since EclipseLink 2.3.0
+ */
+@ManagedBean
+@SessionScoped
+public class LeagueRepositoryBean {
+
+ @EJB
+ private LeagueRepository repository;
+
+ public LeagueRepository getRepository() {
+ return repository;
+ }
+
+ public void setRepository(LeagueRepository repository) {
+ this.repository = repository;
+ }
+
+ public String setLeague() {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ HttpServletRequest myRequest = (HttpServletRequest) facesContext.getExternalContext().getRequest();
+ String value = myRequest.getParameter("league");
+
+ getRepository().setLeagueId(value, null);
+ if (!getRepository().hasLeague()) {
+ return "index?faces-redirect=true";
+ }
+
+ return "view-league?faces-redirect=true";
+ }
+
+ public String getLeagueId() {
+ return getRepository().getLeagueId();
+ }
+
+ public String getLeagueName() {
+ return getRepository().getName();
+ }
+
+ public boolean hasLeague() {
+ return getRepository().hasLeague();
+ }
+
+}
diff --git a/mysports/application/src/main/java/eclipselink/example/mysports/application/view/LeaguesList.java b/mysports/application/src/main/java/eclipselink/example/mysports/application/view/LeaguesList.java
new file mode 100644
index 0000000..03b825f
--- /dev/null
+++ b/mysports/application/src/main/java/eclipselink/example/mysports/application/view/LeaguesList.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.application.view;
+
+import javax.faces.bean.ManagedBean;
+
+import eclipselink.example.mysports.application.admin.HostedLeagues;
+
+/**
+ * Return list of available Leagues from JAX-RS call to MySports Admin app.
+ *
+ * @author dclarke
+ * @since EclipseLink 2.3.0
+ */
+@ManagedBean
+public class LeaguesList extends BaseManagedBean {
+
+ protected static final String PAGE = "index";
+
+ private HostedLeagues leagues;
+
+ public HostedLeagues getLeagues() {
+ if (this.leagues == null) {
+ this.leagues = getRepositoryBean().getRepository().getAdminConnector().getLeagues();
+ }
+ return this.leagues;
+ }
+}
diff --git a/mysports/application/src/main/java/eclipselink/example/mysports/application/view/LookAndFeel.java b/mysports/application/src/main/java/eclipselink/example/mysports/application/view/LookAndFeel.java
new file mode 100644
index 0000000..1b9111a
--- /dev/null
+++ b/mysports/application/src/main/java/eclipselink/example/mysports/application/view/LookAndFeel.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.application.view;
+
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.SessionScoped;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+
+/**
+ * JSF managed bean used to provide custom the look and feel of the UI in a
+ * league specific manner
+ *
+ * @author dclarke
+ * @since EclipseLink 2.3.0
+ */
+@ManagedBean
+@SessionScoped
+public class LookAndFeel extends BaseManagedBean {
+
+ private String adminServerURL;
+
+ private String getAdminServerURL() {
+ if (this.adminServerURL == null) {
+ ExternalContext ctxt = FacesContext.getCurrentInstance().getExternalContext();
+
+ this.adminServerURL = ctxt.getRequestScheme() + "://" + ctxt.getRequestServerName() + ":" + ctxt.getRequestServerPort();
+ this.adminServerURL += "/MySportsAdmin/rest/league"; // TODO
+ }
+ return this.adminServerURL;
+ }
+
+ public String getCss() {
+ return getAdminServerURL() + "/" + getLeagueId() + ".css";
+ }
+
+ public String getLogo() {
+ return getAdminServerURL() + "/" + getLeagueId() + ".png";
+ }
+
+}
diff --git a/mysports/application/src/main/java/eclipselink/example/mysports/application/view/MySportsPhaseListener.java b/mysports/application/src/main/java/eclipselink/example/mysports/application/view/MySportsPhaseListener.java
new file mode 100644
index 0000000..e96fcbc
--- /dev/null
+++ b/mysports/application/src/main/java/eclipselink/example/mysports/application/view/MySportsPhaseListener.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.application.view;
+
+import java.io.IOException;
+
+import javax.faces.context.FacesContext;
+import javax.faces.event.PhaseEvent;
+import javax.faces.event.PhaseId;
+import javax.faces.event.PhaseListener;
+
+public class MySportsPhaseListener implements PhaseListener {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void afterPhase(PhaseEvent event) {
+ FacesContext facesContext = event.getFacesContext();
+ if(facesContext.getViewRoot()==null){
+ try{
+ facesContext.getExternalContext().redirect("/");
+ facesContext.responseComplete();
+ } catch (IOException e){
+ e.printStackTrace();
+ }
+ }
+ }
+
+ @Override
+ public void beforePhase(PhaseEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public PhaseId getPhaseId() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/mysports/application/src/main/java/eclipselink/example/mysports/application/view/NoCacheFilter.java b/mysports/application/src/main/java/eclipselink/example/mysports/application/view/NoCacheFilter.java
new file mode 100644
index 0000000..0ddd6b4
--- /dev/null
+++ b/mysports/application/src/main/java/eclipselink/example/mysports/application/view/NoCacheFilter.java
@@ -0,0 +1,51 @@
+package eclipselink.example.mysports.application.view;
+
+import java.io.IOException;
+
+import javax.faces.application.ResourceHandler;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.annotation.WebFilter;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebFilter(servletNames = { "Faces Servlet" })
+// Must match <servlet-name> of your FacesServlet.
+public class NoCacheFilter implements Filter {
+
+ @Override
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
+ HttpServletRequest req = (HttpServletRequest) request;
+ HttpServletResponse res = (HttpServletResponse) response;
+
+ if (!req.getRequestURI().startsWith(req.getContextPath() + ResourceHandler.RESOURCE_IDENTIFIER)) { // Skip
+ // JSF
+ // resources
+ // (CSS/JS/Images/etc)
+ res.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP
+ // 1.1.
+ res.setHeader("Pragma", "no-cache"); // HTTP 1.0.
+ res.setDateHeader("Expires", 0); // Proxies.
+ }
+
+ chain.doFilter(request, response);
+ }
+
+ @Override
+ public void destroy() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void init(FilterConfig arg0) throws ServletException {
+ // TODO Auto-generated method stub
+
+ }
+
+ // ...
+}
diff --git a/mysports/application/src/main/java/eclipselink/example/mysports/application/view/ViewDivision.java b/mysports/application/src/main/java/eclipselink/example/mysports/application/view/ViewDivision.java
new file mode 100644
index 0000000..b32886c
--- /dev/null
+++ b/mysports/application/src/main/java/eclipselink/example/mysports/application/view/ViewDivision.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.application.view;
+
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.RequestScoped;
+import javax.faces.context.FacesContext;
+import javax.servlet.http.HttpServletRequest;
+
+import eclipselink.example.mysports.application.model.Division;
+
+/**
+ * JSF managed bean to view a division with its teams.
+ *
+ * @author dclarke
+ * @since EclipseLink 2.3.0
+ */
+@ManagedBean
+@RequestScoped
+public class ViewDivision extends BaseManagedBean {
+
+ protected static final String PAGE = "view-division";
+
+ public Division getDivision() {
+ return getRepository().getCurrentDivision();
+ }
+
+ public String view() {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ HttpServletRequest myRequest = (HttpServletRequest) facesContext.getExternalContext().getRequest();
+ String value = myRequest.getParameter("division-id");
+
+ if (value != null && !value.isEmpty()) {
+ Division div = getRepository().find(Division.class, Integer.valueOf(value));
+ getRepository().setCurrentDivision(div);
+ }
+
+ return PAGE;
+ }
+}
diff --git a/mysports/application/src/main/java/eclipselink/example/mysports/application/view/ViewLeague.java b/mysports/application/src/main/java/eclipselink/example/mysports/application/view/ViewLeague.java
new file mode 100644
index 0000000..d9f59bc
--- /dev/null
+++ b/mysports/application/src/main/java/eclipselink/example/mysports/application/view/ViewLeague.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.application.view;
+
+import java.util.List;
+
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.RequestScoped;
+
+import eclipselink.example.mysports.application.model.Division;
+import eclipselink.example.mysports.application.services.LeagueRepository;
+
+/**
+ * JSF managed bean used to view a league's divisions.
+ *
+ * @author dclarke
+ * @since EclipseLink 2.3.0
+ */
+@ManagedBean
+@RequestScoped
+public class ViewLeague extends BaseManagedBean {
+
+ protected static final String PAGE = "view-league";
+
+ public LeagueRepository getRepository() {
+ return getRepositoryBean().getRepository();
+ }
+
+ public String getLeagueId() {
+ return getRepository().getLeagueId();
+ }
+
+ public List<Division> getDivisions() {
+ return getRepository().getDivisions();
+ }
+
+ public Division getCurrentDivision() {
+ return getRepository().getCurrentDivision();
+ }
+
+ public String getLeagueName() {
+ return getRepository().getName();
+ }
+
+ public String view() {
+ return PAGE;
+ }
+
+}
diff --git a/mysports/application/src/main/java/eclipselink/example/mysports/application/view/ViewTeam.java b/mysports/application/src/main/java/eclipselink/example/mysports/application/view/ViewTeam.java
new file mode 100644
index 0000000..8578b55
--- /dev/null
+++ b/mysports/application/src/main/java/eclipselink/example/mysports/application/view/ViewTeam.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.application.view;
+
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.SessionScoped;
+import javax.faces.component.html.HtmlDataTable;
+
+/**
+ * JSF managed bean displaying a team.
+ *
+ * @author dclarke
+ * @since EclipseLink 2.3.0
+ */
+@ManagedBean(name=ViewTeam.NAME)
+@SessionScoped
+public class ViewTeam extends BaseTeamBean {
+
+ protected static final String NAME = "viewTeam";
+
+ protected static final String PAGE = "view-team?faces-redirect=true";
+
+ @Override
+ public String getPage() {
+ return PAGE;
+ }
+
+ @Override
+ public HtmlDataTable getDataTable() {
+ return getDataTable(NAME, false);
+ }
+
+}
diff --git a/mysports/application/src/main/java/resources/application.properties b/mysports/application/src/main/java/resources/application.properties
new file mode 100644
index 0000000..5b9198d
--- /dev/null
+++ b/mysports/application/src/main/java/resources/application.properties
@@ -0,0 +1,7 @@
+# -- welcome --
+welcomeTitle=JSF Blank Application
+
+welcomeHeading=Welcome!
+
+welcomeMessage=This is a JSF blank application. \
+ You can find the application.properties file with this message in the src/resources folder.
diff --git a/mysports/application/src/main/resources/META-INF/eclipselink-oxm.xml b/mysports/application/src/main/resources/META-INF/eclipselink-oxm.xml
new file mode 100644
index 0000000..c067988
--- /dev/null
+++ b/mysports/application/src/main/resources/META-INF/eclipselink-oxm.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0"?>
+<xml-bindings version="2.3"
+ xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm"
+ package-name="eclipselink.example.mysports.application.model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.eclipse.org/eclipselink/xsds/persistence/oxm http://www.eclipse.org/eclipselink/xsds/eclipselink_oxm_2_3.xsd">
+ <java-types>
+ <java-type name="Divisions" xml-accessor-type="FIELD">
+ <java-attributes>
+ <xml-element java-attribute="divisions" xml-path="divisions" />
+ </java-attributes>
+ </java-type>
+ <java-type name="Division" xml-accessor-type="FIELD">
+ <xml-root-element />
+ <xml-virtual-access-methods />
+ <java-attributes>
+ <xml-attribute java-attribute="id" />
+ <xml-attribute java-attribute="version" />
+ <xml-attribute java-attribute="name" />
+ <xml-element java-attribute="teams" xml-path="teams/team" />
+ <xml-transient java-attribute="attributes" />
+ <xml-transient java-attribute="defaultDivision" />
+ </java-attributes>
+ </java-type>
+ <java-type name="Team" xml-accessor-type="FIELD">
+ <xml-root-element />
+ <xml-virtual-access-methods />
+ <java-attributes>
+ <xml-attribute java-attribute="id" />
+ <xml-attribute java-attribute="version" />
+ <xml-element java-attribute="name" />
+ <xml-element java-attribute="players" xml-path="players/player" />
+ <xml-inverse-reference java-attribute="division"
+ mapped-by="teams" />
+ <xml-transient java-attribute="attributes" />
+ </java-attributes>
+ </java-type>
+ <java-type name="Player" xml-accessor-type="FIELD">
+ <xml-root-element />
+ <xml-virtual-access-methods />
+ <java-attributes>
+ <xml-attribute java-attribute="id" />
+ <xml-attribute java-attribute="version" />
+ <xml-attribute java-attribute="userid" />
+ <xml-element java-attribute="firstName" />
+ <xml-element java-attribute="lastName" />
+ <xml-element java-attribute="email" />
+ <xml-inverse-reference java-attribute="team"
+ mapped-by="players" />
+ <xml-transient java-attribute="attributes" />
+ </java-attributes>
+ </java-type>
+ </java-types>
+</xml-bindings>
\ No newline at end of file
diff --git a/mysports/application/src/main/resources/META-INF/local-eclipselink-orm.xml b/mysports/application/src/main/resources/META-INF/local-eclipselink-orm.xml
new file mode 100644
index 0000000..effc5f0
--- /dev/null
+++ b/mysports/application/src/main/resources/META-INF/local-eclipselink-orm.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<entity-mappings version="2.4"
+ xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/orm"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.eclipse.org/eclipselink/xsds/persistence/orm http://www.eclipse.org/eclipselink/xsds/eclipselink_orm_2_4.xsd">
+
+
+
+</entity-mappings>
diff --git a/mysports/application/src/main/resources/META-INF/persistence.xml b/mysports/application/src/main/resources/META-INF/persistence.xml
new file mode 100644
index 0000000..b2efd78
--- /dev/null
+++ b/mysports/application/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
+ <persistence-unit name="mysports" transaction-type="RESOURCE_LOCAL">
+ <provider>eclipselink.example.mysports.persistence.TenantPerEMFProvider</provider>
+ <non-jta-data-source>java:global/mysports</non-jta-data-source>
+ <mapping-file>META-INF/local-eclipselink-orm.xml</mapping-file>
+
+ <class>eclipselink.example.mysports.application.model.Division</class>
+ <class>eclipselink.example.mysports.application.model.Team</class>
+ <class>eclipselink.example.mysports.application.model.Player</class>
+ <class>eclipselink.example.mysports.application.model.User</class>
+ <exclude-unlisted-classes>true</exclude-unlisted-classes>
+ <validation-mode>NONE</validation-mode>
+
+ <properties>
+ <!-- Logging Config -->
+ <property name="eclipselink.logging.level" value="FINE"/>
+ <property name="eclipselink.logging.timestamp" value="false"/>
+ <property name="eclipselink.logging.thread" value="false"/>
+ <property name="eclipselink.logging.connection" value="false"/>
+ <property name="eclipselink.logging.level.metadata" value="WARNING"/>
+ <property name="eclipselink.logging.parameters" value="true"/>
+ <property name="eclipselink.logging.session" value="false"/>
+ <property name="eclipselink.logging.exceptions" value="false"/>
+ <property name="eclipselink.logging.level.metadata" value="WARNING"/>
+ </properties>
+ </persistence-unit>
+</persistence>
diff --git a/mysports/application/src/main/resources/my-sports.properties b/mysports/application/src/main/resources/my-sports.properties
new file mode 100644
index 0000000..2d65d29
--- /dev/null
+++ b/mysports/application/src/main/resources/my-sports.properties
@@ -0,0 +1,3 @@
+mysports.admin.context=/MySportsAdmin/rest/league
+mysports.admin-connector=eclipselink.example.mysports.mysports.application.admin.RESTAdminServerConnector
+mysports.persistence-unit=mysports
\ No newline at end of file
diff --git a/mysports/application/src/main/resources/resources/application.properties b/mysports/application/src/main/resources/resources/application.properties
new file mode 100644
index 0000000..f7fad0b
--- /dev/null
+++ b/mysports/application/src/main/resources/resources/application.properties
@@ -0,0 +1,5 @@
+# -- welcome --
+welcomeHeading=Welcome to MySports
+generalHeading=MySports
+
+welcomeMessage=This is a demo application showing multi-tenancy and extensibility.
diff --git a/mysports/application/src/main/webapp/META-INF/MANIFEST.MF b/mysports/application/src/main/webapp/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..254272e
--- /dev/null
+++ b/mysports/application/src/main/webapp/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
diff --git a/mysports/application/src/main/webapp/WEB-INF/faces-config.xml b/mysports/application/src/main/webapp/WEB-INF/faces-config.xml
new file mode 100644
index 0000000..6b9c92a
--- /dev/null
+++ b/mysports/application/src/main/webapp/WEB-INF/faces-config.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
+ version="2.0">
+ <application>
+ <message-bundle>resources.application</message-bundle>
+ <locale-config>
+ <default-locale>en</default-locale>
+ </locale-config>
+ </application>
+
+ <lifecycle>
+ <phase-listener>eclipselink.example.mysports.application.view.MySportsPhaseListener</phase-listener>
+ </lifecycle>
+
+</faces-config>
diff --git a/mysports/application/src/main/webapp/WEB-INF/sun-web.xml b/mysports/application/src/main/webapp/WEB-INF/sun-web.xml
new file mode 100644
index 0000000..5193bb2
--- /dev/null
+++ b/mysports/application/src/main/webapp/WEB-INF/sun-web.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 Servlet 2.5//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_2_5-0.dtd">
+<sun-web-app error-url="/faces/error.xhtml">
+ <context-root>/MySports</context-root>
+
+<security-role-mapping>
+ <role-name>JPA-RS</role-name>
+ <group-name>JPA-RS</group-name>
+</security-role-mapping>
+
+ <class-loader delegate="true" />
+
+ <jsp-config>
+ <property name="keepgenerated" value="true">
+ <description>Keep a copy of the generated servlet class java code.</description>
+ </property>
+ </jsp-config>
+
+
+</sun-web-app>
diff --git a/mysports/application/src/main/webapp/WEB-INF/web.xml b/mysports/application/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..5c2c718
--- /dev/null
+++ b/mysports/application/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
+ <display-name>MySports</display-name>
+ <welcome-file-list>
+ <welcome-file>faces/index.xhtml</welcome-file>
+ </welcome-file-list>
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>/faces/*</url-pattern>
+ </servlet-mapping>
+</web-app>
\ No newline at end of file
diff --git a/mysports/application/src/main/webapp/WEB-INF/weblogic.xml b/mysports/application/src/main/webapp/WEB-INF/weblogic.xml
new file mode 100644
index 0000000..a31a19c
--- /dev/null
+++ b/mysports/application/src/main/webapp/WEB-INF/weblogic.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wls:weblogic-web-app xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.4/weblogic-web-app.xsd">
+ <wls:context-root>application</wls:context-root>
+</wls:weblogic-web-app>
\ No newline at end of file
diff --git a/mysports/application/src/main/webapp/create-division.xhtml b/mysports/application/src/main/webapp/create-division.xhtml
new file mode 100644
index 0000000..c7ea94d
--- /dev/null
+++ b/mysports/application/src/main/webapp/create-division.xhtml
@@ -0,0 +1,36 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core">
+
+<ui:composition template="template.jsf">
+ <ui:define name="title">
+ <h:outputText value="#{viewLeague.leagueId}" />
+ </ui:define>
+ <ui:define name="subtitle">
+ <h:outputText value="Create Division" />
+ </ui:define>
+ <ui:define name="crumb1">
+ <h:commandLink value="MySports" action="index" style="crumb"/>
+ </ui:define>
+
+ <ui:define name="body">
+ <h:form>
+ <h:panelGrid width="100%" columns="2" border="1" styleClass="pretty">
+ <h:outputLabel value="Division Name:"/>
+ <h:inputText value="#{createDivision.name}" />
+ <f:facet name="footer">
+ <div align="center">
+ <h:commandButton value="Create" action="#{createDivision.create}"/>
+ <h:commandButton value="Cancel" action="#{createDivision.cancel}"/>
+ </div>
+ </f:facet>
+ </h:panelGrid>
+
+ </h:form>
+ </ui:define>
+</ui:composition>
+</html>
\ No newline at end of file
diff --git a/mysports/application/src/main/webapp/create-team.xhtml b/mysports/application/src/main/webapp/create-team.xhtml
new file mode 100644
index 0000000..625cebe
--- /dev/null
+++ b/mysports/application/src/main/webapp/create-team.xhtml
@@ -0,0 +1,51 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core">
+
+<ui:composition template="template.jsf">
+ <ui:define name="title">
+ <h:outputText
+ value="#{viewLeague.leagueId}: #{viewDivision.division.name}" />
+ </ui:define>
+ <ui:define name="subtitle">
+ <h:outputText value="Create Team" />
+ </ui:define>
+ <ui:define name="crumb1">
+ <h:commandLink value="MySports" action="index" />
+ </ui:define>
+ <ui:define name="crumb2">
+ <h:commandLink value="#{viewLeague.leagueId}"
+ action="#{viewLeague.view}" />
+ </ui:define>
+ <ui:define name="crumb3">
+ <h:commandLink value="#{viewLeague.currentDivision.name}"
+ action="#{viewDivision.view}" />
+ </ui:define>
+ <ui:define name="body">
+ <h:form>
+
+ <h:panelGrid width="100%" columns="2" border="1" styleClass="pretty">
+ <f:facet name="header">
+ <div align="right">
+ <h:commandButton action="#{createTeam.save}" value="Save" />
+
+ <h:commandButton action="#{createTeam.cancel}" value="Cancel" />
+ </div>
+ </f:facet>
+ <h:outputLabel value="Name:" />
+ <h:inputText value="#{createTeam.team.name}" size="80"/>
+ <h:outputLabel value="Division: " />
+ <h:outputLabel value="#{createTeam.currentDivision.name}" />
+ </h:panelGrid>
+
+ <h:dataTable binding="#{createTeam.dataTable}">
+ </h:dataTable>
+
+ </h:form>
+ </ui:define>
+</ui:composition>
+</html>
\ No newline at end of file
diff --git a/mysports/application/src/main/webapp/default.css b/mysports/application/src/main/webapp/default.css
new file mode 100644
index 0000000..0ff180c
--- /dev/null
+++ b/mysports/application/src/main/webapp/default.css
@@ -0,0 +1,212 @@
+#*******************************************************************************
+# * Copyright (c) 2010 Oracle. All rights reserved.
+# * This program and the accompanying materials are made available under the
+# * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+# * which accompanies this distribution.
+# * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+# * and the Eclipse Distribution License is available at
+# * http://www.eclipse.org/org/documents/edl-v10.php.
+# *
+# * Contributors:
+# * dclarke - MySports Example for EclipseLink 2.3
+# ******************************************************************************/
+BODY, P, LI, UL, OL {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 50%;
+ color:#000000;
+ list-style-position: outside;
+}
+
+A:link {
+ font-family: Arial, Helvetica, sans-serif;
+ color:#663300;
+
+}
+
+A:active {
+ font-family: Arial, Helvetica, sans-serif;
+ color:#ff6600;
+
+}
+
+A:visited {
+ font-family: Arial, Helvetica, sans-serif;
+ color:#996633;
+
+}
+
+A.navigation:link
+{
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:65%;
+ color:#996633;
+}
+
+A.navigation:active
+{
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:65%;
+ color:#996633;
+}
+
+A.navigation:visited
+{
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:65%;
+ color:#996633;
+}
+
+.clear { /* generic container (i.e. div) for floating buttons */
+ overflow: hidden;
+ width: 100%;
+}
+
+c.button {
+ background: transparent url('../images/bg_button_a.gif') no-repeat scroll top right;
+ color: #444;
+ display: block;
+ float: left;
+ font: normal 12px arial, sans-serif;
+ height: 24px;
+ margin-right: 6px;
+ padding-right: 18px; /* sliding doors padding */
+ text-decoration: none;
+}
+
+a.button span {
+ background: transparent url('../images/bg_button_span.gif') no-repeat;
+ display: block;
+ line-height: 14px;
+ padding: 5px 0 5px 18px;
+}
+
+a.button:active {
+ background-position: bottom right;
+ color: #000;
+ outline: none; /* hide dotted outline in Firefox */
+}
+
+a.button:active span {
+ background-position: bottom left;
+ padding: 6px 0 4px 18px; /* push text down 1px */
+}
+p.listpara
+{text-indent: 15%}
+
+H1 {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:170%;
+ color:#336699;
+ border : solid ##3333CC;
+ width : 100%;
+ border-width : 0px 0px 2px 0px;
+ margin-left: 20px;
+}
+
+H2 {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:130%;
+ font-style: italic;
+ color: white;
+ width : 100%;
+ margin-left: 20px;
+}
+
+H3 {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:110%;
+ color:#336699;
+ border : solid #CCCC99;
+ width : 100%;
+ border-width : 0px 0px 2px 0px;
+}
+
+H4 {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size:92%;
+ color:#000000;
+ font-weight: bold;
+ width : 100%;
+}
+
+.code_no_color {
+ color : #000000;
+ font-family : "Courier New", "Courier", "monospace";
+}
+
+code {
+ color : #336699;
+ font-family : "Courier New", "Courier", "monospace";
+}
+
+P.indent {
+ text-indent: 9%;
+}
+
+table.borders {
+ border : 1% solid #BDB76B;
+}
+
+TR {
+ text-align : left;
+ vertical-align : top;
+}
+
+TH {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 11pt;
+ color:#000000;
+ font-weight: bold;
+}
+
+TD {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 11pt;
+ color:#000000;
+}
+
+.smalltext {
+ font-size:80%;
+}
+
+p.note {
+ display: block;
+ font-family: Arial, Helvetica, Geneva, sans-serif;
+ font-size: 95%;
+}
+
+p.warning {
+ display: block;
+ font-family: Arial, Helvetica, Geneva, sans-serif;
+ font-size: 95%;
+}
+
+pre {
+ font-family: "Courier New", Courier, mono;
+ font-size: 92%;
+ text-indent : 15%;
+}
+
+table.pretty {
+ background: whitesmoke;
+ border-collapse: collapse;
+}
+table.pretty th, table.pretty td {
+ border: 1px silver solid;
+ padding: 0.2em;
+ font-size: 10pt;
+}
+table.pretty th {
+ background: brown;
+ text-align: left;
+ color: white;
+}
+table.pretty caption {
+ margin-left: inherit;
+ margin-right: inherit;
+}
+
+table.accent {
+ background: brown;
+}
+
diff --git a/mysports/application/src/main/webapp/edit-team.xhtml b/mysports/application/src/main/webapp/edit-team.xhtml
new file mode 100644
index 0000000..2250465
--- /dev/null
+++ b/mysports/application/src/main/webapp/edit-team.xhtml
@@ -0,0 +1,43 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core">
+
+<ui:composition template="template.jsf">
+ <ui:define name="title">
+ <h:outputText value="Team: #{viewTeam.team.name}" />
+ </ui:define>
+ <ui:define name="subtitle">
+ <h:outputText value="Modify Team" />
+ </ui:define>
+ <ui:define name="crumb1">
+ <h:commandLink value="MySports" action="index" />
+ </ui:define>
+ <ui:define name="crumb2">
+ <h:commandLink value="#{viewLeague.leagueId}"
+ action="#{viewLeague.view}" />
+ </ui:define>
+ <ui:define name="crumb3">
+ <h:commandLink value="#{viewLeague.currentDivision.name}"
+ action="#{viewDivision.view}" />
+ </ui:define>
+ <ui:define name="body">
+ <h:form>
+
+ <h:panelGrid width="100%" columns="2" border="1">
+ <h:outputLabel value="Name:" />
+ <h:inputText value="#{editTeam.team.name}" />
+ </h:panelGrid>
+ <h3>Players</h3>
+ <h:dataTable binding="#{editTeam.dataTable}" />
+ <div align="center">
+ <h:commandButton action="#{editTeam.save}" value="Save" />
+ <h:commandButton action="#{editTeam.cancel}" value="Cancel" />
+ </div>
+ </h:form>
+ </ui:define>
+</ui:composition>
+</html>
\ No newline at end of file
diff --git a/mysports/application/src/main/webapp/images/add_obj.gif b/mysports/application/src/main/webapp/images/add_obj.gif
new file mode 100644
index 0000000..252d7eb
--- /dev/null
+++ b/mysports/application/src/main/webapp/images/add_obj.gif
Binary files differ
diff --git a/mysports/application/src/main/webapp/images/bg_button_a.gif b/mysports/application/src/main/webapp/images/bg_button_a.gif
new file mode 100644
index 0000000..c8e740d
--- /dev/null
+++ b/mysports/application/src/main/webapp/images/bg_button_a.gif
Binary files differ
diff --git a/mysports/application/src/main/webapp/images/bg_button_span.gif b/mysports/application/src/main/webapp/images/bg_button_span.gif
new file mode 100644
index 0000000..7da2e19
--- /dev/null
+++ b/mysports/application/src/main/webapp/images/bg_button_span.gif
Binary files differ
diff --git a/mysports/application/src/main/webapp/images/eclipselink.png b/mysports/application/src/main/webapp/images/eclipselink.png
new file mode 100644
index 0000000..55b2a2f
--- /dev/null
+++ b/mysports/application/src/main/webapp/images/eclipselink.png
Binary files differ
diff --git a/mysports/application/src/main/webapp/images/mysports.png b/mysports/application/src/main/webapp/images/mysports.png
new file mode 100644
index 0000000..5e9adff
--- /dev/null
+++ b/mysports/application/src/main/webapp/images/mysports.png
Binary files differ
diff --git a/mysports/application/src/main/webapp/index.jsp b/mysports/application/src/main/webapp/index.jsp
new file mode 100644
index 0000000..ab292c3
--- /dev/null
+++ b/mysports/application/src/main/webapp/index.jsp
@@ -0,0 +1,13 @@
+<%@page contentType="text/html" pageEncoding="UTF-8"%>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>JSP Page</title>
+ </head>
+ <body>
+ <h1>Hello World!</h1>
+ </body>
+</html>
diff --git a/mysports/application/src/main/webapp/index.xhtml b/mysports/application/src/main/webapp/index.xhtml
new file mode 100644
index 0000000..ff0aff6
--- /dev/null
+++ b/mysports/application/src/main/webapp/index.xhtml
@@ -0,0 +1,37 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core">
+
+
+<ui:composition template="leagues-template.jsf">
+ <ui:define name="title">My Sports</ui:define>
+ <ui:define name="body">
+ <h2>Leagues</h2>
+ <h:form>
+ <div align="center">
+ <h:dataTable var="league" value="#{leaguesList.leagues.leagues}"
+ border="1" styleClass="pretty" width="500">
+ <f:facet name="header">
+ Leagues
+ </f:facet>
+ <h:column>
+ <h:outputText value="#{league.id}" />
+ </h:column>
+ <h:column>
+ <h:commandLink value="#{league.name}"
+ action="#{leagueRepositoryBean.setLeague}">
+ <f:param name="league" value="#{league.id}" />
+ </h:commandLink>
+ </h:column>
+ </h:dataTable>
+
+ </div>
+ <p> </p>
+ </h:form>
+ </ui:define>
+</ui:composition>
+</html>
diff --git a/mysports/application/src/main/webapp/leagues-template.jsf b/mysports/application/src/main/webapp/leagues-template.jsf
new file mode 100644
index 0000000..33562a2
--- /dev/null
+++ b/mysports/application/src/main/webapp/leagues-template.jsf
@@ -0,0 +1,65 @@
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:fmt="http://java.sun.com/jstl/fmt">
+<head>
+<title><ui:insert name="title" />
+</title>
+<link rel="stylesheet" type="text/css"
+ href="default.css" />
+</head>
+<body>
+ <f:view>
+ <h:form>
+ <table width="100%">
+ <tr>
+ <td width="100%">
+ <table width="100%">
+ <tr>
+ <td width="100%" valign="bottom">
+ <h1>
+ <img src="images/mysports.png" alt="MySports" />
+ </h1></td>
+ <td width="50" align="center"></td>
+
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+
+ <table width="100%" class="accent">
+ <tr>
+ <td><h2>
+ <ui:insert name="subtitle" />
+ </h2></td>
+ </tr>
+ </table>
+
+ <i>
+ <ui:insert name="crumb1" />
+ <ui:insert name="crumb2" />
+ <ui:insert name="crumb3" />
+ <ui:insert name="crumb4" /> </i>
+ <h:messages />
+ </h:form>
+
+ <ui:insert name="body" />
+
+ <table width="100%" class="accent">
+ <tr>
+ <td height="10"></td>
+ </tr>
+ </table>
+ <p/>
+ <div align="center">
+ Powered by: <a href="http://www.eclipse.org/eclipselink"><h:graphicImage
+ url="/images/eclipselink.png" alt="EclipseLink" /> </a>
+ </div>
+ </f:view>
+</body>
+</html>
diff --git a/mysports/application/src/main/webapp/player/view.xhtml b/mysports/application/src/main/webapp/player/view.xhtml
new file mode 100644
index 0000000..1152b57
--- /dev/null
+++ b/mysports/application/src/main/webapp/player/view.xhtml
@@ -0,0 +1,53 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core">
+
+<ui:composition template="../template.jsf">
+ <ui:define name="title">
+ <h:outputText value="Player: #{viewPlayer.player.displayName}" />
+ </ui:define>
+ <ui:define name="crumb1">
+ <h:commandLink value="MySports" action="index" />
+ </ui:define>
+ <ui:define name="crumb2">
+ <h:commandLink value="#{viewLeague.leagueId}"
+ action="#{viewLeague.view}" />
+ </ui:define>
+ <ui:define name="crumb3">
+ <h:commandLink value="#{viewLeague.currentDivision.name}"
+ action="#{viewDivision.view}" />
+ </ui:define>
+ <ui:define name="crumb4">
+ <h:commandLink value="#{viewPlayer.player.team.name}"
+ action="#{viewPlayer.view}" />
+ </ui:define>
+
+ <ui:define name="body">
+ <h:form>
+ <h:panelGrid styleClass="pretty" width="500" columns="2" border="1">
+ <f:facet name="header">
+ <div align="right">
+ <h:commandButton value="Edit" action="#{editPlayer.edit}"/>
+ </div>
+ </f:facet>
+ <h:outputText value="First Name:"/>
+ <h:outputText value="#{viewPlayer.player.firstName}"/>
+ <h:outputText value="Last Name:"/>
+ <h:outputText value="#{viewPlayer.player.lastName}"/>
+ <f:facet name="footer">
+ <div align="center"></div>
+ </f:facet>
+ </h:panelGrid>
+
+ <h:dataTable binding="#{viewTeam.dataTable}" />
+ <h:commandLink value="Modify" action="#{editTeam.setTeam}">
+ <f:param name="team-id" value="#{viewTeam.team.id}" />
+ </h:commandLink>
+ </h:form>
+ </ui:define>
+</ui:composition>
+</html>
\ No newline at end of file
diff --git a/mysports/application/src/main/webapp/template.jsf b/mysports/application/src/main/webapp/template.jsf
new file mode 100644
index 0000000..9d4c9d0
--- /dev/null
+++ b/mysports/application/src/main/webapp/template.jsf
@@ -0,0 +1,65 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:fmt="http://java.sun.com/jstl/fmt">
+<f:loadBundle basename="resources.application" var="msg" />
+<head>
+<title><ui:insert name="title" /></title>
+<link rel="stylesheet" type="text/css" href="#{lookAndFeel.css}" />
+</head>
+<body>
+ <f:view>
+ <h:form>
+ <table width="100%">
+ <tr>
+ <td width="100%">
+ <table width="100%">
+ <tr>
+ <td width="200"><h:commandButton
+ action="#{viewLeague.view}" image="#{lookAndFeel.logo}" /> </td>
+ <td width="100%" valign="middle"><h1><h:outputLabel
+ value="#{viewLeague.leagueName}" /></h1></td>
+ <td width="100" valign="top" align="right"><h:commandButton
+ value="MySports" action="#{viewLeague.home}" image="images/mysports.png"
+ rendered="#{lookAndFeel.multitenant}" /></td>
+ <td width="50" align="center"></td>
+
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+
+ <table width="100%" class="accent">
+ <tr>
+ <td><h2>
+ <ui:insert name="subtitle" />
+ </h2></td>
+ </tr>
+ </table>
+
+ <i> <ui:insert name="crumb1" /> <ui:insert name="crumb2" />
+ <ui:insert name="crumb3" /> <ui:insert name="crumb4" />
+
+ </i>
+ <h:messages />
+ </h:form>
+
+ <ui:insert name="body" />
+ <p> </p>
+ <table width="100%" class="accent">
+ <tr>
+ <td height="10"></td>
+ </tr>
+ </table>
+ <p />
+ <div align="center">
+ Powered by: <a href="http://www.eclipse.org/eclipselink"><h:graphicImage
+ url="/images/eclipselink.png" alt="EclipseLink" /> </a>
+ </div>
+ </f:view>
+</body>
+</html>
diff --git a/mysports/application/src/main/webapp/tsa/index.html b/mysports/application/src/main/webapp/tsa/index.html
new file mode 100644
index 0000000..f524909
--- /dev/null
+++ b/mysports/application/src/main/webapp/tsa/index.html
@@ -0,0 +1,59 @@
+<!--
+ Copyright 2012, Oracle and or its affiliates. All Rights Reserved.
+ @author irfan.ahmed@oracle.com
+-->
+<!DOCTYPE html>
+<html>
+<head>
+<title>My Sports</title>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<link href="mysports.css" rel="stylesheet" />
+
+<!-- DOJO deployed locally on the server -->
+<link href="/dojo/1.7.2/dijit/themes/claro/claro.css" rel="stylesheet" />
+<script src="/dojo/1.7.2/dojo/dojo.js"></script>
+
+<script src="mysports.js"></script>
+<script>
+ djConfig = {
+ isDebug : false,
+ parseOnLoad : true
+ }
+</script>
+<script>
+ dojo.addOnLoad(function() {
+ console.debug("Dojo Loaded: ", dojo.version);
+ mysports = {
+ server : new mysports.Server({
+ rootUrl : '/MySports/persistence/mysports-', league : "OSL"
+ }),
+ navPanel : new mysports.NavPanel()
+ }
+ mysports.navPanel.init();
+
+ });
+</script>
+</head>
+<body class="claro">
+ <div class="mainContainer">
+ <div class="masthead">
+ <table>
+ <tr>
+ <td align="left"><img id="leagueLogo" /></td>
+ <td width="100%" align="center" valign="top"></td>
+ <td align="right" valign="top"><img src="../images/mysports.png"></td>
+ </tr>
+ </table>
+
+ </div>
+
+ <div class="navigation">
+ <div id="tree"></div>
+ </div>
+ <div class="content">
+
+ <div id="playersTableDiv"></div>
+ </div>
+ </div>
+</body>
+</html>
diff --git a/mysports/application/src/main/webapp/tsa/mysports.css b/mysports/application/src/main/webapp/tsa/mysports.css
new file mode 100644
index 0000000..29882d4
--- /dev/null
+++ b/mysports/application/src/main/webapp/tsa/mysports.css
@@ -0,0 +1,92 @@
+/*
+ Document : demo
+ Created on : 7 Jun, 2012, 2:04:42 AM
+ Author : irfan.ahmed@oracle.com
+ Description:
+ Purpose of the stylesheet follows.
+*/
+
+body {
+ font-size: 12px;
+ color: #333;
+ font-family: Ubuntu, Tahoma, Helvetica,Verdana,Arial,sans-serif;
+}
+
+.mainContainer {
+}
+
+.mainContainer .navigation {
+ position: absolute;
+ top: 200px;
+ left: 0;
+ width: 250px;
+ bottom: 0;
+}
+
+.mainContainer .content {
+ position: absolute;
+ left: 251px;
+ right: 0;
+ top: 150px;
+ bottom: 0;
+ background-color: #fdfdfd;
+}
+
+#playersTableDiv {
+ border: 1px solid #CCCCCC;
+ border-radius: 4px 4px 4px 4px;
+ margin: 20px;
+ padding: 5px;
+ background: #f0f0f0;
+}
+
+#playersTableDiv table {
+ width: 100%;
+ font-size: 11px;
+ background: #fff;
+}
+
+#playersTableDiv table th, #playersTableDiv table td {
+ border-color: #CCCCCC;
+ padding: 2px 5px;
+}
+
+#playersTableDiv table th {
+ color: #666666;
+ text-transform: uppercase;
+}
+
+#playersTableDiv table td {
+
+}
+
+#playersTableDiv table caption {
+ font-size: 13px;
+ font-weight: bold;
+ padding: 0 0 4px 1px;
+ text-align: left;
+}
+
+.masthead {
+ height: 200px;
+ left: 0;
+ position: absolute;
+ right: 0;
+ top: 0;
+}
+
+#popupbox {
+ margin: 0;
+ margin-left: 40%;
+ margin-right: 40%;
+ margin-top: 50px;
+ padding-top: 10px;
+ width: 20%;
+ height: 250px;
+ position: absolute;
+ background: #FBFBF0;
+ border: solid #000000 2px;
+ z-index: 9;
+ font-family: arial;
+ visibility: hidden;
+}
\ No newline at end of file
diff --git a/mysports/application/src/main/webapp/tsa/mysports.js b/mysports/application/src/main/webapp/tsa/mysports.js
new file mode 100644
index 0000000..8101fb1
--- /dev/null
+++ b/mysports/application/src/main/webapp/tsa/mysports.js
@@ -0,0 +1,285 @@
+/*
+ * Copyright 2012, Oracle and or its affiliates. All Rights Reserved.
+ *
+ * @author irfan.ahmed@oracle.com
+ */
+
+dojo.provide("demo.demo");
+
+dojo.require("dojo.data.ItemFileReadStore");
+dojo.require("dojo.data.ObjectStore");
+dojo.require("dijit._Widget");
+dojo.require("dijit.Tree");
+dojo.require("dijit.tree.ForestStoreModel");
+
+/**
+ * MySports Server connectivity
+ */
+dojo.declare("mysports.Server", null, {
+
+ rootURL : "/MySports/persistence/mysports-",
+
+ league : 'HTHL',
+
+ constructor : function(args) {
+ rootURL = args.root;
+ league = args.league;
+ },
+
+ get : function(args) {
+ if (!(args.url && args.onSuccess)) {
+ throw "url/onSuccess parameters are required for XHR Get call.";
+ }
+ dojo.xhrGet({
+ url : args.url,
+ headers : {
+ "Accept" : "application/json",
+ "Content-Type" : "application/json"
+ },
+ handleAs : "json",
+ load : function(data, ioArgs) {
+ args.onSuccess.apply(args.context, [ data, ioArgs ]);
+ },
+ error : function(error, ioArgs) {
+ console.error("Error occurred: ", error);
+ },
+ timeout : 15000,
+ sync : (args.sync ? args.sync : false)
+ });
+ }
+});
+
+dojo.declare("mysports.NavPanel", [ dijit._Widget ], {
+ constructor : function() {
+ this.treeData = {
+ label : "name",
+ identifier : "id",
+ items : []
+ };
+ },
+
+ init : function() {
+ var searchParams = dojo.queryToObject(dojo.doc.location.search
+ .substr((dojo.doc.location.search[0] === "?" ? 1 : 0)));
+ console.debug("Search Params: ", searchParams);
+ mysports.server.league = searchParams.league;
+ console.debug("Set leaue to: ", searchParams.league);
+
+ if (!mysports.server.league) {
+ mysports.server.league = 'OSL';
+ }
+
+ dojo.byId("leagueLogo").src = "/MySportsAdmin/rest/league/"
+ + mysports.server.league + ".png";
+
+ mysports.server.get({
+ url : "/MySports/persistence/mysports-" + mysports.server.league
+ + "/query/Division.findAll",
+ onSuccess : function(divisions) {
+ this.divisions = divisions;
+ var divLength = this.divisions.length;
+ dojo.forEach(this.divisions, function(division, divIndex) {
+ division.type = "division";
+ if (!division.children) {
+ division.children = [];
+ }
+ this.getTeam(division, function() {
+ console
+ .debug("Loaded Teams for division ",
+ division.id);
+ this.treeData.items.push(division);
+ if (divIndex == (divLength - 1)) {
+ this.createTree();
+ }
+ });
+ }, this);
+ },
+ context : this
+ });
+ },
+
+ getTeam : function(division, doneLoadingTeams) {
+ var teams = [];
+ dojo.forEach(division.relationships, function(rel) {
+ if (!rel.id) {
+ rel.id = division.id + "_" + rel.rel;
+ }
+ if (rel.rel == "teams") {
+ teams.push(rel);
+ }
+ });
+ var teamLength = teams.length;
+ dojo.forEach(teams, function(teamInfo, index) {
+ mysports.server.get({
+ url : teamInfo.href,
+ onSuccess : function(teamData) {
+ console.debug("Team Data for divsion : ", division.id,
+ teamData);
+
+ dojo.forEach(teamData, function(team) {
+ team.type = "team";
+ dojo.forEach(team.relationships, function(teamRel) {
+ if (!teamRel.id) {
+ teamRel.id = team.id + "_" + teamRel.rel;
+ }
+ });
+ division.children.push(team);
+ });
+ if (index == (teamLength - 1)) {
+ if (doneLoadingTeams) {
+ doneLoadingTeams.call(this);
+ }
+ }
+ },
+ context : this
+ });
+ }, this);
+ },
+
+ createTree : function() {
+ console.debug("Creating Tree : ", dojo.toJson(this.treeData, " "));
+ this.treeStore = new dojo.data.ItemFileReadStore({
+ data : this.treeData
+ });
+ this.treeStore.fetch({
+ query : {
+ type : "division"
+ },
+ onItem : function(item) {
+ console.debug(item);
+ },
+ onError : function(error) {
+ console.error(error);
+ }
+ });
+ this.treeModel = new dijit.tree.ForestStoreModel({
+ store : this.treeStore,
+ query : {
+ type : "division"
+ },
+ rootId : "root",
+ rootLabel : "Divisions",
+ childrenAttrs : [ "children" ]
+ });
+ this.tree = new dijit.Tree({
+ model : this.treeModel
+ }, "tree");
+ this.connect(this.tree, "onClick", function(item) {
+ if (this.treeStore.isItem(item)) {
+ var type = this.treeStore.getValue(item, "type");
+ var name = this.treeStore.getValue(item, "name");
+ if (type == "team") {
+ var relationShips = this.treeStore.getValues(item,
+ "relationships");
+ var players = dojo
+ .filter(relationShips,
+ function(rel) {
+ return this.treeStore.getValue(rel,
+ "rel") == "players";
+ }, this)[0];
+ this.showPlayers(name, players);
+ } else if (type == "division") {
+ this.showDivision(item);
+ }
+ }
+ });
+ this.createPlayersTable();
+ },
+
+ showPlayers : function(teamName, item) {
+ var href = this.treeStore.getValue(item, "href");
+ console.debug("Showing Players : ", href);
+ mysports.server.get({
+ url : href,
+ onSuccess : function(playersInfo) {
+ console.debug("Players : ", playersInfo);
+ this.playersTable.destroyAllRows();
+ this.playersTable.setCaption("Team: " + teamName);
+ dojo.forEach(playersInfo, function(player) {
+ this.playersTable.addRow(player);
+ }, this);
+ },
+ context : this
+ });
+ },
+
+ showDivision : function(item) {
+ console.debug("Showing Division : ", item);
+ },
+
+ createPlayersTable : function() {
+ this.creatingTable = true;
+ mysports.server
+ .get({
+ url : "/MySports/persistence/mysports-"
+ + mysports.server.league
+ + "/metadata/entity/Player",
+ onSuccess : function(tableInfo) {
+ this.playerTableInfo = tableInfo;
+ this.playersTable = new demo.PlayersTable(
+ this.playerTableInfo);
+ dojo.byId("playersTableDiv").appendChild(
+ this.playersTable.domNode);
+ this.creatingTable = false;
+ },
+ context : this
+ });
+ }
+});
+
+dojo.declare("demo.PlayersTable", [ dijit._Widget ], {
+ constructor : function(args) {
+ this.info = args;
+ this.cols = [];
+ this.rows = [];
+ },
+
+ postCreate : function() {
+ this.domNode = dojo.create("table", {
+ "class" : "playersTable",
+ border : "1",
+ rules : "all"
+ });
+ this.captionNode = dojo.create("caption", null, this.domNode);
+ this.tableNode = dojo.create("tbody", null, this.domNode);
+ this.createCols();
+ },
+
+ createCols : function() {
+ var headerRow = dojo.create("tr", null, this.tableNode);
+ dojo.forEach(this.attributes, function(colInfo, index) {
+ // TODO: Filter out some columns
+ if (colInfo.name != "team" && colInfo.name != "version"
+ && colInfo.name != "userid") {
+ this.cols.push(colInfo.name);
+ dojo.create("th", {
+ "class" : (index == 0 ? "first"
+ : (index == this.attributes.length - 1 ? "last"
+ : "")),
+ innerHTML : colInfo.name
+ }, headerRow);
+ }
+ }, this);
+ },
+
+ setCaption : function(caption) {
+ dojo.attr(this.captionNode, "innerHTML", caption);
+ },
+
+ addRow : function(rowInfo) {
+ console.debug("Adding : ", rowInfo);
+ var row = dojo.create("tr", null, this.tableNode);
+ dojo.forEach(this.cols, function(name) {
+ dojo.create("td", {
+ innerHTML : (rowInfo[name] ? rowInfo[name] : "")
+ }, row);
+ });
+ this.rows.push(row);
+ },
+
+ destroyAllRows : function() {
+ dojo.forEach(this.rows, function(row) {
+ dojo.destroy(row);
+ });
+ }
+});
diff --git a/mysports/application/src/main/webapp/view-division.xhtml b/mysports/application/src/main/webapp/view-division.xhtml
new file mode 100644
index 0000000..822f5c9
--- /dev/null
+++ b/mysports/application/src/main/webapp/view-division.xhtml
@@ -0,0 +1,42 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core">
+
+<ui:composition template="template.jsf">
+ <ui:define name="title">
+ <h:outputText value="Division: #{viewDivision.division.name}" />
+ </ui:define>
+
+ <ui:define name="body">
+ <h:form>
+
+ <div align="center">
+ <h:dataTable var="team" value="#{viewDivision.division.teams}"
+ border="1" styleClass="pretty" width="500">
+ <f:facet name="header">
+ <h:outputText
+ value="Division: #{viewDivision.division.name} Teams" />
+ </f:facet>
+ <h:column>
+ <h:commandLink value="#{team.name}" action="#{viewTeam.setTeam}">
+ <f:param name="team-id" value="#{team.id}" />
+ </h:commandLink>
+
+ </h:column>
+ <f:facet name="footer">
+ <div align="right">
+ <h:commandButton value="Add Team" action="#{createTeam.create}" />
+ </div>
+ </f:facet>
+ </h:dataTable>
+
+
+ </div>
+ </h:form>
+ </ui:define>
+</ui:composition>
+</html>
\ No newline at end of file
diff --git a/mysports/application/src/main/webapp/view-league.xhtml b/mysports/application/src/main/webapp/view-league.xhtml
new file mode 100644
index 0000000..39a0087
--- /dev/null
+++ b/mysports/application/src/main/webapp/view-league.xhtml
@@ -0,0 +1,42 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core">
+
+<ui:composition template="template.jsf">
+ <ui:define name="title">
+ <h:outputText value="#{viewLeague.leagueId}" />
+ </ui:define>
+ <ui:define name="crumb1">
+
+ </ui:define>
+
+ <ui:define name="body">
+ <h:form>
+ <div align="center">
+ <h:dataTable var="division" value="#{viewLeague.divisions}"
+ border="1" styleClass="pretty" width="500">
+ <f:facet name="header">Divisions
+ </f:facet>
+ <h:column>
+ <h:commandLink value="#{division.name}"
+ action="#{viewDivision.view}">
+ <f:param name="division-id" value="#{division.id}" />
+ </h:commandLink>
+ </h:column>
+
+
+ <f:facet name="footer">
+ <div align="right">
+ <h:commandButton CLASS="button" value="Add" action="create-division" />
+ </div>
+ </f:facet>
+ </h:dataTable>
+ </div>
+ </h:form>
+ </ui:define>
+</ui:composition>
+</html>
\ No newline at end of file
diff --git a/mysports/application/src/main/webapp/view-team.xhtml b/mysports/application/src/main/webapp/view-team.xhtml
new file mode 100644
index 0000000..6d15109
--- /dev/null
+++ b/mysports/application/src/main/webapp/view-team.xhtml
@@ -0,0 +1,33 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core">
+
+<ui:composition template="template.jsf">
+ <ui:define name="title">
+ <h:outputText value="Team: #{viewTeam.team.name}" />
+ </ui:define>
+
+ <ui:define name="crumb1">
+ <h:commandLink value="#{viewTeam.team.division.name}"
+ action="#{viewDivision.view}">
+ <f:param name="division-id" value="#{viewTeam.team.division.id}" />
+ </h:commandLink>
+ </ui:define>
+
+ <ui:define name="body">
+ <h:form>
+ <h1>
+ <h:outputText value="Team: #{viewTeam.team.name}" />
+ </h1>
+ <h:dataTable binding="#{viewTeam.dataTable}" />
+ <h:commandLink value="Modify" action="#{editTeam.setTeam}">
+ <f:param name="team-id" value="#{viewTeam.team.id}" />
+ </h:commandLink>
+ </h:form>
+ </ui:define>
+</ui:composition>
+</html>
\ No newline at end of file
diff --git a/mysports/application/src/test/java/eclipselink/example/mysports/application/test/MockAdminServerConnector.java b/mysports/application/src/test/java/eclipselink/example/mysports/application/test/MockAdminServerConnector.java
new file mode 100644
index 0000000..ab26482
--- /dev/null
+++ b/mysports/application/src/test/java/eclipselink/example/mysports/application/test/MockAdminServerConnector.java
@@ -0,0 +1,180 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.application.test;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLEntityMappings;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLEntityMappingsReader;
+import org.eclipse.persistence.internal.jpa.metadata.xml.XMLEntityMappingsWriter;
+import org.eclipse.persistence.jpa.metadata.MetadataSource;
+import org.eclipse.persistence.logging.SessionLog;
+
+import eclipselink.example.mysports.admin.model.HostedLeague;
+import eclipselink.example.mysports.admin.services.HostedLeagueRepository;
+import eclipselink.example.mysports.admin.services.MappingsLoader;
+import eclipselink.example.mysports.admin.services.test.AdminPersistenceTesting;
+import eclipselink.example.mysports.application.MySportsConfig;
+import eclipselink.example.mysports.application.admin.AdminServerConnector;
+import eclipselink.example.mysports.application.admin.HostedLeagues;
+import eclipselink.example.mysports.application.admin.League;
+import eclipselink.example.mysports.application.admin.RESTAdminServerConnector;
+
+/**
+ * TODO
+ *
+ * @author dclarke
+ * @since EclipseLink 2.3.0
+ */
+public class MockAdminServerConnector implements AdminServerConnector, MetadataSource {
+
+ private HostedLeagueRepository leaguesRepository;
+
+ public MockAdminServerConnector() {
+ leaguesRepository = AdminPersistenceTesting.createTestRepository(true);
+ }
+
+ public HostedLeagueRepository getRepository() {
+ return leaguesRepository;
+ }
+
+ public HostedLeagues getLeagues() {
+ List<HostedLeague> allLeagues = getRepository().allSharedLeagues();
+
+ for (HostedLeague hl : allLeagues) {
+ hl.setUri(RESTAdminServerConnector.DEFAULT_ROOT_URI+ "/" + hl.getId());
+ }
+
+ HostedLeagues result = new HostedLeagues();
+ for (HostedLeague hl : allLeagues) {
+ League l = new League();
+ l.setId(hl.getId());
+ l.setName(hl.getName());
+ l.setVersion(hl.getVersion());
+ result.getLeagues().add(l);
+ }
+
+ return result;
+ }
+
+ public League getLeague(String leagueId) {
+ HostedLeague hl = getRepository().getLeague(leagueId);
+
+ if (hl == null && "ALL".equals(leagueId)) {
+ hl = getAllExtensionsHostedLeague();
+ }
+
+ if (hl != null) {
+ hl.setUri(RESTAdminServerConnector.DEFAULT_ROOT_URI + "/" + hl.getId());
+ }
+
+ League l = null;
+
+ if (hl != null) {
+ l = new League();
+ l.setId(hl.getId());
+ l.setName(hl.getName());
+ l.setVersion(hl.getVersion());
+ hl.getPlayerExtensions().size();
+ }
+ return l;
+ }
+
+ public InputStream getCss(String leagueId) {
+ return new ByteArrayInputStream(getRepository().getCSS(leagueId).getBytes());
+ }
+
+ public InputStream getLogo(String leagueId) {
+ return getRepository().getLogo(leagueId);
+ }
+
+ public String getOrmURL(String leagueId) {
+ return leagueId;
+ }
+
+ public String getOxmURL(String leagueId) {
+ return null;
+ }
+
+ /**
+ * Default local resource. Only used when admin service cannot be accessed.
+ */
+ public static final String LOCAL_ECLIPSELINK_ORM = "META-INF/local-eclipselink-orm.xml";
+
+ @Override
+ public XMLEntityMappings getEntityMappings(Map<String, Object> properties, ClassLoader classLoader, SessionLog log) {
+ String leagueId = (String) properties.get(MySportsConfig.LEAGUE_CONTEXT);
+ String ormxml = null;
+
+ try {
+ ormxml = getRepository().getORM(leagueId);
+ } catch (IllegalArgumentException e) {
+ if ("ALL".equals(leagueId)) {
+ XMLEntityMappings xmlEntityMappings = MappingsLoader.getXMLEntityMappings(getAllExtensionsHostedLeague());
+ StringWriter writer = new StringWriter();
+ XMLEntityMappingsWriter.write(xmlEntityMappings, writer);
+ String xml = writer.toString();
+ //System.out.println("ORM-XML:\n" + xml + "\n");
+ return XMLEntityMappingsReader.read(getClass().getName(), new StringReader(xml), classLoader, properties);
+ } else {
+ throw e;
+ }
+ }
+ Reader reader = new StringReader(ormxml);
+ try {
+ return XMLEntityMappingsReader.read(getClass().getName(), reader, classLoader, properties);
+ } finally {
+ if (reader != null) {
+ try {
+ reader.close();
+ } catch (Exception e) {
+ }
+ }
+ }
+ }
+
+ @Override
+ public Map<String, Object> getPropertyOverrides(Map<String, Object> arg0, ClassLoader arg1, SessionLog arg2) {
+ return null;
+ }
+
+ private HostedLeague getAllExtensionsHostedLeague() {
+ HostedLeague allLeague = new HostedLeague("ALL", "All League", "red");
+ allLeague.addPlayerExtension("flex1", "java.lang.String", "FLEX_1");
+ allLeague.addPlayerExtension("flex2", "java.lang.String", "FLEX_2");
+ allLeague.addPlayerExtension("flex3", "java.lang.String", "FLEX_3");
+ allLeague.addPlayerExtension("flex4", "java.lang.String", "FLEX_4");
+ allLeague.addPlayerExtension("flex5", "java.lang.String", "FLEX_5");
+
+ allLeague.addTeamExtension("flex1", "java.lang.String", "FLEX_1");
+ allLeague.addTeamExtension("flex2", "java.lang.String", "FLEX_2");
+ allLeague.addTeamExtension("flex3", "java.lang.String", "FLEX_3");
+ allLeague.addTeamExtension("flex4", "java.lang.String", "FLEX_4");
+ allLeague.addTeamExtension("flex5", "java.lang.String", "FLEX_5");
+
+ allLeague.addDivisionExtension("flex1", "java.lang.String", "FLEX_1");
+ allLeague.addDivisionExtension("flex2", "java.lang.String", "FLEX_2");
+ allLeague.addDivisionExtension("flex3", "java.lang.String", "FLEX_3");
+ allLeague.addDivisionExtension("flex4", "java.lang.String", "FLEX_4");
+ allLeague.addDivisionExtension("flex5", "java.lang.String", "FLEX_5");
+
+ return allLeague;
+ }
+
+ }
diff --git a/mysports/application/src/test/java/eclipselink/example/mysports/application/test/TestCreateTenantEMF.java b/mysports/application/src/test/java/eclipselink/example/mysports/application/test/TestCreateTenantEMF.java
new file mode 100644
index 0000000..a0b94a7
--- /dev/null
+++ b/mysports/application/src/test/java/eclipselink/example/mysports/application/test/TestCreateTenantEMF.java
@@ -0,0 +1,115 @@
+package eclipselink.example.mysports.application.test;
+
+import java.util.Map;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+
+import org.eclipse.persistence.config.PersistenceUnitProperties;
+import org.eclipse.persistence.exceptions.QueryException;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import eclipselink.example.mysports.application.MySportsConfig;
+import eclipselink.example.mysports.application.model.Player;
+import eclipselink.example.mysports.examples.ExampleLeague;
+import eclipselink.example.mysports.examples.OttawaSoccerLeague;
+
+public class TestCreateTenantEMF {
+
+ private static ExampleLeague LEAGUE = new OttawaSoccerLeague();
+
+ private static TestingLeagueRepository repository;
+
+ @Test
+ public void createEMWithoutLeague() throws Exception {
+ Map<String, Object> properties = repository.get();
+ EntityManagerFactory emf = Persistence.createEntityManagerFactory(MySportsConfig.PU_NAME, properties);
+
+ Assert.assertNotNull(emf);
+
+ EntityManager em = emf.createEntityManager();
+
+ try {
+ em.find(Player.class, 1);
+ } catch (QueryException e) {
+ return;
+ } finally {
+ em.close();
+ emf.close();
+ }
+ // Assert.fail();
+ }
+
+ @Test
+ public void createKFL() throws Exception {
+ Map<String, Object> properties = repository.get();
+ EntityManagerFactory emf = Persistence.createEntityManagerFactory(MySportsConfig.PU_NAME + ";league=KFL", properties);
+
+ Assert.assertNotNull(emf);
+ EntityManager em = emf.createEntityManager();
+
+ try {
+ em.find(Player.class, 1);
+ } catch (QueryException e) {
+ return;
+ } finally {
+ em.close();
+ emf.close();
+ }
+ }
+
+ @Test
+ public void createEMWithInvalidLeague() throws Exception {
+ Map<String, Object> properties = repository.get();
+ EntityManagerFactory emf = Persistence.createEntityManagerFactory(MySportsConfig.PU_NAME + ";league=XXX", properties);
+
+ Assert.assertNotNull(emf);
+ EntityManager em = emf.createEntityManager();
+
+ try {
+ em.find(Player.class, 1);
+ } catch (QueryException e) {
+ return;
+ } finally {
+ em.close();
+ emf.close();
+ }
+ }
+
+ @Test
+ public void createEM_OSL_WithNullMetadataSource() throws Exception {
+ Map<String, Object> properties = repository.get();
+ properties.put(PersistenceUnitProperties.METADATA_SOURCE, null);
+
+ EntityManagerFactory emf = Persistence.createEntityManagerFactory(MySportsConfig.PU_NAME + ";league=OSL", properties);
+
+ Assert.assertNotNull(emf);
+ EntityManager em = emf.createEntityManager();
+
+ try {
+ em.find(Player.class, 1);
+ } catch (QueryException e) {
+ return;
+ } finally {
+ em.close();
+ emf.close();
+ }
+ }
+
+ @BeforeClass
+ public static void setup() {
+ repository = new TestingLeagueRepository(LEAGUE.getId());
+ repository.createSharedMySportsSchema();
+ LEAGUE.populate(repository);
+ }
+
+ @AfterClass
+ public static void tearDown() {
+ repository.close();
+ }
+
+}
diff --git a/mysports/application/src/test/java/eclipselink/example/mysports/application/test/TestExampleLeagues.java b/mysports/application/src/test/java/eclipselink/example/mysports/application/test/TestExampleLeagues.java
new file mode 100644
index 0000000..83e5beb
--- /dev/null
+++ b/mysports/application/src/test/java/eclipselink/example/mysports/application/test/TestExampleLeagues.java
@@ -0,0 +1,201 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.application.test;
+
+import java.util.List;
+import java.util.Vector;
+
+import javax.persistence.metamodel.Attribute;
+
+import org.eclipse.persistence.descriptors.ClassDescriptor;
+import org.eclipse.persistence.internal.jpa.metamodel.AttributeImpl;
+import org.eclipse.persistence.internal.sessions.ArrayRecord;
+import org.eclipse.persistence.sessions.server.Server;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import eclipselink.example.mysports.admin.model.Extension;
+import eclipselink.example.mysports.admin.model.HostedLeague;
+import eclipselink.example.mysports.application.model.Division;
+import eclipselink.example.mysports.application.model.Player;
+import eclipselink.example.mysports.examples.ExampleLeague;
+import eclipselink.example.mysports.examples.HighTechHockey;
+import eclipselink.example.mysports.examples.KidsFootballLeague;
+import eclipselink.example.mysports.examples.MinorHockeyLeague;
+import eclipselink.example.mysports.examples.OttawaSoccerLeague;
+
+/**
+ * @author dclarke
+ * @since EclipseLink 2.4.2
+ */
+public class TestExampleLeagues {
+
+ static ExampleLeague HTHL = new HighTechHockey();
+ static ExampleLeague KFL = new KidsFootballLeague();
+ static ExampleLeague MHL = new MinorHockeyLeague();
+ static OttawaSoccerLeague OSL = new OttawaSoccerLeague();
+
+ @Test
+ public void verifyHTHLDivisions() {
+ repository.setLeagueId(HTHL.getId(), null);
+
+ List<Division> divisions = repository.getDivisions();
+
+ Assert.assertNotNull(divisions);
+ Assert.assertEquals(2, divisions.size());
+
+ }
+
+ @Test
+ public void verifyHTHLAdditionalAttributes() {
+ repository.setLeagueId(HTHL.getId(), null);
+
+ List<Attribute<?, ?>> attrs = repository.getAdditionalAttributes(Player.class);
+
+ Assert.assertNotNull(attrs);
+ Assert.assertEquals(HTHL.getDefinition().getLeague().getPlayerExtensions().size(), attrs.size());
+
+ int index = 0;
+ for (Extension ext : HTHL.getDefinition().getLeague().getPlayerExtensions()) {
+ Attribute<?, ?> mnAttr = attrs.get(index++);
+ Assert.assertEquals(ext.getName(), mnAttr.getName());
+ Assert.assertFalse(mnAttr.isAssociation());
+ Assert.assertEquals(ext.getJavaType(), mnAttr.getJavaType().getName());
+ Assert.assertTrue(((AttributeImpl<?, ?>) mnAttr).getMapping().getAttributeAccessor().isVirtualAttributeAccessor());
+ }
+ }
+
+ @Test
+ public void verifyKFLMySportsSchema() throws Exception {
+ repository.setLeagueId(KFL.getId(), null);
+ Server session = repository.unwrap(Server.class);
+
+ for (ClassDescriptor desc : session.getDescriptors().values()) {
+ Object result = session.executeSQL("SELECT COUNT(*) FROM " + desc.getTableName());
+ Assert.assertNotNull(result);
+ @SuppressWarnings("unchecked")
+ ArrayRecord record = (ArrayRecord) ((Vector<Object>) result).get(0);
+ int intValue = ((Number) record.getValues().get(0)).intValue();
+ Assert.assertTrue(intValue >= 0);
+ }
+ }
+
+ @Test
+ public void verifyKFLAdditionalAttributes() {
+ repository.setLeagueId(KFL.getId(), null);
+ HostedLeague leagueDef = KFL.getDefinition().getLeague();
+
+ List<Attribute<?, ?>> attrs = repository.getAdditionalAttributes(Player.class);
+
+ Assert.assertNotNull(attrs);
+ Assert.assertEquals(leagueDef.getPlayerExtensions().size(), attrs.size());
+
+ int index = 0;
+ for (Extension ext : leagueDef.getPlayerExtensions()) {
+ Attribute<?, ?> mnAttr = attrs.get(index++);
+ Assert.assertEquals(ext.getName(), mnAttr.getName());
+ Assert.assertFalse(mnAttr.isAssociation());
+ Assert.assertEquals(String.class, mnAttr.getJavaType());
+ Assert.assertTrue(((AttributeImpl<?, ?>) mnAttr).getMapping().getAttributeAccessor().isVirtualAttributeAccessor());
+ }
+
+ }
+
+ @Test
+ public void verifyMHLAdditionalAttributes() {
+ repository.setLeagueId(MHL.getId(), null);
+ HostedLeague leagueDef = MHL.getDefinition().getLeague();
+
+ List<Attribute<?, ?>> attrs = repository.getAdditionalAttributes(Player.class);
+
+ Assert.assertNotNull(attrs);
+ Assert.assertEquals(leagueDef.getPlayerExtensions().size(), attrs.size());
+
+ int index = 0;
+ for (Extension ext : leagueDef.getPlayerExtensions()) {
+ Attribute<?, ?> mnAttr = attrs.get(index++);
+ Assert.assertEquals(ext.getName(), mnAttr.getName());
+ Assert.assertFalse(mnAttr.isAssociation());
+ Assert.assertEquals(String.class, mnAttr.getJavaType());
+ Assert.assertTrue(((AttributeImpl<?, ?>) mnAttr).getMapping().getAttributeAccessor().isVirtualAttributeAccessor());
+ }
+
+ }
+
+ @Test
+ public void verifyMHLDivisions() {
+ repository.setLeagueId(MHL.getId(), null);
+
+ }
+
+ @Test
+ public void verifyMHLTeams() {
+ repository.setLeagueId(MHL.getId(), null);
+
+ }
+
+ @Test
+ public void verifyOSLAdditionalAttributes() {
+ repository.setLeagueId(OSL.getId(), null);
+ HostedLeague leagueDef = OSL.getDefinition().getLeague();
+
+ List<Attribute<?, ?>> attrs = repository.getAdditionalAttributes(Player.class);
+
+ Assert.assertNotNull(attrs);
+ Assert.assertEquals(leagueDef.getPlayerExtensions().size(), attrs.size());
+
+ int index = 0;
+ for (Extension ext : leagueDef.getPlayerExtensions()) {
+ Attribute<?, ?> mnAttr = attrs.get(index++);
+ Assert.assertEquals(ext.getName(), mnAttr.getName());
+ Assert.assertFalse(mnAttr.isAssociation());
+ Assert.assertEquals(String.class, mnAttr.getJavaType());
+ Assert.assertTrue(((AttributeImpl<?, ?>) mnAttr).getMapping().getAttributeAccessor().isVirtualAttributeAccessor());
+ }
+
+ }
+
+ @Test
+ public void loadOSL_U6Division() {
+ repository.setLeagueId(OSL.getId(), null);
+
+ Division division = repository.getDivision(OSL.u6.getName());
+
+ Assert.assertNotNull(division);
+ Assert.assertEquals(division.getName(), "U6");
+
+ }
+
+ private static TestingLeagueRepository repository;
+
+ @BeforeClass
+ public static void initialize() {
+ repository = new TestingLeagueRepository();
+
+ repository.createSharedMySportsSchema();
+ repository.createLeagueTables(KFL.getId());
+
+ HTHL.populate(repository);
+ KFL.populate(repository);
+ MHL.populate(repository);
+ OSL.populate(repository);
+ }
+
+ @AfterClass
+ public static void close() {
+ repository.close();
+ }
+
+}
diff --git a/mysports/application/src/test/java/eclipselink/example/mysports/application/test/TestModelAndMappings.java b/mysports/application/src/test/java/eclipselink/example/mysports/application/test/TestModelAndMappings.java
new file mode 100644
index 0000000..865d94d
--- /dev/null
+++ b/mysports/application/src/test/java/eclipselink/example/mysports/application/test/TestModelAndMappings.java
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.application.test;
+
+import javax.persistence.EntityManagerFactory;
+
+import org.eclipse.persistence.descriptors.ClassDescriptor;
+import org.eclipse.persistence.internal.helper.Helper;
+import org.eclipse.persistence.internal.weaving.PersistenceWeaved;
+import org.eclipse.persistence.jpa.JpaHelper;
+import org.eclipse.persistence.sessions.server.Server;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import eclipselink.example.mysports.application.model.Division;
+import eclipselink.example.mysports.application.model.Extensible;
+import eclipselink.example.mysports.application.model.Player;
+import eclipselink.example.mysports.application.model.Team;
+import eclipselink.example.mysports.application.model.User;
+import eclipselink.example.mysports.examples.ExampleLeague;
+import eclipselink.example.mysports.examples.OttawaSoccerLeague;
+
+/**
+ * @author dclarke
+ * @since EclipseLink 2.3.0
+ */
+public class TestModelAndMappings {
+
+ private static TestingLeagueRepository repository;
+
+ private static ExampleLeague LEAGUE = new OttawaSoccerLeague();
+
+ @Test
+ public void verifySession() {
+ EntityManagerFactory emf = repository.unwrap(EntityManagerFactory.class);
+ Server session = JpaHelper.getServerSession(emf);
+ Assert.assertNotNull(session);
+ Assert.assertTrue(session.isServerSession());
+ }
+
+ @Test
+ public void verifyPlayer() {
+ EntityManagerFactory emf = repository.unwrap(EntityManagerFactory.class);
+ Server session = JpaHelper.getServerSession(emf);
+ ClassDescriptor descriptor = session.getClassDescriptor(Player.class);
+
+ Assert.assertNotNull(descriptor);
+ Assert.assertEquals(Helper.getShortClassName(descriptor.getJavaClass()), descriptor.getAlias());
+
+ Assert.assertTrue(Extensible.class.isAssignableFrom(descriptor.getJavaClass()));
+ Assert.assertTrue("Entity class now woven: " + descriptor, PersistenceWeaved.class.isAssignableFrom(descriptor.getJavaClass()));
+ }
+
+ @Test
+ public void verifyTeam() {
+ EntityManagerFactory emf = repository.unwrap(EntityManagerFactory.class);
+ Server session = JpaHelper.getServerSession(emf);
+ ClassDescriptor descriptor = session.getClassDescriptor(Team.class);
+
+ Assert.assertNotNull(descriptor);
+ Assert.assertEquals(Helper.getShortClassName(descriptor.getJavaClass()), descriptor.getAlias());
+ Assert.assertTrue("Entity class now woven: " + descriptor, PersistenceWeaved.class.isAssignableFrom(descriptor.getJavaClass()));
+ }
+
+ @Test
+ public void verifyDivision() {
+ EntityManagerFactory emf = repository.unwrap(EntityManagerFactory.class);
+ Server session = JpaHelper.getServerSession(emf);
+ ClassDescriptor descriptor = session.getClassDescriptor(Division.class);
+
+ Assert.assertNotNull(descriptor);
+ Assert.assertEquals(Helper.getShortClassName(descriptor.getJavaClass()), descriptor.getAlias());
+ Assert.assertTrue("Entity class now woven: " + descriptor, PersistenceWeaved.class.isAssignableFrom(descriptor.getJavaClass()));
+ }
+
+ @Test
+ public void verifyUser() {
+ EntityManagerFactory emf = repository.unwrap(EntityManagerFactory.class);
+ Server session = JpaHelper.getServerSession(emf);
+ ClassDescriptor descriptor = session.getClassDescriptor(User.class);
+
+ Assert.assertNotNull(descriptor);
+ Assert.assertEquals(Helper.getShortClassName(descriptor.getJavaClass()), descriptor.getAlias());
+ Assert.assertTrue("Entity class now woven: " + descriptor, PersistenceWeaved.class.isAssignableFrom(descriptor.getJavaClass()));
+ }
+
+ @BeforeClass
+ public static void setup() {
+ repository = new TestingLeagueRepository();
+ repository.setLeagueId(LEAGUE.getId(), null);
+ LEAGUE.populate(repository);
+ }
+
+ @AfterClass
+ public static void tearDown() {
+ repository.close();
+ }
+}
diff --git a/mysports/application/src/test/java/eclipselink/example/mysports/application/test/TestSchemaCreation.java b/mysports/application/src/test/java/eclipselink/example/mysports/application/test/TestSchemaCreation.java
new file mode 100644
index 0000000..e5c5d9b
--- /dev/null
+++ b/mysports/application/src/test/java/eclipselink/example/mysports/application/test/TestSchemaCreation.java
@@ -0,0 +1,125 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.application.test;
+
+import java.util.Map;
+
+import javax.persistence.EntityManagerFactory;
+
+import org.eclipse.persistence.config.PersistenceUnitProperties;
+import org.eclipse.persistence.config.SessionCustomizer;
+import org.eclipse.persistence.descriptors.ClassDescriptor;
+import org.eclipse.persistence.exceptions.IntegrityChecker;
+import org.eclipse.persistence.sessions.Session;
+import org.eclipse.persistence.sessions.server.Server;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import eclipselink.example.mysports.application.model.Extensible;
+
+/**
+ * Create Schema and verify using integrity checker.
+ *
+ * @author dclarke
+ * @since EclipseLink 2.3.0
+ */
+public class TestSchemaCreation {
+
+ private static TestingLeagueRepository repository;
+
+ /**
+ * Using EclipseLink's schema generation when the
+ * {@link EntityManagerFactory} is created to drop and create the tables and
+ * sequences.
+ */
+ @Test
+ public void verifySharedMySportsSchema() throws Exception {
+ Server session = repository.unwrap(Server.class);
+
+ for (ClassDescriptor desc : session.getDescriptors().values()) {
+ Object result = session.executeSQL("SELECT COUNT(*) FROM " + desc.getTableName());
+ Assert.assertNotNull(result);
+
+ //ArrayRecord record = (ArrayRecord) ((Vector<Object>) result).get(0);
+ //Assert.assertEquals("COUNT " + desc.getTableName(), 13, ((Number) record.getValues().get(0)).intValue());
+
+ if (Extensible.class.isAssignableFrom(desc.getJavaClass())) {
+ Assert.assertNotNull(desc.getMappingForAttributeName("flex1"));
+ session.executeSQL("SELECT FLEX_1 FROM " + desc.getTableName());
+ Assert.assertNotNull(desc.getMappingForAttributeName("flex2"));
+ session.executeSQL("SELECT FLEX_2 FROM " + desc.getTableName());
+ Assert.assertNotNull(desc.getMappingForAttributeName("flex3"));
+ session.executeSQL("SELECT FLEX_3 FROM " + desc.getTableName());
+ Assert.assertNotNull(desc.getMappingForAttributeName("flex4"));
+ session.executeSQL("SELECT FLEX_4 FROM " + desc.getTableName());
+ Assert.assertNotNull(desc.getMappingForAttributeName("flex5"));
+ session.executeSQL("SELECT FLEX_5 FROM " + desc.getTableName());
+ }
+ }
+ }
+
+
+ /**
+ * Verify the schema using the integrity checker to compare database
+ * structure to that expected in the mappings.
+ */
+ @Test
+ public void integrityCheckSharedMySportsSchema() {
+ Map<String, Object> properties = repository.get();
+
+ properties.put(PersistenceUnitProperties.SESSION_CUSTOMIZER, EnableIntegrityChecker.class.getName());
+ properties.put(PersistenceUnitProperties.DEPLOY_ON_STARTUP, Boolean.TRUE.toString());
+ properties.put(PersistenceUnitProperties.MULTITENANT_SHARED_EMF, Boolean.TRUE.toString());
+ properties.put("javax.persistence.provider", "org.eclipse.persistence.jpa.PersistenceProvider");
+
+ repository.setLeagueId("ALL", properties);
+
+ Server session = repository.unwrap(Server.class);
+
+ IntegrityChecker ic = session.getIntegrityChecker();
+ Assert.assertNotNull(ic);
+ Assert.assertTrue(ic.getCaughtExceptions().isEmpty());
+ }
+
+ @BeforeClass
+ public static void createLeagueRepository() {
+ repository = new TestingLeagueRepository();
+ repository.setLeagueId("OSL", null);
+ }
+
+ @AfterClass
+ public static void closeLeagueRepository() {
+ if (repository != null) {
+ repository.close();
+ }
+ }
+
+ /**
+ * {@link SessionCustomizer} that enables the {@link IntegrityChecker}.
+ *
+ * NOTE: If another {@link SessionCustomizer} is specified in the
+ * persistence.xml this one will replace it.
+ */
+ public static class EnableIntegrityChecker implements SessionCustomizer {
+
+ public void customize(Session session) throws Exception {
+ IntegrityChecker ic = new IntegrityChecker();
+ ic.setShouldCheckDatabase(true);
+ session.setIntegrityChecker(ic);
+ }
+
+ }
+
+}
diff --git a/mysports/application/src/test/java/eclipselink/example/mysports/application/test/TestingLeagueRepository.java b/mysports/application/src/test/java/eclipselink/example/mysports/application/test/TestingLeagueRepository.java
new file mode 100644
index 0000000..e9b3534
--- /dev/null
+++ b/mysports/application/src/test/java/eclipselink/example/mysports/application/test/TestingLeagueRepository.java
@@ -0,0 +1,126 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.application.test;
+
+import java.util.Map;
+
+import org.eclipse.persistence.config.PersistenceUnitProperties;
+import org.eclipse.persistence.exceptions.DatabaseException;
+import org.eclipse.persistence.sessions.server.Server;
+
+import eclipselink.example.mysports.admin.services.HostedLeagueRepository;
+import eclipselink.example.mysports.admin.services.test.AdminPersistenceTesting;
+import eclipselink.example.mysports.application.services.LeagueRepository;
+
+/**
+ * Add testing specific properties to override the non-JTA data-source
+ * configured in the persistence.xml.
+ *
+ * @author dclarke
+ * @since EclipseLink 2.3.0
+ */
+public class TestingLeagueRepository extends LeagueRepository {
+ private static final long serialVersionUID = 1L;
+
+ public TestingLeagueRepository() {
+ super(new MockAdminServerConnector());
+ }
+
+ public TestingLeagueRepository(String leagueId) {
+ super(new MockAdminServerConnector());
+ setLeagueId(leagueId, get(leagueId));
+ }
+
+ @Override
+ public void setLeagueId(String leagueId, Map<String, Object> properties) {
+ super.setLeagueId(leagueId, add(leagueId, properties));
+ }
+
+ public MockAdminServerConnector getMockAdminConnector() {
+ return (MockAdminServerConnector) super.getAdminConnector();
+ }
+
+ public HostedLeagueRepository getHostedLeagueRepository() {
+ return getMockAdminConnector().getRepository();
+ }
+
+ @Override
+ public void close() {
+ AdminPersistenceTesting.closeTestingRepository(getMockAdminConnector().getRepository(), false);
+
+ super.close();
+ }
+
+ public Map<String, Object> add(String leagueId, Map<String, Object> properties) {
+ Map<String, Object> props = AdminPersistenceTesting.add(properties);
+
+ if (leagueId != null) {
+ props.put(PersistenceUnitProperties.METADATA_SOURCE, getAdminConnector());
+ }
+ return props;
+ }
+
+ public Map<String, Object> get(String leagueId) {
+ return add(leagueId, null);
+ }
+
+ public Map<String, Object> get() {
+ return add(null, null);
+ }
+
+ public void createSharedMySportsSchema() {
+ Map<String, Object> properties = get("ALL");
+
+ properties.put(PersistenceUnitProperties.DDL_GENERATION, PersistenceUnitProperties.DROP_AND_CREATE);
+ properties.put(PersistenceUnitProperties.DDL_GENERATION_MODE, PersistenceUnitProperties.DDL_DATABASE_GENERATION);
+ properties.put(PersistenceUnitProperties.ALLOW_NATIVE_SQL_QUERIES, "true");
+
+ setLeagueId("ALL", properties);
+ }
+
+ public void dropLeagueTables(String leagueId) {
+ Map<String, Object> properties = get(leagueId);
+ properties.put(PersistenceUnitProperties.ALLOW_NATIVE_SQL_QUERIES, "true");
+ setLeagueId(leagueId, properties);
+
+ Server session = unwrap(Server.class);
+
+ try {
+ session.executeNonSelectingSQL("DROP TABLE MYS_PLAYER_" + leagueId);
+ } catch (DatabaseException dbe) {
+ }
+ try {
+ session.executeNonSelectingSQL("DROP TABLE MYS_TEAM_" + leagueId);
+ } catch (DatabaseException dbe) {
+ }
+ try {
+ session.executeNonSelectingSQL("DROP TABLE MYS_DIV_" + leagueId);
+ } catch (DatabaseException dbe) {
+ }
+ }
+
+ public void createLeagueTables(String leagueId) {
+ Map<String, Object> properties = get(leagueId);
+ properties.put(PersistenceUnitProperties.ALLOW_NATIVE_SQL_QUERIES, "true");
+ setLeagueId(leagueId, properties);
+
+ Server session = unwrap(Server.class);
+ try {
+ session.executeNonSelectingSQL("CREATE TABLE MYS_DIV_" + leagueId + " (ID INTEGER NOT NULL, DEF_DIV INTEGER default 0, NAME VARCHAR(255), FLEX_1 VARCHAR(255), FLEX_2 VARCHAR(255), FLEX_3 VARCHAR(255), FLEX_4 VARCHAR(255), FLEX_5 VARCHAR(255), VERSION INTEGER, PRIMARY KEY (ID))");
+ session.executeNonSelectingSQL("CREATE TABLE MYS_PLAYER_" + leagueId + " (ID INTEGER NOT NULL, EMAIL VARCHAR(255), F_NAME VARCHAR(255), L_NAME VARCHAR(255), NUM INTEGER, FLEX_1 VARCHAR(255), FLEX_2 VARCHAR(255), FLEX_3 VARCHAR(255), FLEX_4 VARCHAR(255), FLEX_5 VARCHAR(255), USER_ID VARCHAR(255), VERSION INTEGER, TEAM_ID INTEGER, PRIMARY KEY (ID))");
+ session.executeNonSelectingSQL("CREATE TABLE MYS_TEAM_" + leagueId + " (ID INTEGER NOT NULL, NAME VARCHAR(255), FLEX_1 VARCHAR(255), FLEX_2 VARCHAR(255), FLEX_3 VARCHAR(255), FLEX_4 VARCHAR(255), FLEX_5 VARCHAR(255), VERSION INTEGER, DIVISION_ID INTEGER, PRIMARY KEY (ID))");
+ } catch (DatabaseException e) {
+
+ }
+ }
+}
diff --git a/mysports/application/src/test/java/eclipselink/example/mysports/examples/ExampleLeague.java b/mysports/application/src/test/java/eclipselink/example/mysports/examples/ExampleLeague.java
new file mode 100644
index 0000000..b05845a
--- /dev/null
+++ b/mysports/application/src/test/java/eclipselink/example/mysports/examples/ExampleLeague.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.examples;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import eclipselink.example.mysports.admin.examples.ExampleLeagueDefinition;
+import eclipselink.example.mysports.application.model.Division;
+import eclipselink.example.mysports.application.services.LeagueRepository;
+
+public abstract class ExampleLeague {
+
+ private ExampleLeagueDefinition definition;
+
+ private List<Division> divisions = new ArrayList<Division>();
+
+ public ExampleLeague(ExampleLeagueDefinition definition) {
+ super();
+ this.definition = definition;
+ }
+
+ public ExampleLeagueDefinition getDefinition() {
+ return definition;
+ }
+
+ public List<Division> getDivisions() {
+ return divisions;
+ }
+
+ public abstract void populate(LeagueRepository repository);
+
+ public boolean usesSharedSchema() {
+ return getDefinition().getLeague().isShared();
+ }
+
+ public String getId() {
+ return getDefinition().getLeague().getId();
+ }
+}
\ No newline at end of file
diff --git a/mysports/application/src/test/java/eclipselink/example/mysports/examples/HighTechHockey.java b/mysports/application/src/test/java/eclipselink/example/mysports/examples/HighTechHockey.java
new file mode 100644
index 0000000..1f69f51
--- /dev/null
+++ b/mysports/application/src/test/java/eclipselink/example/mysports/examples/HighTechHockey.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.examples;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+
+import eclipselink.example.mysports.admin.examples.ExampleLeagueDefinition;
+import eclipselink.example.mysports.application.model.Division;
+import eclipselink.example.mysports.application.model.Player;
+import eclipselink.example.mysports.application.services.LeagueRepository;
+
+public class HighTechHockey extends ExampleLeague {
+
+ public HighTechHockey() {
+ super(ExampleLeagueDefinition.HTHL);
+ }
+
+ public static final String LEAGUE = "HTHL";
+
+ private static final String[] POSITIONS = new String[] { "R", "L", "C", "D" };
+
+ public void populate(LeagueRepository repository) {
+ repository.setLeagueId(LEAGUE, null);
+
+ Division div1 = repository.addDivision("Div_1");
+ repository.addTeam("Aces", createPlayers(12), div1);
+ repository.addTeam("Leafs", createPlayers(12), div1);
+ repository.addTeam("Pucks", createPlayers(12), div1);
+ repository.addTeam("Meteors", createPlayers(12), div1);
+ repository.addTeam("Rockets", createPlayers(12), div1);
+ repository.addTeam("Jets", createPlayers(12), div1);
+ repository.addTeam("Tigers", createPlayers(12), div1);
+ repository.addTeam("Barons", createPlayers(12), div1);
+ getDivisions().add(div1);
+
+ Division div2 = repository.addDivision("Div_2");
+ repository.addTeam("Slapshots", createPlayers(9), div2);
+ repository.addTeam("Dragons", createPlayers(12), div2);
+ repository.addTeam("Fury", createPlayers(12), div2);
+ repository.addTeam("Cougars", createPlayers(12), div2);
+ repository.addTeam("Flyers", createPlayers(12), div2);
+ repository.addTeam("Lizards", createPlayers(12), div2);
+ getDivisions().add(div2);
+ }
+
+ List<Player> createPlayers(int num) {
+ List<Player> players = new ArrayList<Player>();
+ Random random = new Random();
+
+ for (int index = 0; index < num; index++) {
+ Player p = PlayerFactory.createPlayer();
+ p.set("penaltyMinutes", String.valueOf(random.nextInt(100)));
+ p.set("position", POSITIONS[random.nextInt(POSITIONS.length)]);
+ players.add(p);
+ }
+
+ return players;
+ }
+
+}
diff --git a/mysports/application/src/test/java/eclipselink/example/mysports/examples/KidsFootballLeague.java b/mysports/application/src/test/java/eclipselink/example/mysports/examples/KidsFootballLeague.java
new file mode 100644
index 0000000..8dc6ef1
--- /dev/null
+++ b/mysports/application/src/test/java/eclipselink/example/mysports/examples/KidsFootballLeague.java
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.examples;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+
+import eclipselink.example.mysports.admin.examples.ExampleLeagueDefinition;
+import eclipselink.example.mysports.application.model.Division;
+import eclipselink.example.mysports.application.model.Player;
+import eclipselink.example.mysports.application.services.LeagueRepository;
+
+/**
+ * @author dclarke
+ * @since EclipseLink 2.3.0
+ */
+public class KidsFootballLeague extends ExampleLeague {
+
+ public KidsFootballLeague() {
+ super(ExampleLeagueDefinition.KFL);
+ }
+
+ public void populate(LeagueRepository repository) {
+ repository.setLeagueId(getId(), null);
+
+ Division mite = repository.addDivision("Mite");
+ repository.addTeam("Scorpions", createPlayers(15), mite);
+ repository.addTeam("Bears", createPlayers(15), mite);
+ repository.addTeam("Dragons", createPlayers(15), mite);
+ repository.addTeam("Gorillas", createPlayers(15), mite);
+ repository.addTeam("Peaches", createPlayers(15), mite);
+ getDivisions().add(mite);
+
+ Division tyke = repository.addDivision("Tyke");
+ repository.addTeam("Blazers", createPlayers(28), tyke);
+ repository.addTeam("Gladiators", createPlayers(28), tyke);
+ repository.addTeam("Ducks", createPlayers(28), tyke);
+ repository.addTeam("Pirates", createPlayers(28), tyke);
+ repository.addTeam("Crusaders", createPlayers(28), tyke);
+ getDivisions().add(tyke);
+
+ Division mosquito = repository.addDivision("Mosquito");
+ repository.addTeam("Blazers", createPlayers(28), mosquito);
+ repository.addTeam("Gladiators", createPlayers(28), mosquito);
+ repository.addTeam("Ducks", createPlayers(28), mosquito);
+ repository.addTeam("Pirates", createPlayers(28), mosquito);
+ repository.addTeam("Crusaders", createPlayers(28), mosquito);
+ getDivisions().add(mosquito);
+ }
+
+ private static final String[] POSITIONS = new String[] { "Center", "Offensive Guard", "Offensive Tackle", "Tight End", "Wide Receiver", "Full Back", "Running Back", "Quarter Back", "Defensive End", "Defensive Tackle", "Nose Guard", "Linebacker", "Cornerback", "Safety" };
+
+ private List<Player> createPlayers(int num) {
+ List<Player> players = new ArrayList<Player>();
+ Random random = new Random();
+
+ for (int index = 0; index < num; index++) {
+ Player p = PlayerFactory.createPlayer();
+ p.setEmail(p.getFirstName() + "." + p.getLastName() + "@email.com");
+ p.set("position", POSITIONS[random.nextInt(POSITIONS.length)]);
+ players.add(p);
+ }
+
+ return players;
+ }
+
+}
diff --git a/mysports/application/src/test/java/eclipselink/example/mysports/examples/MinorHockeyLeague.java b/mysports/application/src/test/java/eclipselink/example/mysports/examples/MinorHockeyLeague.java
new file mode 100644
index 0000000..32b1217
--- /dev/null
+++ b/mysports/application/src/test/java/eclipselink/example/mysports/examples/MinorHockeyLeague.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.examples;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+
+import eclipselink.example.mysports.admin.examples.ExampleLeagueDefinition;
+import eclipselink.example.mysports.application.model.Division;
+import eclipselink.example.mysports.application.model.Player;
+import eclipselink.example.mysports.application.services.LeagueRepository;
+
+public class MinorHockeyLeague extends ExampleLeague {
+
+ public MinorHockeyLeague() {
+ super(ExampleLeagueDefinition.MHL);
+ }
+
+ private final static String[][] teamNames = { { "Novice", "Aces", "Bruins", "Capitals", "Devils", "Eagles", "Flyers", "Giants", "" }, { "Atom", "Aces", "Bruins", "Capitals", "Devils", "Eagles", "Flyers", "Giants", "" }, { "PeeWee", "Aces", "Bruins", "Capitals", "Devils", "Eagles", "Flyers", "Giants", "" }, { "Bantam", "Aces", "Bruins", "Capitals", "Devils", "Eagles", "Flyers", "Giants", "" }, { "Midget", "Aces", "Bruins", "Capitals", "Devils", "Eagles", "Flyers", "Giants", "" }, { "Juvenile", "Aces", "Bruins", "Capitals", "Devils", "Eagles", "Flyers", "Giants", "" }, };
+
+ public void populate(LeagueRepository repository) {
+ repository.setLeagueId(getId(), null);
+
+ for (int divIndex = 0; divIndex < teamNames.length; divIndex++) {
+ Division div = repository.addDivision(teamNames[divIndex][0]);
+ for (int teamIndex = 1; teamIndex < teamNames[divIndex].length; teamIndex++) {
+ repository.addTeam(teamNames[divIndex][teamIndex], createPlayers(16), div);
+ }
+ getDivisions().add(div);
+ }
+ }
+
+ private static final String[] POSITIONS = new String[] { "R", "L", "C", "D" };
+
+ private List<Player> createPlayers(int num) {
+ List<Player> players = new ArrayList<Player>();
+ Random random = new Random();
+
+ for (int index = 0; index < num; index++) {
+ Player p = PlayerFactory.createPlayer();
+ p.set("penaltyMinutes", random.nextInt(100));
+ p.set("position", POSITIONS[random.nextInt(POSITIONS.length)]);
+ players.add(p);
+ }
+
+ return players;
+ }
+
+}
diff --git a/mysports/application/src/test/java/eclipselink/example/mysports/examples/OttawaSoccerLeague.java b/mysports/application/src/test/java/eclipselink/example/mysports/examples/OttawaSoccerLeague.java
new file mode 100644
index 0000000..35af2a4
--- /dev/null
+++ b/mysports/application/src/test/java/eclipselink/example/mysports/examples/OttawaSoccerLeague.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.examples;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+
+import eclipselink.example.mysports.admin.examples.ExampleLeagueDefinition;
+import eclipselink.example.mysports.application.model.Division;
+import eclipselink.example.mysports.application.model.Player;
+import eclipselink.example.mysports.application.services.LeagueRepository;
+
+/**
+ * @author dclarke
+ * @since EclipseLink 2.3.0
+ */
+public class OttawaSoccerLeague extends ExampleLeague {
+
+ public Division u6;
+ public Division u8;
+
+ public OttawaSoccerLeague() {
+ super(ExampleLeagueDefinition.OSL);
+ }
+
+ public void populate(LeagueRepository repository) {
+ repository.setLeagueId(getId(), null);
+
+ u6 = repository.addDivision("U6");
+ repository.addTeam("Scorpions", createPlayers(11), u6);
+ repository.addTeam("Bears", createPlayers(11), u6);
+ repository.addTeam("Dragons", createPlayers(11), u6);
+ repository.addTeam("Gorillas", createPlayers(11), u6);
+ repository.addTeam("Peaches", createPlayers(11), u6);
+ getDivisions().add(u6);
+
+ u8 = repository.addDivision("U8");
+ repository.addTeam("Blazers", createPlayers(12), u8);
+ repository.addTeam("Gladiators", createPlayers(12), u8);
+ repository.addTeam("Ducks", createPlayers(12), u8);
+ repository.addTeam("Pirates", createPlayers(12), u8);
+ repository.addTeam("Crusaders", createPlayers(12), u8);
+ getDivisions().add(u8);
+ }
+
+ private static final String[] ALLERGIES = new String[] { "NONE", "NONE", "NONE", "PEANUT", "MILK" };
+
+ private List<Player> createPlayers(int num) {
+ List<Player> players = new ArrayList<Player>();
+ Random random = new Random();
+
+ for (int index = 0; index < num; index++) {
+ Player p = PlayerFactory.createPlayer();
+ p.setEmail(p.getFirstName() + "." + p.getLastName() + "@email.com");
+ p.set("allergies", ALLERGIES[random.nextInt(ALLERGIES.length)]);
+ players.add(p);
+ }
+
+ return players;
+ }
+
+}
diff --git a/mysports/application/src/test/java/eclipselink/example/mysports/examples/PlayerFactory.java b/mysports/application/src/test/java/eclipselink/example/mysports/examples/PlayerFactory.java
new file mode 100644
index 0000000..116044b
--- /dev/null
+++ b/mysports/application/src/test/java/eclipselink/example/mysports/examples/PlayerFactory.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.examples;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+
+import eclipselink.example.mysports.application.model.Player;
+
+/**
+ * Simple utility for generating players with random names.
+ *
+ * @author dclarke
+ * @since EclipseLink 2.3.0
+ */
+public class PlayerFactory {
+
+ private static String[] FIRST_NAMES = new String[] { "John", "Ted", "Phil", "Jason", "Bill", "Jim", "Martin", "Sam", "Tim", "Rob" };
+
+ private static String[] LAST_NAMES = new String[] { "Orr", "Smith", "Johnson", "Williams", "Jones", "Brown", "Davis", "Miller", "Wilson", "Moore", "Taylor" };
+
+ public static Player createPlayer() {
+ Random random = new Random();
+
+ Player p = new Player();
+ p.setNumber(random.nextInt(99) + 1);
+ p.setFirstName(FIRST_NAMES[random.nextInt(FIRST_NAMES.length)]);
+ p.setLastName(LAST_NAMES[random.nextInt(LAST_NAMES.length)]);
+ return p;
+ }
+
+ public static List<Player> createPlayers(int num) {
+ List<Player> players = new ArrayList<Player>();
+
+ for (int index = 0; index < num; index++) {
+ players.add(createPlayer());
+ }
+
+ return players;
+ }
+
+}
diff --git a/mysports/application/src/test/resources/META-INF/flex-columns-orm.xml b/mysports/application/src/test/resources/META-INF/flex-columns-orm.xml
new file mode 100644
index 0000000..b5a8857
--- /dev/null
+++ b/mysports/application/src/test/resources/META-INF/flex-columns-orm.xml
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<entity-mappings version="2.4"
+ xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/orm"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.eclipse.org/eclipselink/xsds/persistence/orm http://www.eclipse.org/eclipselink/xsds/eclipselink_orm_2_4.xsd">
+
+ <package>eclipselink.example.mysports.application.model</package>
+
+ <entity class="Division">
+ <attributes>
+ <basic name="flex1" attribute-type="String">
+ <column name="FLEX_1" />
+ </basic>
+ <basic name="flex2" attribute-type="String">
+ <column name="FLEX_2" />
+ </basic>
+ <basic name="flex3" attribute-type="String">
+ <column name="FLEX_3" />
+ </basic>
+ <basic name="flex4" attribute-type="String">
+ <column name="FLEX_4" />
+ </basic>
+ <basic name="flex5" attribute-type="String">
+ <column name="FLEX_5" />
+ </basic>
+ </attributes>
+ </entity>
+
+ <entity class="Team">
+ <attributes>
+ <basic name="flex1" attribute-type="String">
+ <column name="FLEX_1" />
+ </basic>
+ <basic name="flex2" attribute-type="String">
+ <column name="FLEX_2" />
+ </basic>
+ <basic name="flex3" attribute-type="String">
+ <column name="FLEX_3" />
+ </basic>
+ <basic name="flex4" attribute-type="String">
+ <column name="FLEX_4" />
+ </basic>
+ <basic name="flex5" attribute-type="String">
+ <column name="FLEX_5" />
+ </basic>
+ </attributes>
+ </entity>
+
+ <entity class="Player">
+ <attributes>
+ <basic name="flex1" attribute-type="String">
+ <column name="FLEX_1" />
+ </basic>
+ <basic name="flex2" attribute-type="String">
+ <column name="FLEX_2" />
+ </basic>
+ <basic name="flex3" attribute-type="String">
+ <column name="FLEX_3" />
+ </basic>
+ <basic name="flex4" attribute-type="String">
+ <column name="FLEX_4" />
+ </basic>
+ <basic name="flex5" attribute-type="String">
+ <column name="FLEX_5" />
+ </basic>
+ </attributes>
+ </entity>
+</entity-mappings>
diff --git a/mysports/application/src/test/resources/eclipselink-example-mysports.properties b/mysports/application/src/test/resources/eclipselink-example-mysports.properties
new file mode 100644
index 0000000..d5daa1f
--- /dev/null
+++ b/mysports/application/src/test/resources/eclipselink-example-mysports.properties
@@ -0,0 +1,22 @@
+javax.persistence.jdbc.url=jdbc:derby:target/derby/mysports;create=true
+javax.persistence.jdbc.user=app
+javax.persistence.jdbc.password=app
+javax.persistence.jdbc.driver=org.apache.derby.jdbc.EmbeddedDriver
+
+eclipselink.jdbc.uppercase-columns=true
+eclipselink.jdbc.allow-native-sql-queries=true
+
+# Ensure that the data source info in persistence.xml is replaced
+javax.persistence.jtaDataSource=
+javax.persistence.nonJtaDataSource=
+javax.persistence.transactionType=RESOURCE_LOCAL
+
+eclipselink.logging.level=FINE
+eclipselink.logging.connection=false
+eclipselink.logging.timestamp=false
+eclipselink.logging.thread=false
+eclipselink.logging.session=false
+eclipselink.logging.exceptions=false
+eclipselink.logging.level.sql=FINE
+eclipselink.logging.level.metadata=WARNING
+eclipselink.logging.parameters=true
\ No newline at end of file
diff --git a/mysports/persistence/.classpath b/mysports/persistence/.classpath
new file mode 100644
index 0000000..778be37
--- /dev/null
+++ b/mysports/persistence/.classpath
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" output="target/classes" path="src/main/java">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/java">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ <attribute name="org.eclipse.jst.component.nondependency" value=""/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
+ <attributes>
+ <attribute name="owner.project.facets" value="java"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
diff --git a/mysports/persistence/.project b/mysports/persistence/.project
new file mode 100644
index 0000000..0e09c8b
--- /dev/null
+++ b/mysports/persistence/.project
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>mysports.persistence</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.wst.common.project.facet.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.wst.validation.validationbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.m2e.core.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
+ <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.m2e.core.maven2Nature</nature>
+ <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+ </natures>
+</projectDescription>
diff --git a/mysports/persistence/.settings/org.eclipse.jdt.core.prefs b/mysports/persistence/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..69c31cd
--- /dev/null
+++ b/mysports/persistence/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/mysports/persistence/.settings/org.eclipse.m2e.core.prefs b/mysports/persistence/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 0000000..f897a7f
--- /dev/null
+++ b/mysports/persistence/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/mysports/persistence/.settings/org.eclipse.wst.common.component b/mysports/persistence/.settings/org.eclipse.wst.common.component
new file mode 100644
index 0000000..dbb2c53
--- /dev/null
+++ b/mysports/persistence/.settings/org.eclipse.wst.common.component
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
+ <wb-module deploy-name="mysports.persistence">
+ <wb-resource deploy-path="/" source-path="/src/main/java"/>
+ <wb-resource deploy-path="/" source-path="/src/main/resources"/>
+ </wb-module>
+</project-modules>
diff --git a/mysports/persistence/.settings/org.eclipse.wst.common.project.facet.core.xml b/mysports/persistence/.settings/org.eclipse.wst.common.project.facet.core.xml
new file mode 100644
index 0000000..5c9bd75
--- /dev/null
+++ b/mysports/persistence/.settings/org.eclipse.wst.common.project.facet.core.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+ <installed facet="jst.utility" version="1.0"/>
+ <installed facet="java" version="1.6"/>
+</faceted-project>
diff --git a/mysports/persistence/pom.xml b/mysports/persistence/pom.xml
new file mode 100644
index 0000000..d3c408f
--- /dev/null
+++ b/mysports/persistence/pom.xml
@@ -0,0 +1,99 @@
+<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>
+
+ <parent>
+ <groupId>eclipselink.example.mysports</groupId>
+ <artifactId>bom</artifactId>
+ <version>2.4.2-SNAPSHOT</version>
+ <relativePath>..</relativePath>
+ </parent>
+
+ <artifactId>persistence</artifactId>
+ <packaging>jar</packaging>
+ <name>MySports Persistence</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>${eclipselink.groupid}</groupId>
+ <artifactId>${eclipselink.artifactid}</artifactId>
+ <version>${eclipselink.version}</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>commonj.sdo</artifactId>
+ <groupId>commonj.sdo</groupId>
+ </exclusion>
+ </exclusions>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.derby</groupId>
+ <artifactId>derby</artifactId>
+ <version>10.9.1.0</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifestEntries>
+ <Premain-Class>eclipselink.example.mysports.persistence.TenantPerEMFWeavingAgent</Premain-Class>
+ </manifestEntries>
+ </archive>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.12.4</version>
+ <configuration>
+ <systemProperties>
+ <property>
+ <name>derby.stream.error.file</name>
+ <value>target/derby.log</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.4</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-report-plugin</artifactId>
+ <version>2.12.4</version>
+ </plugin>
+ </plugins>
+ </reporting>
+
+</project>
diff --git a/mysports/persistence/src/main/java/eclipselink/example/mysports/persistence/TenantPerEMFProvider.java b/mysports/persistence/src/main/java/eclipselink/example/mysports/persistence/TenantPerEMFProvider.java
new file mode 100644
index 0000000..d22bec0
--- /dev/null
+++ b/mysports/persistence/src/main/java/eclipselink/example/mysports/persistence/TenantPerEMFProvider.java
@@ -0,0 +1,86 @@
+/**
+ * *****************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved. This program and the
+ * accompanying materials are made available under the terms of the Eclipse
+ * Public License v1.0 and Eclipse Distribution License v. 1.0 which accompanies
+ * this distribution. The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html and the Eclipse Distribution
+ * License is available at http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors: dclarke - EclipseLink 2.4 - MySports Demo Bug 344608
+ * ****************************************************************************
+ */
+package eclipselink.example.mysports.persistence;
+
+import java.util.HashMap;
+import java.util.Map;
+import javax.persistence.EntityManagerFactory;
+import org.eclipse.persistence.config.PersistenceUnitProperties;
+import org.eclipse.persistence.internal.jpa.deployment.JPAInitializer;
+import org.eclipse.persistence.jpa.PersistenceProvider;
+
+/**
+ * Custom {@link javax.persistence.spi.PersistenceProvider} to support the
+ * TODO
+ *
+ * @author dclarke
+ * @since EclipseLink 2.4
+ */
+@SuppressWarnings({"rawtypes", "unchecked"})
+public class TenantPerEMFProvider extends PersistenceProvider {
+
+ /**
+ * TODO
+ */
+ public static final String PROVIDER_CLASS = "eclipselink.example.mysports.persistence.TenantPerEMFProvider";
+
+ /**
+ * TODO
+ */
+ public static final String SEPARATOR = ";";
+ /**
+ * Tenant PU name prefix used to identify the tenant specific PU creation
+ * request.
+ */
+ public static final String EQUALS = "=";
+
+ @Override
+ public EntityManagerFactory createEntityManagerFactory(String name, Map properties) {
+ int sepIndex = name == null ? 0 : name.indexOf(SEPARATOR);
+
+ if (name != null && !name.isEmpty() && sepIndex >= 0) {
+ if (sepIndex == 0) {
+ throw new IllegalArgumentException("Invalid tenant PU name");
+ }
+
+ String puName = name.substring(0, sepIndex);
+
+ int equalsIndex = name.indexOf(EQUALS);
+
+ if (equalsIndex <= sepIndex + 1) {
+ throw new IllegalArgumentException("Invalid tenant PU name");
+ }
+
+ String contextProperty = name.substring(sepIndex + 1, equalsIndex);
+ String contextValue = name.substring(equalsIndex + 1);
+
+ Map props = properties == null ? new HashMap() : properties;
+
+ if (!props.containsKey(PersistenceUnitProperties.SESSION_NAME)) {
+ props.put(PersistenceUnitProperties.SESSION_NAME, name);
+ }
+ props.put(PersistenceUnitProperties.MULTITENANT_SHARED_EMF, Boolean.FALSE.toString());
+ props.put(contextProperty, contextValue);
+
+ return super.createEntityManagerFactory(puName, props);
+ }
+
+ return super.createEntityManagerFactory(name, properties);
+ }
+
+ @Override
+ public JPAInitializer getInitializer(String emName, Map m) {
+ ClassLoader classLoader = getClassLoader(emName, m);
+ return TenantPerEMFProviderInitializer.getJavaSECMPInitializer(classLoader);
+ }
+}
diff --git a/mysports/persistence/src/main/java/eclipselink/example/mysports/persistence/TenantPerEMFProviderInitializer.java b/mysports/persistence/src/main/java/eclipselink/example/mysports/persistence/TenantPerEMFProviderInitializer.java
new file mode 100644
index 0000000..613487e
--- /dev/null
+++ b/mysports/persistence/src/main/java/eclipselink/example/mysports/persistence/TenantPerEMFProviderInitializer.java
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.4 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.persistence;
+
+import java.lang.instrument.Instrumentation;
+import java.util.HashMap;
+import java.util.Map;
+import org.eclipse.persistence.internal.jpa.deployment.JavaSECMPInitializer;
+import org.eclipse.persistence.logging.AbstractSessionLog;
+import org.eclipse.persistence.logging.SessionLog;
+
+
+/**
+ * Custom initializer to support {@link TenantPerEMFProvider} usage.
+ * This subclass is required to ensure
+ * {@link #isPersistenceProviderSupported(String)} passes when using the custom
+ * provider as well as storing its own singlton instance of this initializer and
+ * avoid conflicting with the default EclipseLink JPA provider's initializer.
+ *
+ * @author dclarke
+ * @since EclipseLink 2.4
+ */
+@SuppressWarnings("rawtypes")
+public class TenantPerEMFProviderInitializer extends JavaSECMPInitializer {
+
+ // Indicates whether has been initialized - that could be done only once.
+ protected static boolean isInitialized;
+ // Singleton corresponding to the main class loader. Created only if agent
+ // is used.
+ protected static JavaSECMPInitializer initializer;
+
+ public static boolean isInContainer() {
+ return isInContainer;
+ }
+
+ public static void setIsInContainer(boolean isInContainer) {
+ JavaSECMPInitializer.isInContainer = isInContainer;
+ }
+
+ /**
+ * Get the singleton entityContainer.
+ */
+ public static JavaSECMPInitializer getJavaSECMPInitializer() {
+ return getJavaSECMPInitializer(Thread.currentThread().getContextClassLoader(), null, false);
+ }
+
+ public static JavaSECMPInitializer getJavaSECMPInitializer(ClassLoader classLoader) {
+ return getJavaSECMPInitializer(classLoader, null, false);
+ }
+
+ public static JavaSECMPInitializer getJavaSECMPInitializerFromAgent() {
+ return getJavaSECMPInitializer(Thread.currentThread().getContextClassLoader(), null, true);
+ }
+
+ public static JavaSECMPInitializer getJavaSECMPInitializerFromMain(Map m) {
+ return getJavaSECMPInitializer(Thread.currentThread().getContextClassLoader(), m, false);
+ }
+
+ public static JavaSECMPInitializer getJavaSECMPInitializer(ClassLoader classLoader, Map m, boolean fromAgent) {
+ if (!isInitialized) {
+ if (globalInstrumentation != null) {
+ synchronized (initializationLock) {
+ if (!isInitialized) {
+ initializeTopLinkLoggingFile();
+ if (fromAgent) {
+ AbstractSessionLog.getLog().log(SessionLog.FINER, SessionLog.WEAVER, "cmp_init_initialize_from_agent", (Object[]) null);
+ }
+ usesAgent = true;
+ initializer = new TenantPerEMFProviderInitializer(classLoader);
+ initializer.initialize(m != null ? m : new HashMap(0));
+ // all the transformers have been added to
+ // instrumentation, don't need it any more.
+ globalInstrumentation = null;
+ }
+ }
+ }
+ isInitialized = true;
+ }
+ if (initializer != null && initializer.getInitializationClassLoader() == classLoader) {
+ return initializer;
+ } else {
+ // when agent is not used initializer does not need to be
+ // initialized.
+ return new TenantPerEMFProviderInitializer(classLoader);
+ }
+ }
+
+ /**
+ * INTERNAL: Should be called only by the agent. (when weaving classes) If
+ * succeeded return true, false otherwise.
+ */
+ protected static void initializeFromAgent(Instrumentation instrumentation) throws Exception {
+ // Squirrel away the instrumentation for later
+ globalInstrumentation = instrumentation;
+ getJavaSECMPInitializerFromAgent();
+ }
+
+ protected TenantPerEMFProviderInitializer(ClassLoader loader) {
+ super(loader);
+ }
+
+ @Override
+ public boolean isPersistenceProviderSupported(String providerClassName) {
+ return providerClassName != null && providerClassName.equals(TenantPerEMFProvider.PROVIDER_CLASS);
+ }
+}
diff --git a/mysports/persistence/src/main/java/eclipselink/example/mysports/persistence/TenantPerEMFWeavingAgent.java b/mysports/persistence/src/main/java/eclipselink/example/mysports/persistence/TenantPerEMFWeavingAgent.java
new file mode 100644
index 0000000..49ca5d2
--- /dev/null
+++ b/mysports/persistence/src/main/java/eclipselink/example/mysports/persistence/TenantPerEMFWeavingAgent.java
@@ -0,0 +1,62 @@
+/**
+ * *****************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved. This program and the
+ * accompanying materials are made available under the terms of the Eclipse
+ * Public License v1.0 and Eclipse Distribution License v. 1.0 which accompanies
+ * this distribution. The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html and the Eclipse Distribution
+ * License is available at http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors: dclarke - EclipseLink 2.4 - MySports Demo Bug 344608
+ *****************************************************************************
+ */
+package eclipselink.example.mysports.persistence;
+
+import java.lang.instrument.Instrumentation;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+/**
+ * Custom agent to support weaving with custom provider:
+ * {@link TenantPerEMFProvider}.
+ *
+ * @see TenantPerEMFProvider
+ * @see TenantPerEMFProviderInitializer
+ *
+ * @author dclarke
+ * @since EclipseLink 2.4
+ */
+public class TenantPerEMFWeavingAgent {
+
+ private static final String INITIALIZER_CLASS = "eclipselink.example.mysports.persistence.TenantPerEMFProviderInitializer";
+ public static final String INITIALIZE_FROM_AGENT = "initializeFromAgent";
+ public static final String GLOBAL_INSTRUMENTATION = "globalInstrumentation";
+
+ public static void premain(String agentArgs, Instrumentation instr) throws Throwable {
+ // Reflection allows:
+ // JavaSECMPInitializerAgent to be the *ONLY* class is the jar file specified in -javaagent;
+ // Loading JavaSECMPInitializer class using SystemClassLoader.
+ if ((agentArgs != null) && agentArgs.equals("main")) {
+ initializeFromMain(instr);
+ } else {
+ initializeFromAgent(instr);
+ }
+ }
+
+ public static void initializeFromAgent(Instrumentation instr) throws Throwable {
+ Class<?> cls = Class.forName(INITIALIZER_CLASS);
+ Method method = cls.getDeclaredMethod(INITIALIZE_FROM_AGENT, new Class[]{Instrumentation.class});
+ try {
+ method.invoke(null, new Object[]{instr});
+ } catch (InvocationTargetException exception) {
+ throw exception.getCause();
+ }
+ }
+
+ public static void initializeFromMain(Instrumentation instr) throws Exception {
+ Class<?> cls = Class.forName(INITIALIZER_CLASS);
+ Field field = cls.getField(GLOBAL_INSTRUMENTATION);
+ field.set(null, instr);
+ }
+}
diff --git a/mysports/persistence/src/main/resources/META-INF/MANIFEST.MF b/mysports/persistence/src/main/resources/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..79e82d2
--- /dev/null
+++ b/mysports/persistence/src/main/resources/META-INF/MANIFEST.MF
@@ -0,0 +1,11 @@
+Manifest-Version: 1.0
+Specification-Title: EclipseLink MT Provider
+Specification-Vendor: Eclipse.org - EclipseLink Project
+Specification-Version: 2.4
+Implementation-Title: org.eclipse.persistence
+Implementation-Vendor: Eclipse.org - EclipseLink Project
+Implementation-Version: 2.4
+Release-Designation: EclipseLink 2.4
+Premain-Class: eclipselink.example.mysports.persistence.TenantPerEMFWeavingAgent
+
+
diff --git a/mysports/persistence/src/main/resources/META-INF/services/javax.persistence.spi.PersistenceProvider b/mysports/persistence/src/main/resources/META-INF/services/javax.persistence.spi.PersistenceProvider
new file mode 100644
index 0000000..eeacb0b
--- /dev/null
+++ b/mysports/persistence/src/main/resources/META-INF/services/javax.persistence.spi.PersistenceProvider
@@ -0,0 +1 @@
+eclipselink.example.mysports.persistence.TenantPerEMFProvider
\ No newline at end of file
diff --git a/mysports/persistence/src/test/java/eclipselink/example/mysports/persistence/test/ConfigTest.java b/mysports/persistence/src/test/java/eclipselink/example/mysports/persistence/test/ConfigTest.java
new file mode 100644
index 0000000..e9aa40f
--- /dev/null
+++ b/mysports/persistence/src/test/java/eclipselink/example/mysports/persistence/test/ConfigTest.java
@@ -0,0 +1,20 @@
+package eclipselink.example.mysports.persistence.test;
+
+import org.junit.Test;
+
+/**
+ * Unit test for simple App.
+ */
+public class ConfigTest {
+
+ @Test
+ public void verifyProviderServices() {
+
+ }
+
+ @Test
+ public void verifyPremainInManifest() {
+
+ }
+
+}
diff --git a/mysports/persistence/src/test/java/eclipselink/example/mysports/persistence/test/ExamplePropertiesLoader.java b/mysports/persistence/src/test/java/eclipselink/example/mysports/persistence/test/ExamplePropertiesLoader.java
new file mode 100644
index 0000000..bb09100
--- /dev/null
+++ b/mysports/persistence/src/test/java/eclipselink/example/mysports/persistence/test/ExamplePropertiesLoader.java
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.persistence.test;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * Helper class that will load persistence unit overrides from a properties file
+ * in both the current running folder and the current user's home folder. The
+ * goal is to enable developers and users of the example to customize its
+ * behaviour without having to modify the source of the example.
+ *
+ * @author dclarke
+ * @since EclipseLink 2.0.0
+ */
+public class ExamplePropertiesLoader {
+
+ public static final String DEFAULT_FILENAME = "eclipselink-example-mysports.properties";
+
+ /**
+ *
+ * @param properties
+ */
+ public static void loadProperties(Map<String, Object> properties) {
+ loadProperties(properties, DEFAULT_FILENAME);
+ }
+
+ /**
+ *
+ * @param properties
+ */
+ public static void loadProperties(Map<String, Object> properties, String filename) {
+ loadProperties(properties, new File(filename));
+
+ String home = System.getProperty("user.home");
+ loadProperties(properties, new File(home + System.getProperty("file.separator") + filename));
+
+ for (Object key : System.getProperties().keySet()) {
+ String keyName = (String) key;
+
+ if (keyName.startsWith("javax.persistence") || keyName.startsWith("eclipselink")) {
+ String value = System.getProperty(keyName);
+ properties.put(keyName, value);
+ }
+ }
+ }
+
+ /**
+ *
+ * @param properties
+ * @param filePath
+ */
+ public static void loadProperties(Map<String, Object> properties, File file) {
+ try {
+ if (file.exists()) {
+ Properties exampleProps = new Properties();
+ InputStream in = new FileInputStream(file);
+ exampleProps.load(in);
+ in.close();
+
+ for (Map.Entry<Object, Object> entry: exampleProps.entrySet()) {
+ properties.put((String) entry.getKey(), entry.getValue());
+ }
+ }
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+}
diff --git a/mysports/persistence/src/test/java/eclipselink/example/mysports/persistence/test/ProviderTest.java b/mysports/persistence/src/test/java/eclipselink/example/mysports/persistence/test/ProviderTest.java
new file mode 100644
index 0000000..3c4cf8b
--- /dev/null
+++ b/mysports/persistence/src/test/java/eclipselink/example/mysports/persistence/test/ProviderTest.java
@@ -0,0 +1,78 @@
+package eclipselink.example.mysports.persistence.test;
+
+import java.util.HashMap;
+import java.util.Map;
+import javax.persistence.EntityManagerFactory;
+import org.junit.Assert;
+import org.junit.Test;
+import org.eclipse.persistence.config.PersistenceUnitProperties;
+import org.eclipse.persistence.jpa.JpaHelper;
+import org.eclipse.persistence.sessions.server.Server;
+
+import eclipselink.example.mysports.persistence.TenantPerEMFProvider;
+
+/**
+ * Unit test for simple App.
+ */
+public class ProviderTest {
+
+ @Test
+ public void testNullName() {
+ new TenantPerEMFProvider().createEntityManagerFactory(null, null);
+ }
+
+ @Test
+ public void testEmptyName() {
+ new TenantPerEMFProvider().createEntityManagerFactory("", null);
+ }
+
+ @Test
+ public void testJustSeparator() {
+ try {
+ new TenantPerEMFProvider().createEntityManagerFactory(";", null);
+ } catch (IllegalArgumentException e) {
+ return;
+ }
+ Assert.fail("IllegalArgumentException expected");
+ }
+
+ @Test
+ public void testSeparatorEquals() {
+ try {
+ new TenantPerEMFProvider().createEntityManagerFactory(";=", null);
+ } catch (IllegalArgumentException e) {
+ return;
+ }
+ Assert.fail("IllegalArgumentException expected");
+
+ }
+
+ @Test
+ public void testXSeparatorEquals() {
+ try {
+ new TenantPerEMFProvider().createEntityManagerFactory(";X=", null);
+ } catch (IllegalArgumentException e) {
+ return;
+ }
+ Assert.fail("IllegalArgumentException expected");
+
+ }
+
+ @Test
+ public void testContextX() {
+ Map<String, Object> props = new HashMap<String, Object>();
+ props.put(PersistenceUnitProperties.ECLIPSELINK_PERSISTENCE_XML,
+ "META-INF/test-persistence.xml");
+ EntityManagerFactory emf = new TenantPerEMFProvider()
+ .createEntityManagerFactory("test;context=X", props);
+
+ Assert.assertNotNull(emf);
+ Server session = JpaHelper.getServerSession(emf);
+
+ Assert.assertEquals("test;context=X", session.getName());
+
+ String context = (String) emf.getProperties().get("context");
+ Assert.assertEquals(context, "X");
+ }
+
+}
diff --git a/mysports/persistence/src/test/java/eclipselink/example/mysports/persistence/test/persistence.xml b/mysports/persistence/src/test/java/eclipselink/example/mysports/persistence/test/persistence.xml
new file mode 100644
index 0000000..d919de1
--- /dev/null
+++ b/mysports/persistence/src/test/java/eclipselink/example/mysports/persistence/test/persistence.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
+ <persistence-unit name="test" transaction-type="RESOURCE_LOCAL">
+ <provider>eclipselink.example.mysports.persistence.TenantPerEMFProvider</provider>
+ <properties>
+ <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
+ <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/mysports"/>
+ <property name="javax.persistence.jdbc.user" value="root"/>
+ <property name="javax.persistence.jdbc.password" value="password"/>
+ </properties>
+ </persistence-unit>
+</persistence>
diff --git a/mysports/persistence/src/test/java/eclipselink/example/mysports/test/common/ExamplePropertiesLoader.java b/mysports/persistence/src/test/java/eclipselink/example/mysports/test/common/ExamplePropertiesLoader.java
new file mode 100644
index 0000000..28832af
--- /dev/null
+++ b/mysports/persistence/src/test/java/eclipselink/example/mysports/test/common/ExamplePropertiesLoader.java
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * dclarke - EclipseLink 2.3 - MySports Demo Bug 344608
+ ******************************************************************************/
+package eclipselink.example.mysports.test.common;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * Helper class that will load persistence unit overrides from a properties file
+ * in both the current running folder and the current user's home folder. The
+ * goal is to enable developers and users of the example to customize its
+ * behavior without having to modify the source of the example.
+ *
+ * @author dclarke
+ * @since EclipseLink 2.0.0
+ */
+public class ExamplePropertiesLoader {
+
+ public static final String DEFAULT_FILENAME = "eclipselink-example-mysports.properties";
+
+ /**
+ *
+ * @param properties
+ */
+ public static void loadProperties(Map<String, Object> properties) {
+ loadProperties(properties, DEFAULT_FILENAME);
+ }
+
+ /**
+ *
+ * @param properties
+ */
+ public static void loadProperties(Map<String, Object> properties, String filename) {
+ loadProperties(properties, Thread.currentThread().getContextClassLoader(), filename);
+ loadProperties(properties, new File(filename));
+
+ String home = System.getProperty("user.home");
+ loadProperties(properties, new File(home + System.getProperty("file.separator") + filename));
+
+ for (Object key : System.getProperties().keySet()) {
+ String keyName = (String) key;
+
+ if (keyName.startsWith("javax.persistence") || keyName.startsWith("eclipselink")) {
+ String value = System.getProperty(keyName);
+ properties.put(keyName, value);
+ }
+ }
+ }
+
+ public static void loadProperties(Map<String, Object> properties, File file) {
+ if (file.exists()) {
+ InputStream in;
+ try {
+ in = new FileInputStream(file);
+ } catch (FileNotFoundException e) {
+ return;
+ }
+ loadProperties(properties, in);
+ }
+ }
+
+ public static void loadProperties(Map<String, Object> properties, ClassLoader cl, String resource) {
+ InputStream in = cl.getResourceAsStream(resource);
+ loadProperties(properties, in);
+ }
+
+ public static void loadProperties(Map<String, Object> properties, InputStream in) {
+ try {
+ if (in != null) {
+ Properties exampleProps = new Properties();
+ exampleProps.load(in);
+ in.close();
+
+ for (Map.Entry<Object, Object> entry : exampleProps.entrySet()) {
+ properties.put((String) entry.getKey(), entry.getValue());
+ }
+ }
+ } catch (Exception e) {
+ // ignore
+ } finally {
+ try {
+ in.close();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+
+}
diff --git a/mysports/persistence/src/test/resources/META-INF/test-persistence.xml b/mysports/persistence/src/test/resources/META-INF/test-persistence.xml
new file mode 100644
index 0000000..99ff2b7
--- /dev/null
+++ b/mysports/persistence/src/test/resources/META-INF/test-persistence.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
+ <persistence-unit name="test" transaction-type="RESOURCE_LOCAL">
+ <provider>eclipselink.example.mysports.persistence.TenantPerEMFProvider</provider>
+ <properties>
+ <property name="javax.persistence.jdbc.url" value="jdbc:derby:target/derby/test;create=true"/>
+ <property name="javax.persistence.jdbc.user" value="app"/>
+ <property name="javax.persistence.jdbc.password" value="app"/>
+ <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver"/>
+ </properties>
+ </persistence-unit>
+</persistence>
diff --git a/mysports/persistence/src/test/resources/eclipselink-example-mysports.properties b/mysports/persistence/src/test/resources/eclipselink-example-mysports.properties
new file mode 100644
index 0000000..104c7ce
--- /dev/null
+++ b/mysports/persistence/src/test/resources/eclipselink-example-mysports.properties
@@ -0,0 +1,21 @@
+javax.persistence.jdbc.url=jdbc:derby:target/derby/mysports;create=true
+javax.persistence.jdbc.user=app
+javax.persistence.jdbc.password=app
+javax.persistence.jdbc.driver=org.apache.derby.jdbc.EmbeddedDriver
+
+# Ensure that the data source info in persistence.xml is replaced
+javax.persistence.jtaDataSource=
+javax.persistence.nonJtaDataSource=
+javax.persistence.transactionType=RESOURCE_LOCAL
+
+eclipselink.logging.level=FINE
+eclipselink.logging.connection=false
+eclipselink.logging.timestamp=false
+eclipselink.logging.thread=false
+eclipselink.logging.session=false
+eclipselink.logging.exceptions=false
+eclipselink.logging.level.sql=FINE
+eclipselink.logging.level.metadata=WARNING
+eclipselink.logging.parameters=true
+
+eclipselink.jdbc.case-insensitive-columns=true
\ No newline at end of file
diff --git a/mysports/pom.xml b/mysports/pom.xml
new file mode 100644
index 0000000..d05600e
--- /dev/null
+++ b/mysports/pom.xml
@@ -0,0 +1,144 @@
+<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>eclipselink.example.mysports</groupId>
+ <artifactId>bom</artifactId>
+ <version>2.4.2-SNAPSHOT</version>
+ <packaging>pom</packaging>
+ <name>MySports BOM</name>
+ <url>http://wiki.eclipse.org/EclipseLink/Examples/MySports</url>
+ <scm>
+ <connection>git://git.eclipse.org/gitroot/eclipselink/examples/mysports.git</connection>
+ <url>http://git.eclipse.org/c/eclipselink/examples/mysports.git/</url>
+ </scm>
+ <licenses>
+ <license>
+ <name>EPL: Eclipse Public License</name>
+ <url>http://www.eclipse.org/legal/epl-v10.html</url>
+ </license>
+ <license>
+ <name>EDL: Eclipse Distribution License</name>
+ <url>http://www.eclipse.org/org/documents/edl-v10.php</url>
+ </license>
+ </licenses>
+ <developers>
+ <developer>
+ <name>Doug Clarke</name>
+ <organization>Oracle</organization>
+ <email>douglas.clarke@oracle.com</email>
+ <url>java-persistence.blogspot.com</url>
+ </developer>
+ </developers>
+
+ <properties>
+ <eclipselink.groupid>org.eclipse.persistence</eclipselink.groupid>
+ <eclipselink.artifactid>eclipselink</eclipselink.artifactid>
+ <eclipselink.version>2.4.2-SNAPSHOT</eclipselink.version>
+ </properties>
+
+ <repositories>
+ <repository>
+ <id>Java.Net</id>
+ <url>http://download.java.net/maven/2/</url>
+ </repository>
+ <repository>
+ <id>EclipseLink</id>
+ <url>http://download.eclipse.org/rt/eclipselink/maven.repo</url>
+ </repository>
+ </repositories>
+
+ <modules>
+ <module>admin.services</module>
+ <module>admin.web</module>
+ <module>application</module>
+ <module>persistence</module>
+ </modules>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <defaultGoal>package</defaultGoal>
+
+ <plugins>
+ <plugin>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <version>2.6</version>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.3.2</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <!-- Profile to run tests and populate sample data in a MySQL DB
+ data source will be using. USAGE: mvn -P mysql -->
+ <profiles>
+ <profile>
+ <id>mysql</id>
+ <activation>
+ <property>
+ <name>mysql</name>
+ </property>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <version>5.1.22</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.12.4</version>
+ <configuration>
+ <systemProperties>
+ <property>
+ <name>javax.persistence.jdbc.url</name>
+ <value>jdbc:mysql://localhost:3306/mysports</value>
+ </property>
+ <property>
+ <name>javax.persistence.jdbc.driver</name>
+ <value>com.mysql.jdbc.Driver</value>
+ </property>
+ <property>
+ <name>javax.persistence.jdbc.user</name>
+ <value>mysports</value>
+ </property>
+ <property>
+ <name>javax.persistence.jdbc.password</name>
+ <value>mysports</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+
+</project>