diff options
99 files changed, 9860 insertions, 0 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server/.classpath b/plugins/org.eclipse.emf.cdo.server/.classpath new file mode 100644 index 0000000000..30a021e7cd --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry excluding="org/eclipse/emf/cdo/server/ModelManager.java|org/eclipse/emf/cdo/server/Model.java|org/eclipse/emf/cdo/internal/server/ModelManagerImpl.java|org/eclipse/emf/cdo/internal/server/protocol/LoadResourcePathIndication.java|org/eclipse/emf/cdo/internal/server/protocol/AddModelsIndication.java" kind="src" path="src"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/plugins/org.eclipse.emf.cdo.server/.cvsignore b/plugins/org.eclipse.emf.cdo.server/.cvsignore new file mode 100644 index 0000000000..693869726d --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/.cvsignore @@ -0,0 +1,2 @@ +bin +doc diff --git a/plugins/org.eclipse.emf.cdo.server/.options b/plugins/org.eclipse.emf.cdo.server/.options new file mode 100644 index 0000000000..3503d0a9e4 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/.options @@ -0,0 +1,5 @@ +org.eclipse.emf.cdo.server/debug = true +org.eclipse.emf.cdo.server/debug.repository = true +org.eclipse.emf.cdo.server/debug.session = true +org.eclipse.emf.cdo.server/debug.revision = true +org.eclipse.emf.cdo.server/debug.resource = true diff --git a/plugins/org.eclipse.emf.cdo.server/.project b/plugins/org.eclipse.emf.cdo.server/.project new file mode 100644 index 0000000000..9ea6a8ca9c --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.emf.cdo.server</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/plugins/org.eclipse.emf.cdo.server/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.emf.cdo.server/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..b66ac61b86 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +#Sun Jan 07 15:36:27 CET 2007 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.5 diff --git a/plugins/org.eclipse.emf.cdo.server/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.server/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..f49026294a --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/META-INF/MANIFEST.MF @@ -0,0 +1,18 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: %pluginName +Bundle-SymbolicName: org.eclipse.emf.cdo.server;singleton:=true +Bundle-Version: 0.8.0.qualifier +Bundle-ClassPath: . +Bundle-Vendor: %providerName +Bundle-Localization: plugin +Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Export-Package: org.eclipse.emf.cdo.internal.server;version="0.8.0", + org.eclipse.emf.cdo.internal.server.bundle;version="0.8.0", + org.eclipse.emf.cdo.internal.server.protocol;version="0.8.0", + org.eclipse.emf.cdo.server;version="0.8.0" +Require-Bundle: org.eclipse.core.runtime;resolution:=optional, + org.eclipse.emf.ecore;visibility:=reexport, + org.eclipse.emf.cdo.protocol;bundle-version="0.8.0";visibility:=reexport +Eclipse-LazyStart: true +Bundle-Activator: org.eclipse.emf.cdo.internal.server.bundle.Activator$Implementation diff --git a/plugins/org.eclipse.emf.cdo.server/about.html b/plugins/org.eclipse.emf.cdo.server/about.html new file mode 100644 index 0000000000..81a265f458 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/about.html @@ -0,0 +1,42 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html> + + <head> + + <meta content="text/html; charset=ISO-8859-1" + http-equiv="Content-Type"/> + + <title>About</title> + + </head> + + <body lang="EN-US"> + + <h2>About This Content</h2> + + <p>May 17, 2007</p> + + <h3>License</h3> + + <p>The Eclipse Foundation makes available all content in this + plug-in ("Content"). Unless otherwise indicated below, + the Content is provided to you under the terms and conditions of + the Eclipse Public License Version 1.0 ("EPL"). A copy of + the EPL is available at + <a href="http://www.eclipse.org/legal/epl-v10.html"> + http://www.eclipse.org/legal/epl-v10.html</a>. For purposes of the + EPL, "Program" will mean the Content.</p> + + <p>If you did not receive this Content directly from the Eclipse + Foundation, the Content is being redistributed by another party + ("Redistributor") and different terms and conditions may + apply to your use of any object code in the Content. Check the + Redistributor's license that was provided with the Content. If + no such license exists, contact the Redistributor. Unless otherwise + indicated below, the terms and conditions of the EPL still apply to + any source code in the Content.</p> + + </body> + +</html> + diff --git a/plugins/org.eclipse.emf.cdo.server/build.properties b/plugins/org.eclipse.emf.cdo.server/build.properties new file mode 100644 index 0000000000..37a8aafa15 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/build.properties @@ -0,0 +1,17 @@ +# <copyright> +# </copyright> +# +# $Id$ + +bin.includes = .,\ + META-INF/,\ + plugin.properties,\ + .options,\ + about.html,\ + copyright.txt,\ + epl-v10.html,\ + license.html,\ + plugin.xml +jars.compile.order = . +source.. = src/ +output.. = bin/ diff --git a/plugins/org.eclipse.emf.cdo.server/copyright.txt b/plugins/org.eclipse.emf.cdo.server/copyright.txt new file mode 100644 index 0000000000..025f15218e --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/copyright.txt @@ -0,0 +1,8 @@ +Copyright (c) 2004 - 2007 Eike Stepper, Germany. +All rights reserved. This program and the accompanying materials +are made available under the terms of the Eclipse Public License v1.0 +which accompanies this distribution, and is available at +http://www.eclipse.org/legal/epl-v10.html + +Contributors: + Eike Stepper - initial API and implementation
\ No newline at end of file diff --git a/plugins/org.eclipse.emf.cdo.server/epl-v10.html b/plugins/org.eclipse.emf.cdo.server/epl-v10.html new file mode 100644 index 0000000000..d7b88e9416 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/epl-v10.html @@ -0,0 +1,319 @@ +<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40"><head> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta name="ProgId" content="Word.Document"> +<meta name="Generator" content="Microsoft Word 9"> +<meta name="Originator" content="Microsoft Word 9"> +<link rel="File-List" href="http://www.eclipse.org/org/documents/Eclipse%20EPL%202003_11_10%20Final_files/filelist.xml"><title>Eclipse Public License - Version 1.0</title><!--[if gte mso 9]><xml> + <o:DocumentProperties> + <o:Revision>2</o:Revision> + <o:TotalTime>3</o:TotalTime> + <o:Created>2004-03-05T23:03:00Z</o:Created> + <o:LastSaved>2004-03-05T23:03:00Z</o:LastSaved> + <o:Pages>4</o:Pages> + <o:Words>1626</o:Words> + <o:Characters>9270</o:Characters> + <o:Lines>77</o:Lines> + <o:Paragraphs>18</o:Paragraphs> + <o:CharactersWithSpaces>11384</o:CharactersWithSpaces> + <o:Version>9.4402</o:Version> + </o:DocumentProperties> +</xml><![endif]--><!--[if gte mso 9]><xml> + <w:WordDocument> + <w:TrackRevisions/> + </w:WordDocument> +</xml><![endif]--> + + +<style> +<!-- + /* Font Definitions */ +@font-face + {font-family:Tahoma; + panose-1:2 11 6 4 3 5 4 4 2 4; + mso-font-charset:0; + mso-generic-font-family:swiss; + mso-font-pitch:variable; + mso-font-signature:553679495 -2147483648 8 0 66047 0;} + /* Style Definitions */ +p.MsoNormal, li.MsoNormal, div.MsoNormal + {mso-style-parent:""; + margin:0in; + margin-bottom:.0001pt; + mso-pagination:widow-orphan; + font-size:12.0pt; + font-family:"Times New Roman"; + mso-fareast-font-family:"Times New Roman";} +p + {margin-right:0in; + mso-margin-top-alt:auto; + mso-margin-bottom-alt:auto; + margin-left:0in; + mso-pagination:widow-orphan; + font-size:12.0pt; + font-family:"Times New Roman"; + mso-fareast-font-family:"Times New Roman";} +p.BalloonText, li.BalloonText, div.BalloonText + {mso-style-name:"Balloon Text"; + margin:0in; + margin-bottom:.0001pt; + mso-pagination:widow-orphan; + font-size:8.0pt; + font-family:Tahoma; + mso-fareast-font-family:"Times New Roman";} +@page Section1 + {size:8.5in 11.0in; + margin:1.0in 1.25in 1.0in 1.25in; + mso-header-margin:.5in; + mso-footer-margin:.5in; + mso-paper-source:0;} +div.Section1 + {page:Section1;} +--> +</style></head> + +<body style="" lang="EN-US"> + +<div class="Section1"> + +<p style="text-align: center;" align="center"><b>Eclipse Public License - v 1.0</b> +</p> + +<p><span style="font-size: 10pt;">THE ACCOMPANYING PROGRAM IS PROVIDED UNDER +THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, +REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE +OF THIS AGREEMENT.</span> </p> + +<p><b><span style="font-size: 10pt;">1. DEFINITIONS</span></b> </p> + +<p><span style="font-size: 10pt;">"Contribution" means:</span> </p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">a) +in the case of the initial Contributor, the initial code and documentation +distributed under this Agreement, and<br clear="left"> +b) in the case of each subsequent Contributor:</span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">i) +changes to the Program, and</span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">ii) +additions to the Program;</span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">where +such changes and/or additions to the Program originate from and are distributed +by that particular Contributor. A Contribution 'originates' from a Contributor +if it was added to the Program by such Contributor itself or anyone acting on +such Contributor's behalf. Contributions do not include additions to the +Program which: (i) are separate modules of software distributed in conjunction +with the Program under their own license agreement, and (ii) are not derivative +works of the Program. </span></p> + +<p><span style="font-size: 10pt;">"Contributor" means any person or +entity that distributes the Program.</span> </p> + +<p><span style="font-size: 10pt;">"Licensed Patents " mean patent +claims licensable by a Contributor which are necessarily infringed by the use +or sale of its Contribution alone or when combined with the Program. </span></p> + +<p><span style="font-size: 10pt;">"Program" means the Contributions +distributed in accordance with this Agreement.</span> </p> + +<p><span style="font-size: 10pt;">"Recipient" means anyone who +receives the Program under this Agreement, including all Contributors.</span> </p> + +<p><b><span style="font-size: 10pt;">2. GRANT OF RIGHTS</span></b> </p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">a) +Subject to the terms of this Agreement, each Contributor hereby grants Recipient +a non-exclusive, worldwide, royalty-free copyright license to<span style="color: red;"> </span>reproduce, prepare derivative works of, publicly +display, publicly perform, distribute and sublicense the Contribution of such +Contributor, if any, and such derivative works, in source code and object code +form.</span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">b) +Subject to the terms of this Agreement, each Contributor hereby grants +Recipient a non-exclusive, worldwide,<span style="color: green;"> </span>royalty-free +patent license under Licensed Patents to make, use, sell, offer to sell, import +and otherwise transfer the Contribution of such Contributor, if any, in source +code and object code form. This patent license shall apply to the combination +of the Contribution and the Program if, at the time the Contribution is added +by the Contributor, such addition of the Contribution causes such combination +to be covered by the Licensed Patents. The patent license shall not apply to +any other combinations which include the Contribution. No hardware per se is +licensed hereunder. </span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">c) +Recipient understands that although each Contributor grants the licenses to its +Contributions set forth herein, no assurances are provided by any Contributor +that the Program does not infringe the patent or other intellectual property +rights of any other entity. Each Contributor disclaims any liability to Recipient +for claims brought by any other entity based on infringement of intellectual +property rights or otherwise. As a condition to exercising the rights and +licenses granted hereunder, each Recipient hereby assumes sole responsibility +to secure any other intellectual property rights needed, if any. For example, +if a third party patent license is required to allow Recipient to distribute +the Program, it is Recipient's responsibility to acquire that license before +distributing the Program.</span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">d) +Each Contributor represents that to its knowledge it has sufficient copyright +rights in its Contribution, if any, to grant the copyright license set forth in +this Agreement. </span></p> + +<p><b><span style="font-size: 10pt;">3. REQUIREMENTS</span></b> </p> + +<p><span style="font-size: 10pt;">A Contributor may choose to distribute the +Program in object code form under its own license agreement, provided that:</span> +</p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">a) +it complies with the terms and conditions of this Agreement; and</span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">b) +its license agreement:</span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">i) +effectively disclaims on behalf of all Contributors all warranties and +conditions, express and implied, including warranties or conditions of title +and non-infringement, and implied warranties or conditions of merchantability +and fitness for a particular purpose; </span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">ii) +effectively excludes on behalf of all Contributors all liability for damages, +including direct, indirect, special, incidental and consequential damages, such +as lost profits; </span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">iii) +states that any provisions which differ from this Agreement are offered by that +Contributor alone and not by any other party; and</span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">iv) +states that source code for the Program is available from such Contributor, and +informs licensees how to obtain it in a reasonable manner on or through a +medium customarily used for software exchange.<span style="color: blue;"> </span></span></p> + +<p><span style="font-size: 10pt;">When the Program is made available in source +code form:</span> </p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">a) +it must be made available under this Agreement; and </span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">b) a +copy of this Agreement must be included with each copy of the Program. </span></p> + +<p><span style="font-size: 10pt;">Contributors may not remove or alter any +copyright notices contained within the Program. </span></p> + +<p><span style="font-size: 10pt;">Each Contributor must identify itself as the +originator of its Contribution, if any, in a manner that reasonably allows +subsequent Recipients to identify the originator of the Contribution. </span></p> + +<p><b><span style="font-size: 10pt;">4. COMMERCIAL DISTRIBUTION</span></b> </p> + +<p><span style="font-size: 10pt;">Commercial distributors of software may +accept certain responsibilities with respect to end users, business partners +and the like. While this license is intended to facilitate the commercial use +of the Program, the Contributor who includes the Program in a commercial +product offering should do so in a manner which does not create potential +liability for other Contributors. Therefore, if a Contributor includes the +Program in a commercial product offering, such Contributor ("Commercial +Contributor") hereby agrees to defend and indemnify every other +Contributor ("Indemnified Contributor") against any losses, damages and +costs (collectively "Losses") arising from claims, lawsuits and other +legal actions brought by a third party against the Indemnified Contributor to +the extent caused by the acts or omissions of such Commercial Contributor in +connection with its distribution of the Program in a commercial product +offering. The obligations in this section do not apply to any claims or Losses +relating to any actual or alleged intellectual property infringement. In order +to qualify, an Indemnified Contributor must: a) promptly notify the Commercial +Contributor in writing of such claim, and b) allow the Commercial Contributor +to control, and cooperate with the Commercial Contributor in, the defense and +any related settlement negotiations. The Indemnified Contributor may participate +in any such claim at its own expense.</span> </p> + +<p><span style="font-size: 10pt;">For example, a Contributor might include the +Program in a commercial product offering, Product X. That Contributor is then a +Commercial Contributor. If that Commercial Contributor then makes performance +claims, or offers warranties related to Product X, those performance claims and +warranties are such Commercial Contributor's responsibility alone. Under this +section, the Commercial Contributor would have to defend claims against the +other Contributors related to those performance claims and warranties, and if a +court requires any other Contributor to pay any damages as a result, the +Commercial Contributor must pay those damages.</span> </p> + +<p><b><span style="font-size: 10pt;">5. NO WARRANTY</span></b> </p> + +<p><span style="font-size: 10pt;">EXCEPT AS EXPRESSLY SET FORTH IN THIS +AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT +WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, +WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, +MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely +responsible for determining the appropriateness of using and distributing the +Program and assumes all risks associated with its exercise of rights under this +Agreement , including but not limited to the risks and costs of program errors, +compliance with applicable laws, damage to or loss of data, programs or +equipment, and unavailability or interruption of operations. </span></p> + +<p><b><span style="font-size: 10pt;">6. DISCLAIMER OF LIABILITY</span></b> </p> + +<p><span style="font-size: 10pt;">EXCEPT AS EXPRESSLY SET FORTH IN THIS +AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF +THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGES.</span> </p> + +<p><b><span style="font-size: 10pt;">7. GENERAL</span></b> </p> + +<p><span style="font-size: 10pt;">If any provision of this Agreement is invalid +or unenforceable under applicable law, it shall not affect the validity or +enforceability of the remainder of the terms of this Agreement, and without +further action by the parties hereto, such provision shall be reformed to the +minimum extent necessary to make such provision valid and enforceable.</span> </p> + +<p><span style="font-size: 10pt;">If Recipient institutes patent litigation +against any entity (including a cross-claim or counterclaim in a lawsuit) +alleging that the Program itself (excluding combinations of the Program with +other software or hardware) infringes such Recipient's patent(s), then such +Recipient's rights granted under Section 2(b) shall terminate as of the date +such litigation is filed. </span></p> + +<p><span style="font-size: 10pt;">All Recipient's rights under this Agreement +shall terminate if it fails to comply with any of the material terms or +conditions of this Agreement and does not cure such failure in a reasonable +period of time after becoming aware of such noncompliance. If all Recipient's +rights under this Agreement terminate, Recipient agrees to cease use and +distribution of the Program as soon as reasonably practicable. However, +Recipient's obligations under this Agreement and any licenses granted by +Recipient relating to the Program shall continue and survive. </span></p> + +<p><span style="font-size: 10pt;">Everyone is permitted to copy and distribute +copies of this Agreement, but in order to avoid inconsistency the Agreement is +copyrighted and may only be modified in the following manner. The Agreement +Steward reserves the right to publish new versions (including revisions) of +this Agreement from time to time. No one other than the Agreement Steward has +the right to modify this Agreement. The Eclipse Foundation is the initial +Agreement Steward. The Eclipse Foundation may assign the responsibility to +serve as the Agreement Steward to a suitable separate entity. Each new version +of the Agreement will be given a distinguishing version number. The Program +(including Contributions) may always be distributed subject to the version of +the Agreement under which it was received. In addition, after a new version of +the Agreement is published, Contributor may elect to distribute the Program +(including its Contributions) under the new version. Except as expressly stated +in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to +the intellectual property of any Contributor under this Agreement, whether +expressly, by implication, estoppel or otherwise. All rights in the Program not +expressly granted under this Agreement are reserved.</span> </p> + +<p><span style="font-size: 10pt;">This Agreement is governed by the laws of the +State of New York and the intellectual property laws of the United States of +America. No party to this Agreement will bring a legal action under this +Agreement more than one year after the cause of action arose. Each party waives +its rights to a jury trial in any resulting litigation.</span> </p> + +<p class="MsoNormal"><!--[if !supportEmptyParas]--> <!--[endif]--><o:p></o:p></p> + +</div> + +</body></html>
\ No newline at end of file diff --git a/plugins/org.eclipse.emf.cdo.server/license.html b/plugins/org.eclipse.emf.cdo.server/license.html new file mode 100644 index 0000000000..d7b88e9416 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/license.html @@ -0,0 +1,319 @@ +<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40"><head> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta name="ProgId" content="Word.Document"> +<meta name="Generator" content="Microsoft Word 9"> +<meta name="Originator" content="Microsoft Word 9"> +<link rel="File-List" href="http://www.eclipse.org/org/documents/Eclipse%20EPL%202003_11_10%20Final_files/filelist.xml"><title>Eclipse Public License - Version 1.0</title><!--[if gte mso 9]><xml> + <o:DocumentProperties> + <o:Revision>2</o:Revision> + <o:TotalTime>3</o:TotalTime> + <o:Created>2004-03-05T23:03:00Z</o:Created> + <o:LastSaved>2004-03-05T23:03:00Z</o:LastSaved> + <o:Pages>4</o:Pages> + <o:Words>1626</o:Words> + <o:Characters>9270</o:Characters> + <o:Lines>77</o:Lines> + <o:Paragraphs>18</o:Paragraphs> + <o:CharactersWithSpaces>11384</o:CharactersWithSpaces> + <o:Version>9.4402</o:Version> + </o:DocumentProperties> +</xml><![endif]--><!--[if gte mso 9]><xml> + <w:WordDocument> + <w:TrackRevisions/> + </w:WordDocument> +</xml><![endif]--> + + +<style> +<!-- + /* Font Definitions */ +@font-face + {font-family:Tahoma; + panose-1:2 11 6 4 3 5 4 4 2 4; + mso-font-charset:0; + mso-generic-font-family:swiss; + mso-font-pitch:variable; + mso-font-signature:553679495 -2147483648 8 0 66047 0;} + /* Style Definitions */ +p.MsoNormal, li.MsoNormal, div.MsoNormal + {mso-style-parent:""; + margin:0in; + margin-bottom:.0001pt; + mso-pagination:widow-orphan; + font-size:12.0pt; + font-family:"Times New Roman"; + mso-fareast-font-family:"Times New Roman";} +p + {margin-right:0in; + mso-margin-top-alt:auto; + mso-margin-bottom-alt:auto; + margin-left:0in; + mso-pagination:widow-orphan; + font-size:12.0pt; + font-family:"Times New Roman"; + mso-fareast-font-family:"Times New Roman";} +p.BalloonText, li.BalloonText, div.BalloonText + {mso-style-name:"Balloon Text"; + margin:0in; + margin-bottom:.0001pt; + mso-pagination:widow-orphan; + font-size:8.0pt; + font-family:Tahoma; + mso-fareast-font-family:"Times New Roman";} +@page Section1 + {size:8.5in 11.0in; + margin:1.0in 1.25in 1.0in 1.25in; + mso-header-margin:.5in; + mso-footer-margin:.5in; + mso-paper-source:0;} +div.Section1 + {page:Section1;} +--> +</style></head> + +<body style="" lang="EN-US"> + +<div class="Section1"> + +<p style="text-align: center;" align="center"><b>Eclipse Public License - v 1.0</b> +</p> + +<p><span style="font-size: 10pt;">THE ACCOMPANYING PROGRAM IS PROVIDED UNDER +THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, +REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE +OF THIS AGREEMENT.</span> </p> + +<p><b><span style="font-size: 10pt;">1. DEFINITIONS</span></b> </p> + +<p><span style="font-size: 10pt;">"Contribution" means:</span> </p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">a) +in the case of the initial Contributor, the initial code and documentation +distributed under this Agreement, and<br clear="left"> +b) in the case of each subsequent Contributor:</span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">i) +changes to the Program, and</span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">ii) +additions to the Program;</span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">where +such changes and/or additions to the Program originate from and are distributed +by that particular Contributor. A Contribution 'originates' from a Contributor +if it was added to the Program by such Contributor itself or anyone acting on +such Contributor's behalf. Contributions do not include additions to the +Program which: (i) are separate modules of software distributed in conjunction +with the Program under their own license agreement, and (ii) are not derivative +works of the Program. </span></p> + +<p><span style="font-size: 10pt;">"Contributor" means any person or +entity that distributes the Program.</span> </p> + +<p><span style="font-size: 10pt;">"Licensed Patents " mean patent +claims licensable by a Contributor which are necessarily infringed by the use +or sale of its Contribution alone or when combined with the Program. </span></p> + +<p><span style="font-size: 10pt;">"Program" means the Contributions +distributed in accordance with this Agreement.</span> </p> + +<p><span style="font-size: 10pt;">"Recipient" means anyone who +receives the Program under this Agreement, including all Contributors.</span> </p> + +<p><b><span style="font-size: 10pt;">2. GRANT OF RIGHTS</span></b> </p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">a) +Subject to the terms of this Agreement, each Contributor hereby grants Recipient +a non-exclusive, worldwide, royalty-free copyright license to<span style="color: red;"> </span>reproduce, prepare derivative works of, publicly +display, publicly perform, distribute and sublicense the Contribution of such +Contributor, if any, and such derivative works, in source code and object code +form.</span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">b) +Subject to the terms of this Agreement, each Contributor hereby grants +Recipient a non-exclusive, worldwide,<span style="color: green;"> </span>royalty-free +patent license under Licensed Patents to make, use, sell, offer to sell, import +and otherwise transfer the Contribution of such Contributor, if any, in source +code and object code form. This patent license shall apply to the combination +of the Contribution and the Program if, at the time the Contribution is added +by the Contributor, such addition of the Contribution causes such combination +to be covered by the Licensed Patents. The patent license shall not apply to +any other combinations which include the Contribution. No hardware per se is +licensed hereunder. </span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">c) +Recipient understands that although each Contributor grants the licenses to its +Contributions set forth herein, no assurances are provided by any Contributor +that the Program does not infringe the patent or other intellectual property +rights of any other entity. Each Contributor disclaims any liability to Recipient +for claims brought by any other entity based on infringement of intellectual +property rights or otherwise. As a condition to exercising the rights and +licenses granted hereunder, each Recipient hereby assumes sole responsibility +to secure any other intellectual property rights needed, if any. For example, +if a third party patent license is required to allow Recipient to distribute +the Program, it is Recipient's responsibility to acquire that license before +distributing the Program.</span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">d) +Each Contributor represents that to its knowledge it has sufficient copyright +rights in its Contribution, if any, to grant the copyright license set forth in +this Agreement. </span></p> + +<p><b><span style="font-size: 10pt;">3. REQUIREMENTS</span></b> </p> + +<p><span style="font-size: 10pt;">A Contributor may choose to distribute the +Program in object code form under its own license agreement, provided that:</span> +</p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">a) +it complies with the terms and conditions of this Agreement; and</span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">b) +its license agreement:</span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">i) +effectively disclaims on behalf of all Contributors all warranties and +conditions, express and implied, including warranties or conditions of title +and non-infringement, and implied warranties or conditions of merchantability +and fitness for a particular purpose; </span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">ii) +effectively excludes on behalf of all Contributors all liability for damages, +including direct, indirect, special, incidental and consequential damages, such +as lost profits; </span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">iii) +states that any provisions which differ from this Agreement are offered by that +Contributor alone and not by any other party; and</span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">iv) +states that source code for the Program is available from such Contributor, and +informs licensees how to obtain it in a reasonable manner on or through a +medium customarily used for software exchange.<span style="color: blue;"> </span></span></p> + +<p><span style="font-size: 10pt;">When the Program is made available in source +code form:</span> </p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">a) +it must be made available under this Agreement; and </span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">b) a +copy of this Agreement must be included with each copy of the Program. </span></p> + +<p><span style="font-size: 10pt;">Contributors may not remove or alter any +copyright notices contained within the Program. </span></p> + +<p><span style="font-size: 10pt;">Each Contributor must identify itself as the +originator of its Contribution, if any, in a manner that reasonably allows +subsequent Recipients to identify the originator of the Contribution. </span></p> + +<p><b><span style="font-size: 10pt;">4. COMMERCIAL DISTRIBUTION</span></b> </p> + +<p><span style="font-size: 10pt;">Commercial distributors of software may +accept certain responsibilities with respect to end users, business partners +and the like. While this license is intended to facilitate the commercial use +of the Program, the Contributor who includes the Program in a commercial +product offering should do so in a manner which does not create potential +liability for other Contributors. Therefore, if a Contributor includes the +Program in a commercial product offering, such Contributor ("Commercial +Contributor") hereby agrees to defend and indemnify every other +Contributor ("Indemnified Contributor") against any losses, damages and +costs (collectively "Losses") arising from claims, lawsuits and other +legal actions brought by a third party against the Indemnified Contributor to +the extent caused by the acts or omissions of such Commercial Contributor in +connection with its distribution of the Program in a commercial product +offering. The obligations in this section do not apply to any claims or Losses +relating to any actual or alleged intellectual property infringement. In order +to qualify, an Indemnified Contributor must: a) promptly notify the Commercial +Contributor in writing of such claim, and b) allow the Commercial Contributor +to control, and cooperate with the Commercial Contributor in, the defense and +any related settlement negotiations. The Indemnified Contributor may participate +in any such claim at its own expense.</span> </p> + +<p><span style="font-size: 10pt;">For example, a Contributor might include the +Program in a commercial product offering, Product X. That Contributor is then a +Commercial Contributor. If that Commercial Contributor then makes performance +claims, or offers warranties related to Product X, those performance claims and +warranties are such Commercial Contributor's responsibility alone. Under this +section, the Commercial Contributor would have to defend claims against the +other Contributors related to those performance claims and warranties, and if a +court requires any other Contributor to pay any damages as a result, the +Commercial Contributor must pay those damages.</span> </p> + +<p><b><span style="font-size: 10pt;">5. NO WARRANTY</span></b> </p> + +<p><span style="font-size: 10pt;">EXCEPT AS EXPRESSLY SET FORTH IN THIS +AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT +WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, +WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, +MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely +responsible for determining the appropriateness of using and distributing the +Program and assumes all risks associated with its exercise of rights under this +Agreement , including but not limited to the risks and costs of program errors, +compliance with applicable laws, damage to or loss of data, programs or +equipment, and unavailability or interruption of operations. </span></p> + +<p><b><span style="font-size: 10pt;">6. DISCLAIMER OF LIABILITY</span></b> </p> + +<p><span style="font-size: 10pt;">EXCEPT AS EXPRESSLY SET FORTH IN THIS +AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF +THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGES.</span> </p> + +<p><b><span style="font-size: 10pt;">7. GENERAL</span></b> </p> + +<p><span style="font-size: 10pt;">If any provision of this Agreement is invalid +or unenforceable under applicable law, it shall not affect the validity or +enforceability of the remainder of the terms of this Agreement, and without +further action by the parties hereto, such provision shall be reformed to the +minimum extent necessary to make such provision valid and enforceable.</span> </p> + +<p><span style="font-size: 10pt;">If Recipient institutes patent litigation +against any entity (including a cross-claim or counterclaim in a lawsuit) +alleging that the Program itself (excluding combinations of the Program with +other software or hardware) infringes such Recipient's patent(s), then such +Recipient's rights granted under Section 2(b) shall terminate as of the date +such litigation is filed. </span></p> + +<p><span style="font-size: 10pt;">All Recipient's rights under this Agreement +shall terminate if it fails to comply with any of the material terms or +conditions of this Agreement and does not cure such failure in a reasonable +period of time after becoming aware of such noncompliance. If all Recipient's +rights under this Agreement terminate, Recipient agrees to cease use and +distribution of the Program as soon as reasonably practicable. However, +Recipient's obligations under this Agreement and any licenses granted by +Recipient relating to the Program shall continue and survive. </span></p> + +<p><span style="font-size: 10pt;">Everyone is permitted to copy and distribute +copies of this Agreement, but in order to avoid inconsistency the Agreement is +copyrighted and may only be modified in the following manner. The Agreement +Steward reserves the right to publish new versions (including revisions) of +this Agreement from time to time. No one other than the Agreement Steward has +the right to modify this Agreement. The Eclipse Foundation is the initial +Agreement Steward. The Eclipse Foundation may assign the responsibility to +serve as the Agreement Steward to a suitable separate entity. Each new version +of the Agreement will be given a distinguishing version number. The Program +(including Contributions) may always be distributed subject to the version of +the Agreement under which it was received. In addition, after a new version of +the Agreement is published, Contributor may elect to distribute the Program +(including its Contributions) under the new version. Except as expressly stated +in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to +the intellectual property of any Contributor under this Agreement, whether +expressly, by implication, estoppel or otherwise. All rights in the Program not +expressly granted under this Agreement are reserved.</span> </p> + +<p><span style="font-size: 10pt;">This Agreement is governed by the laws of the +State of New York and the intellectual property laws of the United States of +America. No party to this Agreement will bring a legal action under this +Agreement more than one year after the cause of action arose. Each party waives +its rights to a jury trial in any resulting litigation.</span> </p> + +<p class="MsoNormal"><!--[if !supportEmptyParas]--> <!--[endif]--><o:p></o:p></p> + +</div> + +</body></html>
\ No newline at end of file diff --git a/plugins/org.eclipse.emf.cdo.server/plugin.properties b/plugins/org.eclipse.emf.cdo.server/plugin.properties new file mode 100644 index 0000000000..d7ec571b9b --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/plugin.properties @@ -0,0 +1,19 @@ +# <copyright> +# </copyright> +# +# $Id$ + +# ==================================================================== +# To code developer: +# Do NOT change the properties between this line and the +# "%%% END OF TRANSLATED PROPERTIES %%%" line. +# Make a new property name, append to the end of the file and change +# the code to use the new property. +# ==================================================================== + +# ==================================================================== +# %%% END OF TRANSLATED PROPERTIES %%% +# ==================================================================== + +pluginName = CDO Server +providerName = Eclipse.org diff --git a/plugins/org.eclipse.emf.cdo.server/plugin.xml b/plugins/org.eclipse.emf.cdo.server/plugin.xml new file mode 100644 index 0000000000..4973c6a9af --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/plugin.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.2"?> + +<plugin> + + <extension + point="org.eclipse.net4j.factories"> + <factory + class="org.eclipse.emf.cdo.internal.server.protocol.CDOServerProtocolFactory" + productGroup="org.eclipse.net4j.serverProtocols" + type="cdo"/> + </extension> + +</plugin> diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RepositoryImpl.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RepositoryImpl.java new file mode 100644 index 0000000000..0f5142764e --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RepositoryImpl.java @@ -0,0 +1,76 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.cdo.internal.server; + +import org.eclipse.emf.cdo.internal.protocol.CDOIDImpl; +import org.eclipse.emf.cdo.protocol.CDOID; +import org.eclipse.emf.cdo.server.Repository; + +import java.util.UUID; + +/** + * @author Eike Stepper + */ +public class RepositoryImpl implements Repository +{ + private static final long INITIAL_OID_VALUE = 1; + + private String name; + + private String uuid; + + private SessionManagerImpl sessionManager; + + private ResourceManagerImpl resourceManager; + + private RevisionManagerImpl revisionManager; + + private long nextOIDValue = INITIAL_OID_VALUE; + + public RepositoryImpl(String name) + { + this.name = name; + this.uuid = UUID.randomUUID().toString(); + sessionManager = new SessionManagerImpl(this); + resourceManager = new ResourceManagerImpl(this); + revisionManager = new RevisionManagerImpl(this); + } + + public String getName() + { + return name; + } + + public String getUUID() + { + return uuid; + } + + public SessionManagerImpl getSessionManager() + { + return sessionManager; + } + + public ResourceManagerImpl getResourceManager() + { + return resourceManager; + } + + public RevisionManagerImpl getRevisionManager() + { + return revisionManager; + } + + public CDOID getNextCDOID() + { + return CDOIDImpl.create(nextOIDValue++); + } +} diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RepositoryManagerImpl.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RepositoryManagerImpl.java new file mode 100644 index 0000000000..c823fd6693 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RepositoryManagerImpl.java @@ -0,0 +1,58 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.cdo.internal.server; + +import org.eclipse.emf.cdo.server.RepositoryManager; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author Eike Stepper + */ +public class RepositoryManagerImpl implements RepositoryManager +{ + // @Singleton + public static final RepositoryManagerImpl INSTANCE = new RepositoryManagerImpl(); + + private Map<String, RepositoryImpl> repositories = new HashMap(); + + public RepositoryManagerImpl() + { + } + + public RepositoryImpl getRepository(String name) + { + RepositoryImpl repository = repositories.get(name); + if (repository == null) + { + repository = openRepository(name); + repositories.put(name, repository); + } + + return repository; + } + + private RepositoryImpl openRepository(String name) + { + return new RepositoryImpl(name); + } + + public boolean isEmpty() + { + return repositories.isEmpty(); + } + + public void clear() + { + repositories.clear(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/ResourceManagerImpl.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/ResourceManagerImpl.java new file mode 100644 index 0000000000..2ca0b1083a --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/ResourceManagerImpl.java @@ -0,0 +1,94 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.cdo.internal.server; + +import org.eclipse.emf.cdo.internal.server.bundle.CDOServer; +import org.eclipse.emf.cdo.protocol.CDOID; +import org.eclipse.emf.cdo.server.ResourceManager; + +import org.eclipse.net4j.util.om.trace.ContextTracer; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author Eike Stepper + */ +public class ResourceManagerImpl implements ResourceManager +{ + private static final ContextTracer TRACER = new ContextTracer(CDOServer.DEBUG_SESSION, SessionManagerImpl.class); + + private RepositoryImpl repository; + + private Map<CDOID, String> idToPathMap = new HashMap(); + + private Map<String, CDOID> pathToIDMap = new HashMap(); + + public ResourceManagerImpl(RepositoryImpl repository) + { + this.repository = repository; + } + + public RepositoryImpl getRepository() + { + return repository; + } + + public CDOID getActualResourceID(String path) + { + CDOID id = pathToIDMap.get(path); + if (id == null) + { + id = loadActualID(path); + registerResource(id, path); + } + + return id; + } + + public String getActualResourcePath(CDOID id) + { + String path = idToPathMap.get(id); + if (path == null) + { + path = loadActualPath(id); + registerResource(id, path); + } + + return path; + } + + public void registerResource(CDOID id, String path) + { + final String oldPath = idToPathMap.put(id, path); + if (oldPath != path) + { + if (TRACER.isEnabled()) + { + TRACER.format("Registering resource: {0} --> {1}", id, path); + } + + pathToIDMap.put(path, id); + } + } + + private CDOID loadActualID(String path) + { + // TODO Implement method ResourceManagerImpl.loadID() + throw new UnsupportedOperationException("Not yet implemented"); + } + + private String loadActualPath(CDOID id) + { + // TODO Implement method ResourceManagerImpl.loadPath() + throw new UnsupportedOperationException("Not yet implemented"); + } +} diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RevisionManagerImpl.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RevisionManagerImpl.java new file mode 100644 index 0000000000..fe5f24129b --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RevisionManagerImpl.java @@ -0,0 +1,53 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.cdo.internal.server; + +import org.eclipse.emf.cdo.internal.protocol.model.resource.CDOPathFeatureImpl; +import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl; +import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionResolverImpl; +import org.eclipse.emf.cdo.protocol.CDOID; +import org.eclipse.emf.cdo.server.RevisionManager; + +/** + * @author Eike Stepper + */ +public class RevisionManagerImpl extends CDORevisionResolverImpl implements RevisionManager +{ + private RepositoryImpl repository; + + public RevisionManagerImpl(RepositoryImpl repository) + { + this.repository = repository; + } + + public RepositoryImpl getRepository() + { + return repository; + } + + @Override + public void addRevision(CDORevisionImpl revision) + { + super.addRevision(revision); + if (revision.isResource()) + { + String path = (String)revision.getData().get(CDOPathFeatureImpl.INSTANCE, -1); + repository.getResourceManager().registerResource(revision.getID(), path); + } + } + + @Override + protected CDORevisionImpl loadActual(CDOID id) + { + // TODO Implement method RevisionManagerImpl.loadActual() + throw new UnsupportedOperationException("Not yet implemented"); + } +} diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/SessionImpl.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/SessionImpl.java new file mode 100644 index 0000000000..4739b2df3d --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/SessionImpl.java @@ -0,0 +1,63 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.cdo.internal.server; + +import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl; +import org.eclipse.emf.cdo.internal.server.bundle.CDOServer; +import org.eclipse.emf.cdo.internal.server.protocol.CDOServerProtocol; +import org.eclipse.emf.cdo.internal.server.protocol.InvalidationRequest; +import org.eclipse.emf.cdo.server.Session; + +/** + * @author Eike Stepper + */ +public class SessionImpl implements Session +{ + private SessionManagerImpl sessionManager; + + private CDOServerProtocol protocol; + + private int sessionID; + + public SessionImpl(SessionManagerImpl sessionManager, CDOServerProtocol protocol, int sessionID) + { + this.sessionManager = sessionManager; + this.protocol = protocol; + this.sessionID = sessionID; + } + + public SessionManagerImpl getSessionManager() + { + return sessionManager; + } + + public int getSessionID() + { + return sessionID; + } + + public CDOServerProtocol getProtocol() + { + return protocol; + } + + public void notifyInvalidation(long timeStamp, CDORevisionImpl[] dirtyObjects) + { + try + { + new InvalidationRequest(protocol.getChannel(), timeStamp, dirtyObjects).send(); + } + catch (Exception ex) + { + CDOServer.LOG.error(ex); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/SessionManagerImpl.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/SessionManagerImpl.java new file mode 100644 index 0000000000..9a7e7eec2e --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/SessionManagerImpl.java @@ -0,0 +1,85 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.cdo.internal.server; + +import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl; +import org.eclipse.emf.cdo.internal.server.bundle.CDOServer; +import org.eclipse.emf.cdo.internal.server.protocol.CDOServerProtocol; +import org.eclipse.emf.cdo.server.SessionManager; + +import org.eclipse.net4j.util.om.trace.ContextTracer; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author Eike Stepper + */ +public class SessionManagerImpl implements SessionManager +{ + private static final ContextTracer TRACER = new ContextTracer(CDOServer.DEBUG_SESSION, SessionManagerImpl.class); + + private RepositoryImpl repository; + + private Map<Integer, SessionImpl> sessions = new HashMap(); + + private int lastSessionID; + + public SessionManagerImpl(RepositoryImpl repository) + { + this.repository = repository; + } + + public RepositoryImpl getRepository() + { + return repository; + } + + public SessionImpl[] getSessions() + { + synchronized (sessions) + { + return sessions.values().toArray(new SessionImpl[sessions.size()]); + } + } + + public SessionImpl openSession(CDOServerProtocol protocol) + { + int id = ++lastSessionID; + if (TRACER.isEnabled()) + { + TRACER.trace("Opening session " + id); + } + + SessionImpl session = new SessionImpl(this, protocol, id); + synchronized (sessions) + { + sessions.put(id, session); + } + + return session; + } + + public void sessionClosed(SessionImpl session) + { + } + + public void notifyInvalidation(long timeStamp, CDORevisionImpl[] dirtyObjects, SessionImpl excludedSession) + { + for (SessionImpl session : getSessions()) + { + if (session != excludedSession) + { + session.notifyInvalidation(timeStamp, dirtyObjects); + } + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/bundle/Activator.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/bundle/Activator.java new file mode 100644 index 0000000000..2cb425a8f2 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/bundle/Activator.java @@ -0,0 +1,53 @@ +package org.eclipse.emf.cdo.internal.server.bundle; + +import org.eclipse.emf.common.EMFPlugin; +import org.eclipse.emf.common.util.ResourceLocator; + +import org.osgi.framework.BundleContext; + +public final class Activator extends EMFPlugin +{ + // @Singleton + public static final Activator INSTANCE = new Activator(); + + private static Implementation plugin; + + public Activator() + { + super(new ResourceLocator[] {}); + } + + public ResourceLocator getPluginResourceLocator() + { + return plugin; + } + + public static Implementation getPlugin() + { + return plugin; + } + + public static class Implementation extends EclipsePlugin + { + public Implementation() + { + plugin = this; + } + + @Override + public void start(BundleContext context) throws Exception + { + super.start(context); + CDOServer.BUNDLE.setBundleContext(context); + } + + @Override + public void stop(BundleContext context) throws Exception + { + plugin = null; + CDOServer.BUNDLE.setBundleContext(null); + super.stop(context); + } + } + +} diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/bundle/CDOServer.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/bundle/CDOServer.java new file mode 100644 index 0000000000..a52c89861c --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/bundle/CDOServer.java @@ -0,0 +1,42 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.cdo.internal.server.bundle; + +import org.eclipse.net4j.util.om.OMBundle; +import org.eclipse.net4j.util.om.OMLogger; +import org.eclipse.net4j.util.om.OMPlatform; +import org.eclipse.net4j.util.om.OMTracer; + +/** + * @author Eike Stepper + */ +public final class CDOServer +{ + public static final String BUNDLE_ID = "org.eclipse.emf.cdo.server"; //$NON-NLS-1$ + + public static final OMBundle BUNDLE = OMPlatform.INSTANCE.bundle(BUNDLE_ID, CDOServer.class); + + public static final OMTracer DEBUG = BUNDLE.tracer("debug"); //$NON-NLS-1$ + + public static final OMTracer DEBUG_REPOSITORY = DEBUG.tracer("repository"); //$NON-NLS-1$ + + public static final OMTracer DEBUG_SESSION = DEBUG.tracer("session"); //$NON-NLS-1$ + + public static final OMTracer DEBUG_REVISION = DEBUG.tracer("revision"); //$NON-NLS-1$ + + public static final OMTracer DEBUG_RESOURCE = DEBUG.tracer("resource"); //$NON-NLS-1$ + + public static final OMLogger LOG = BUNDLE.logger(); + + private CDOServer() + { + } +} diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerIndication.java new file mode 100644 index 0000000000..0fed2def2a --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerIndication.java @@ -0,0 +1,68 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.cdo.internal.server.protocol; + +import org.eclipse.emf.cdo.internal.server.RepositoryImpl; +import org.eclipse.emf.cdo.internal.server.ResourceManagerImpl; +import org.eclipse.emf.cdo.internal.server.RevisionManagerImpl; +import org.eclipse.emf.cdo.internal.server.SessionImpl; +import org.eclipse.emf.cdo.internal.server.SessionManagerImpl; + +import org.eclipse.net4j.signal.IndicationWithResponse; + +/** + * @author Eike Stepper + */ +public abstract class CDOServerIndication extends IndicationWithResponse +{ + private short signalID; + + public CDOServerIndication(short signalID) + { + this.signalID = signalID; + } + + @Override + protected short getSignalID() + { + return signalID; + } + + protected SessionManagerImpl getSessionManager() + { + return getSession().getSessionManager(); + } + + protected RevisionManagerImpl getRevisionManager() + { + return getRepository().getRevisionManager(); + } + + protected ResourceManagerImpl getResourceManager() + { + return getRepository().getResourceManager(); + } + + protected RepositoryImpl getRepository() + { + return getSessionManager().getRepository(); + } + + protected SessionImpl getSession() + { + return getProtocol().getSession(); + } + + protected CDOServerProtocol getProtocol() + { + return (CDOServerProtocol)super.getProtocol(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerProtocol.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerProtocol.java new file mode 100644 index 0000000000..21e73b0575 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerProtocol.java @@ -0,0 +1,68 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.cdo.internal.server.protocol; + +import org.eclipse.emf.cdo.internal.server.SessionImpl; +import org.eclipse.emf.cdo.protocol.CDOProtocolConstants; + +import org.eclipse.net4j.signal.SignalProtocol; +import org.eclipse.net4j.signal.SignalReactor; + +/** + * @author Eike Stepper + */ +public class CDOServerProtocol extends SignalProtocol +{ + private SessionImpl session; + + public CDOServerProtocol() + { + } + + public String getType() + { + return CDOProtocolConstants.PROTOCOL_NAME; + } + + public SessionImpl getSession() + { + return session; + } + + public void setSession(SessionImpl session) + { + this.session = session; + } + + @Override + protected SignalReactor doCreateSignalReactor(short signalID) + { + switch (signalID) + { + case CDOProtocolConstants.OPEN_SESSION_SIGNAL: + return new OpenSessionIndication(); + + case CDOProtocolConstants.RESOURCE_ID_SIGNAL: + return new ResourceIDIndication(); + + case CDOProtocolConstants.RESOURCE_PATH_SIGNAL: + return new ResourcePathIndication(); + + case CDOProtocolConstants.LOAD_OBJECT_SIGNAL: + return new LoadObjectIndication(); + + case CDOProtocolConstants.COMMIT_TRANSACTION_SIGNAL: + return new CommitTransactionIndication(); + } + + return null; + } +} diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerProtocolFactory.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerProtocolFactory.java new file mode 100644 index 0000000000..4fb3ef4ea3 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerProtocolFactory.java @@ -0,0 +1,22 @@ +package org.eclipse.emf.cdo.internal.server.protocol; + +import org.eclipse.emf.cdo.protocol.CDOProtocolConstants; + +import org.eclipse.internal.net4j.ServerProtocolFactory; + +/** + * @author Eike Stepper + */ +public final class CDOServerProtocolFactory extends ServerProtocolFactory +{ + + public CDOServerProtocolFactory() + { + super(CDOProtocolConstants.PROTOCOL_NAME); + } + + public Object create(String description) + { + return new CDOServerProtocol(); + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionIndication.java new file mode 100644 index 0000000000..cc00bed875 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionIndication.java @@ -0,0 +1,162 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.cdo.internal.server.protocol; + +import org.eclipse.emf.cdo.internal.protocol.CDOIDImpl; +import org.eclipse.emf.cdo.internal.protocol.bundle.CDOProtocol; +import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl; +import org.eclipse.emf.cdo.internal.server.RevisionManagerImpl; +import org.eclipse.emf.cdo.protocol.CDOID; +import org.eclipse.emf.cdo.protocol.CDOProtocolConstants; + +import org.eclipse.net4j.util.om.trace.ContextTracer; +import org.eclipse.net4j.util.stream.ExtendedDataInputStream; +import org.eclipse.net4j.util.stream.ExtendedDataOutputStream; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; + +/** + * @author Eike Stepper + */ +@SuppressWarnings("unused") +public class CommitTransactionIndication extends CDOServerIndication +{ + private static final ContextTracer PROTOCOL = new ContextTracer(CDOProtocol.DEBUG_PROTOCOL, + CommitTransactionIndication.class); + + private static final ContextTracer TRACER = new ContextTracer(CDOProtocol.DEBUG_REVISION, + CommitTransactionIndication.class); + + private CDORevisionImpl[] newResources; + + private CDORevisionImpl[] newObjects; + + private CDORevisionImpl[] dirtyObjects; + + private Map<CDOID, CDOID> idMappings = new HashMap(); + + private long timeStamp; + + public CommitTransactionIndication() + { + super(CDOProtocolConstants.COMMIT_TRANSACTION_SIGNAL); + } + + @Override + protected void indicating(ExtendedDataInputStream in) throws IOException + { + newResources = readNewResources(in); + newObjects = readNewObjects(in); + dirtyObjects = readDirtyObjects(in); + } + + private CDORevisionImpl[] readNewResources(ExtendedDataInputStream in) throws IOException + { + int size = in.readInt(); + if (PROTOCOL.isEnabled()) + { + PROTOCOL.format("Reading {0} new resources", size); + } + + return readRevisions(in, size); + } + + private CDORevisionImpl[] readNewObjects(ExtendedDataInputStream in) throws IOException + { + int size = in.readInt(); + if (PROTOCOL.isEnabled()) + { + PROTOCOL.format("Reading {0} new objects", size); + } + + return readRevisions(in, size); + } + + private CDORevisionImpl[] readDirtyObjects(ExtendedDataInputStream in) throws IOException + { + int size = in.readInt(); + if (PROTOCOL.isEnabled()) + { + PROTOCOL.format("Reading {0} dirty objects", size); + } + + return readRevisions(in, size); + } + + private CDORevisionImpl[] readRevisions(ExtendedDataInputStream in, int size) throws IOException + { + CDORevisionImpl[] revisions = new CDORevisionImpl[size]; + for (int i = 0; i < size; i++) + { + revisions[i] = new CDORevisionImpl(in); + mapTemporaryID(revisions[i]); + } + + return revisions; + } + + @Override + protected void responding(ExtendedDataOutputStream out) throws IOException + { + timeStamp = System.currentTimeMillis(); + out.writeLong(timeStamp); + + addRevisions(newResources); + addRevisions(newObjects); + addRevisions(dirtyObjects); + writeIDMappings(out); + + if (dirtyObjects.length > 0) + { + getSessionManager().notifyInvalidation(timeStamp, dirtyObjects, getSession()); + } + } + + private void addRevisions(CDORevisionImpl[] revisions) + { + RevisionManagerImpl revisionManager = getRevisionManager(); + for (CDORevisionImpl revision : revisions) + { + revision.setCreated(timeStamp); + revision.adjustReferences(idMappings); + revisionManager.addRevision(revision); + } + } + + private void mapTemporaryID(CDORevisionImpl revision) + { + CDOID oldID = revision.getID(); + if (oldID.isTemporary()) + { + CDOID newID = getRepository().getNextCDOID(); + if (TRACER.isEnabled()) + { + TRACER.format("Mapping ID: {0} --> {1}", oldID, newID); + } + + idMappings.put(oldID, newID); + revision.setID(newID); + } + } + + private void writeIDMappings(ExtendedDataOutputStream out) throws IOException + { + out.writeInt(idMappings.size()); + for (Entry<CDOID, CDOID> entry : idMappings.entrySet()) + { + CDOIDImpl.write(out, entry.getKey()); + CDOIDImpl.write(out, entry.getValue()); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/InvalidationRequest.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/InvalidationRequest.java new file mode 100644 index 0000000000..2e82ec41f0 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/InvalidationRequest.java @@ -0,0 +1,72 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.cdo.internal.server.protocol; + +import org.eclipse.emf.cdo.internal.protocol.CDOIDImpl; +import org.eclipse.emf.cdo.internal.protocol.bundle.CDOProtocol; +import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl; +import org.eclipse.emf.cdo.protocol.CDOProtocolConstants; + +import org.eclipse.net4j.IChannel; +import org.eclipse.net4j.signal.Request; +import org.eclipse.net4j.util.om.trace.ContextTracer; +import org.eclipse.net4j.util.stream.ExtendedDataOutputStream; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class InvalidationRequest extends Request +{ + private static final ContextTracer PROTOCOL = new ContextTracer(CDOProtocol.DEBUG_PROTOCOL, InvalidationRequest.class); + + private long timeStamp; + + private CDORevisionImpl[] dirtyObjects; + + public InvalidationRequest(IChannel channel, long timeStamp, CDORevisionImpl[] dirtyObjects) + { + super(channel); + this.timeStamp = timeStamp; + this.dirtyObjects = dirtyObjects; + } + + @Override + protected short getSignalID() + { + return CDOProtocolConstants.INVALIDATION_SIGNAL; + } + + @Override + protected void requesting(ExtendedDataOutputStream out) throws IOException + { + if (PROTOCOL.isEnabled()) + { + PROTOCOL.format("Writing timeStamp: {0,date} {0,time}", timeStamp); + } + + out.writeLong(timeStamp); + + int size = dirtyObjects.length; + if (PROTOCOL.isEnabled()) + { + PROTOCOL.format("Writing {0} IDs", size); + } + + out.writeInt(size); + for (int i = 0; i < dirtyObjects.length; i++) + { + CDORevisionImpl dirty = dirtyObjects[i]; + CDOIDImpl.write(out, dirty.getID()); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadObjectIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadObjectIndication.java new file mode 100644 index 0000000000..a414485f21 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadObjectIndication.java @@ -0,0 +1,72 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.cdo.internal.server.protocol; + +import org.eclipse.emf.cdo.internal.protocol.CDOIDImpl; +import org.eclipse.emf.cdo.internal.protocol.bundle.CDOProtocol; +import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl; +import org.eclipse.emf.cdo.internal.server.RevisionManagerImpl; +import org.eclipse.emf.cdo.protocol.CDOID; +import org.eclipse.emf.cdo.protocol.CDOProtocolConstants; + +import org.eclipse.net4j.util.om.trace.ContextTracer; +import org.eclipse.net4j.util.stream.ExtendedDataInputStream; +import org.eclipse.net4j.util.stream.ExtendedDataOutputStream; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class LoadObjectIndication extends CDOServerIndication +{ + private static final ContextTracer PROTOCOL = new ContextTracer(CDOProtocol.DEBUG_PROTOCOL, + LoadObjectIndication.class); + + private CDOID id; + + private boolean historical; + + private long timeStamp; + + public LoadObjectIndication() + { + super(CDOProtocolConstants.LOAD_OBJECT_SIGNAL); + } + + @Override + protected void indicating(ExtendedDataInputStream in) throws IOException + { + id = CDOIDImpl.read(in); + if (PROTOCOL.isEnabled()) + { + PROTOCOL.format("Read ID: {0}", id); + } + + historical = in.readBoolean(); + if (historical) + { + timeStamp = in.readLong(); + if (PROTOCOL.isEnabled()) + { + PROTOCOL.format("Read timeStamp: {0}", timeStamp); + } + } + } + + @Override + protected void responding(ExtendedDataOutputStream out) throws IOException + { + RevisionManagerImpl rm = getRevisionManager(); + CDORevisionImpl revision = historical ? rm.getHistoricalRevision(id, timeStamp) : rm.getActualRevision(id); + revision.write(out, null); + } +} diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/OpenSessionIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/OpenSessionIndication.java new file mode 100644 index 0000000000..4e1c01d633 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/OpenSessionIndication.java @@ -0,0 +1,112 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.cdo.internal.server.protocol; + +import org.eclipse.emf.cdo.internal.protocol.bundle.CDOProtocol; +import org.eclipse.emf.cdo.internal.server.RepositoryImpl; +import org.eclipse.emf.cdo.internal.server.RepositoryManagerImpl; +import org.eclipse.emf.cdo.internal.server.SessionImpl; +import org.eclipse.emf.cdo.internal.server.SessionManagerImpl; +import org.eclipse.emf.cdo.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.server.Repository; +import org.eclipse.emf.cdo.server.Session; + +import org.eclipse.net4j.signal.IndicationWithResponse; +import org.eclipse.net4j.util.om.trace.ContextTracer; +import org.eclipse.net4j.util.stream.ExtendedDataInputStream; +import org.eclipse.net4j.util.stream.ExtendedDataOutputStream; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class OpenSessionIndication extends IndicationWithResponse +{ + private static final ContextTracer PROTOCOL = new ContextTracer(CDOProtocol.DEBUG_PROTOCOL, + OpenSessionIndication.class); + + private String repositoryName; + + public OpenSessionIndication() + { + } + + @Override + protected short getSignalID() + { + return CDOProtocolConstants.OPEN_SESSION_SIGNAL; + } + + @Override + protected void indicating(ExtendedDataInputStream in) throws IOException + { + repositoryName = in.readString(); + if (PROTOCOL.isEnabled()) + { + PROTOCOL.format("Read repositoryName: {0}", repositoryName); + } + } + + @Override + protected void responding(ExtendedDataOutputStream out) throws IOException + { + RepositoryImpl repository = RepositoryManagerImpl.INSTANCE.getRepository(repositoryName); + if (repository == null) + { + if (PROTOCOL.isEnabled()) + { + PROTOCOL.format("Repository {0} not found", repositoryName); + } + + out.writeInt(CDOProtocolConstants.ERROR_REPOSITORY_NOT_FOUND); + return; + } + + CDOServerProtocol serverProtocol = (CDOServerProtocol)getProtocol(); + SessionManagerImpl sessionManager = repository.getSessionManager(); + SessionImpl session = sessionManager.openSession(serverProtocol); + if (session == null) + { + if (PROTOCOL.isEnabled()) + { + PROTOCOL.format("Failed to open session for repository {0}", repositoryName); + } + + out.writeInt(CDOProtocolConstants.ERROR_NO_SESSION); + return; + } + + (serverProtocol).setSession(session); + writeSessionID(out, session); + writeRepositoryUUID(out, repository); + } + + private void writeSessionID(ExtendedDataOutputStream out, Session session) throws IOException + { + if (PROTOCOL.isEnabled()) + { + PROTOCOL.format("Writing sessionID: {0}", session.getSessionID()); + } + + out.writeInt(session.getSessionID()); + } + + private void writeRepositoryUUID(ExtendedDataOutputStream out, Repository repository) throws IOException + { + if (PROTOCOL.isEnabled()) + { + PROTOCOL.format("Writing repositoryUUID: {0}", repository.getUUID()); + } + + out.writeString(repository.getUUID()); + } +} diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/ResourceIDIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/ResourceIDIndication.java new file mode 100644 index 0000000000..8164a3709e --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/ResourceIDIndication.java @@ -0,0 +1,71 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.cdo.internal.server.protocol; + +import org.eclipse.emf.cdo.internal.protocol.CDOIDImpl; +import org.eclipse.emf.cdo.internal.protocol.bundle.CDOProtocol; +import org.eclipse.emf.cdo.internal.server.bundle.CDOServer; +import org.eclipse.emf.cdo.protocol.CDOID; +import org.eclipse.emf.cdo.protocol.CDOProtocolConstants; + +import org.eclipse.net4j.util.om.trace.ContextTracer; +import org.eclipse.net4j.util.stream.ExtendedDataInputStream; +import org.eclipse.net4j.util.stream.ExtendedDataOutputStream; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class ResourceIDIndication extends CDOServerIndication +{ + private static final ContextTracer PROTOCOL = new ContextTracer(CDOProtocol.DEBUG_PROTOCOL, + ResourceIDIndication.class); + + private CDOID id; + + public ResourceIDIndication() + { + super(CDOProtocolConstants.RESOURCE_ID_SIGNAL); + } + + @Override + protected void indicating(ExtendedDataInputStream in) throws IOException + { + // TODO Optimize transfer of URIs/paths + String path = in.readString(); + if (PROTOCOL.isEnabled()) + { + PROTOCOL.format("Read path: {0}", path); + } + + try + { + id = getResourceManager().getActualResourceID(path); + } + catch (Exception ex) + { + CDOServer.LOG.error(ex); + id = CDOID.NULL; + } + } + + @Override + protected void responding(ExtendedDataOutputStream out) throws IOException + { + if (PROTOCOL.isEnabled()) + { + PROTOCOL.format("Writing ID: {0}", id); + } + + CDOIDImpl.write(out, id); + } +} diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/ResourcePathIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/ResourcePathIndication.java new file mode 100644 index 0000000000..8b1ee59dd0 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/ResourcePathIndication.java @@ -0,0 +1,62 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.cdo.internal.server.protocol; + +import org.eclipse.emf.cdo.internal.protocol.CDOIDImpl; +import org.eclipse.emf.cdo.internal.protocol.bundle.CDOProtocol; +import org.eclipse.emf.cdo.protocol.CDOID; +import org.eclipse.emf.cdo.protocol.CDOProtocolConstants; + +import org.eclipse.net4j.util.om.trace.ContextTracer; +import org.eclipse.net4j.util.stream.ExtendedDataInputStream; +import org.eclipse.net4j.util.stream.ExtendedDataOutputStream; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class ResourcePathIndication extends CDOServerIndication +{ + private static final ContextTracer PROTOCOL = new ContextTracer(CDOProtocol.DEBUG_PROTOCOL, + ResourcePathIndication.class); + + private String path; + + public ResourcePathIndication() + { + super(CDOProtocolConstants.RESOURCE_PATH_SIGNAL); + } + + @Override + protected void indicating(ExtendedDataInputStream in) throws IOException + { + CDOID id = CDOIDImpl.read(in); + if (PROTOCOL.isEnabled()) + { + PROTOCOL.format("Read ID: {0}", id); + } + + path = getResourceManager().getActualResourcePath(id); + } + + @Override + protected void responding(ExtendedDataOutputStream out) throws IOException + { + if (PROTOCOL.isEnabled()) + { + PROTOCOL.format("Writing path: {0}", path); + } + + // TODO Optimize transfer of URIs/paths + out.writeString(path); + } +} diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/Repository.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/Repository.java new file mode 100644 index 0000000000..4eb6f59d77 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/Repository.java @@ -0,0 +1,27 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.cdo.server; + +/** + * @author Eike Stepper + */ +public interface Repository +{ + public String getName(); + + public String getUUID(); + + public SessionManager getSessionManager(); + + public ResourceManager getResourceManager(); + + public RevisionManager getRevisionManager(); +} diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/RepositoryManager.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/RepositoryManager.java new file mode 100644 index 0000000000..f727cfa0d6 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/RepositoryManager.java @@ -0,0 +1,23 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.cdo.server; + +import org.eclipse.emf.cdo.internal.server.RepositoryManagerImpl; + +/** + * @author Eike Stepper + */ +public interface RepositoryManager +{ + public static final RepositoryManager INSTANCE = RepositoryManagerImpl.INSTANCE; + + public Repository getRepository(String name); +} diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/ResourceManager.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/ResourceManager.java new file mode 100644 index 0000000000..653227f92e --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/ResourceManager.java @@ -0,0 +1,26 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.cdo.server; + +import org.eclipse.emf.cdo.internal.server.RepositoryImpl; +import org.eclipse.emf.cdo.protocol.CDOID; + +/** + * @author Eike Stepper + */ +public interface ResourceManager +{ + public RepositoryImpl getRepository(); + + public CDOID getActualResourceID(String path); + + public String getActualResourcePath(CDOID id); +} diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/RevisionManager.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/RevisionManager.java new file mode 100644 index 0000000000..acd54b22be --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/RevisionManager.java @@ -0,0 +1,21 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.cdo.server; + +import org.eclipse.emf.cdo.protocol.revision.CDORevisionResolver; + +/** + * @author Eike Stepper + */ +public interface RevisionManager extends CDORevisionResolver +{ + public Repository getRepository(); +} diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/ServerConstants.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/ServerConstants.java new file mode 100644 index 0000000000..c654fdd4a7 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/ServerConstants.java @@ -0,0 +1,21 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.cdo.server; + +import org.eclipse.emf.cdo.protocol.CDOProtocolConstants; + +/** + * @author Eike Stepper + */ +public interface ServerConstants +{ + public static final String TYPE = CDOProtocolConstants.PROTOCOL_NAME + "server"; +} diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/Session.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/Session.java new file mode 100644 index 0000000000..0fee6b3663 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/Session.java @@ -0,0 +1,25 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.cdo.server; + +import org.eclipse.emf.cdo.internal.server.protocol.CDOServerProtocol; + +/** + * @author Eike Stepper + */ +public interface Session +{ + public SessionManager getSessionManager(); + + public CDOServerProtocol getProtocol(); + + public int getSessionID(); +} diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/SessionManager.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/SessionManager.java new file mode 100644 index 0000000000..7359db392e --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/SessionManager.java @@ -0,0 +1,25 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.cdo.server; + +import org.eclipse.emf.cdo.internal.server.protocol.CDOServerProtocol; + +/** + * @author Eike Stepper + */ +public interface SessionManager +{ + public Repository getRepository(); + + public Session[] getSessions(); + + public Session openSession(CDOServerProtocol protocol); +} diff --git a/plugins/org.eclipse.emf.cdo/.classpath b/plugins/org.eclipse.emf.cdo/.classpath new file mode 100644 index 0000000000..ab96b0ff60 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry excluding="org/eclipse/emf/internal/cdo/CDOModelManagerImpl.java|org/eclipse/emf/cdo/CDOResource.java|org/eclipse/emf/cdo/CDOLocal.java|org/eclipse/emf/internal/cdo/CDOLocalInternal.java|org/eclipse/emf/internal/cdo/util/ResourceUtil.java|org/eclipse/emf/internal/cdo/util/TransientStore.java|org/eclipse/emf/cdo/CDOResourceManager.java|org/eclipse/emf/internal/cdo/CDOResourceManagerImpl.java|org/eclipse/emf/internal/cdo/protocol/LoadResourcePathRequest.java|org/eclipse/emf/internal/cdo/protocol/AddModelsRequest.java|org/eclipse/emf/internal/cdo/CDOResourceImpl.java" kind="src" path="src"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/plugins/org.eclipse.emf.cdo/.cvsignore b/plugins/org.eclipse.emf.cdo/.cvsignore new file mode 100644 index 0000000000..693869726d --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/.cvsignore @@ -0,0 +1,2 @@ +bin +doc diff --git a/plugins/org.eclipse.emf.cdo/.options b/plugins/org.eclipse.emf.cdo/.options new file mode 100644 index 0000000000..728617cc66 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/.options @@ -0,0 +1,10 @@ +org.eclipse.emf.cdo/debug = true +org.eclipse.emf.cdo/debug.util = true +org.eclipse.emf.cdo/debug.repository = true +org.eclipse.emf.cdo/debug.session = true +org.eclipse.emf.cdo/debug.adapter = true +org.eclipse.emf.cdo/debug.view = true +org.eclipse.emf.cdo/debug.transaction = true +org.eclipse.emf.cdo/debug.object = true +org.eclipse.emf.cdo/debug.resource = true +org.eclipse.emf.cdo/debug.revision = true diff --git a/plugins/org.eclipse.emf.cdo/.project b/plugins/org.eclipse.emf.cdo/.project new file mode 100644 index 0000000000..b582e8aa34 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.emf.cdo</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/plugins/org.eclipse.emf.cdo/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.emf.cdo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..40cfe76ba5 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +#Sun Jan 07 14:25:28 CET 2007 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.5 diff --git a/plugins/org.eclipse.emf.cdo/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..62c47957d0 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/META-INF/MANIFEST.MF @@ -0,0 +1,23 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: %pluginName +Bundle-SymbolicName: org.eclipse.emf.cdo; singleton:=true +Bundle-Version: 0.8.0.qualifier +Bundle-ClassPath: . +Bundle-Vendor: %providerName +Bundle-Localization: plugin +Bundle-Activator: org.eclipse.emf.internal.cdo.bundle.Activator$Implementation +Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Export-Package: org.eclipse.emf.cdo;version="0.8.0", + org.eclipse.emf.cdo.eresource;version="0.8.0", + org.eclipse.emf.cdo.eresource.impl;version="0.8.0", + org.eclipse.emf.cdo.eresource.util;version="0.8.0", + org.eclipse.emf.cdo.util;version="0.8.0", + org.eclipse.emf.internal.cdo;version="0.8.0", + org.eclipse.emf.internal.cdo.bundle;version="0.8.0", + org.eclipse.emf.internal.cdo.protocol;version="0.8.0", + org.eclipse.emf.internal.cdo.util;version="0.8.0" +Require-Bundle: org.eclipse.core.runtime, + org.eclipse.emf.ecore;visibility:=reexport, + org.eclipse.emf.cdo.protocol;bundle-version="0.8.0";visibility:=reexport +Eclipse-LazyStart: true diff --git a/plugins/org.eclipse.emf.cdo/about.html b/plugins/org.eclipse.emf.cdo/about.html new file mode 100644 index 0000000000..81a265f458 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/about.html @@ -0,0 +1,42 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html> + + <head> + + <meta content="text/html; charset=ISO-8859-1" + http-equiv="Content-Type"/> + + <title>About</title> + + </head> + + <body lang="EN-US"> + + <h2>About This Content</h2> + + <p>May 17, 2007</p> + + <h3>License</h3> + + <p>The Eclipse Foundation makes available all content in this + plug-in ("Content"). Unless otherwise indicated below, + the Content is provided to you under the terms and conditions of + the Eclipse Public License Version 1.0 ("EPL"). A copy of + the EPL is available at + <a href="http://www.eclipse.org/legal/epl-v10.html"> + http://www.eclipse.org/legal/epl-v10.html</a>. For purposes of the + EPL, "Program" will mean the Content.</p> + + <p>If you did not receive this Content directly from the Eclipse + Foundation, the Content is being redistributed by another party + ("Redistributor") and different terms and conditions may + apply to your use of any object code in the Content. Check the + Redistributor's license that was provided with the Content. If + no such license exists, contact the Redistributor. Unless otherwise + indicated below, the terms and conditions of the EPL still apply to + any source code in the Content.</p> + + </body> + +</html> + diff --git a/plugins/org.eclipse.emf.cdo/build.properties b/plugins/org.eclipse.emf.cdo/build.properties new file mode 100644 index 0000000000..37a8aafa15 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/build.properties @@ -0,0 +1,17 @@ +# <copyright> +# </copyright> +# +# $Id$ + +bin.includes = .,\ + META-INF/,\ + plugin.properties,\ + .options,\ + about.html,\ + copyright.txt,\ + epl-v10.html,\ + license.html,\ + plugin.xml +jars.compile.order = . +source.. = src/ +output.. = bin/ diff --git a/plugins/org.eclipse.emf.cdo/copyright.txt b/plugins/org.eclipse.emf.cdo/copyright.txt new file mode 100644 index 0000000000..025f15218e --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/copyright.txt @@ -0,0 +1,8 @@ +Copyright (c) 2004 - 2007 Eike Stepper, Germany. +All rights reserved. This program and the accompanying materials +are made available under the terms of the Eclipse Public License v1.0 +which accompanies this distribution, and is available at +http://www.eclipse.org/legal/epl-v10.html + +Contributors: + Eike Stepper - initial API and implementation
\ No newline at end of file diff --git a/plugins/org.eclipse.emf.cdo/epl-v10.html b/plugins/org.eclipse.emf.cdo/epl-v10.html new file mode 100644 index 0000000000..d7b88e9416 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/epl-v10.html @@ -0,0 +1,319 @@ +<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40"><head> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta name="ProgId" content="Word.Document"> +<meta name="Generator" content="Microsoft Word 9"> +<meta name="Originator" content="Microsoft Word 9"> +<link rel="File-List" href="http://www.eclipse.org/org/documents/Eclipse%20EPL%202003_11_10%20Final_files/filelist.xml"><title>Eclipse Public License - Version 1.0</title><!--[if gte mso 9]><xml> + <o:DocumentProperties> + <o:Revision>2</o:Revision> + <o:TotalTime>3</o:TotalTime> + <o:Created>2004-03-05T23:03:00Z</o:Created> + <o:LastSaved>2004-03-05T23:03:00Z</o:LastSaved> + <o:Pages>4</o:Pages> + <o:Words>1626</o:Words> + <o:Characters>9270</o:Characters> + <o:Lines>77</o:Lines> + <o:Paragraphs>18</o:Paragraphs> + <o:CharactersWithSpaces>11384</o:CharactersWithSpaces> + <o:Version>9.4402</o:Version> + </o:DocumentProperties> +</xml><![endif]--><!--[if gte mso 9]><xml> + <w:WordDocument> + <w:TrackRevisions/> + </w:WordDocument> +</xml><![endif]--> + + +<style> +<!-- + /* Font Definitions */ +@font-face + {font-family:Tahoma; + panose-1:2 11 6 4 3 5 4 4 2 4; + mso-font-charset:0; + mso-generic-font-family:swiss; + mso-font-pitch:variable; + mso-font-signature:553679495 -2147483648 8 0 66047 0;} + /* Style Definitions */ +p.MsoNormal, li.MsoNormal, div.MsoNormal + {mso-style-parent:""; + margin:0in; + margin-bottom:.0001pt; + mso-pagination:widow-orphan; + font-size:12.0pt; + font-family:"Times New Roman"; + mso-fareast-font-family:"Times New Roman";} +p + {margin-right:0in; + mso-margin-top-alt:auto; + mso-margin-bottom-alt:auto; + margin-left:0in; + mso-pagination:widow-orphan; + font-size:12.0pt; + font-family:"Times New Roman"; + mso-fareast-font-family:"Times New Roman";} +p.BalloonText, li.BalloonText, div.BalloonText + {mso-style-name:"Balloon Text"; + margin:0in; + margin-bottom:.0001pt; + mso-pagination:widow-orphan; + font-size:8.0pt; + font-family:Tahoma; + mso-fareast-font-family:"Times New Roman";} +@page Section1 + {size:8.5in 11.0in; + margin:1.0in 1.25in 1.0in 1.25in; + mso-header-margin:.5in; + mso-footer-margin:.5in; + mso-paper-source:0;} +div.Section1 + {page:Section1;} +--> +</style></head> + +<body style="" lang="EN-US"> + +<div class="Section1"> + +<p style="text-align: center;" align="center"><b>Eclipse Public License - v 1.0</b> +</p> + +<p><span style="font-size: 10pt;">THE ACCOMPANYING PROGRAM IS PROVIDED UNDER +THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, +REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE +OF THIS AGREEMENT.</span> </p> + +<p><b><span style="font-size: 10pt;">1. DEFINITIONS</span></b> </p> + +<p><span style="font-size: 10pt;">"Contribution" means:</span> </p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">a) +in the case of the initial Contributor, the initial code and documentation +distributed under this Agreement, and<br clear="left"> +b) in the case of each subsequent Contributor:</span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">i) +changes to the Program, and</span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">ii) +additions to the Program;</span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">where +such changes and/or additions to the Program originate from and are distributed +by that particular Contributor. A Contribution 'originates' from a Contributor +if it was added to the Program by such Contributor itself or anyone acting on +such Contributor's behalf. Contributions do not include additions to the +Program which: (i) are separate modules of software distributed in conjunction +with the Program under their own license agreement, and (ii) are not derivative +works of the Program. </span></p> + +<p><span style="font-size: 10pt;">"Contributor" means any person or +entity that distributes the Program.</span> </p> + +<p><span style="font-size: 10pt;">"Licensed Patents " mean patent +claims licensable by a Contributor which are necessarily infringed by the use +or sale of its Contribution alone or when combined with the Program. </span></p> + +<p><span style="font-size: 10pt;">"Program" means the Contributions +distributed in accordance with this Agreement.</span> </p> + +<p><span style="font-size: 10pt;">"Recipient" means anyone who +receives the Program under this Agreement, including all Contributors.</span> </p> + +<p><b><span style="font-size: 10pt;">2. GRANT OF RIGHTS</span></b> </p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">a) +Subject to the terms of this Agreement, each Contributor hereby grants Recipient +a non-exclusive, worldwide, royalty-free copyright license to<span style="color: red;"> </span>reproduce, prepare derivative works of, publicly +display, publicly perform, distribute and sublicense the Contribution of such +Contributor, if any, and such derivative works, in source code and object code +form.</span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">b) +Subject to the terms of this Agreement, each Contributor hereby grants +Recipient a non-exclusive, worldwide,<span style="color: green;"> </span>royalty-free +patent license under Licensed Patents to make, use, sell, offer to sell, import +and otherwise transfer the Contribution of such Contributor, if any, in source +code and object code form. This patent license shall apply to the combination +of the Contribution and the Program if, at the time the Contribution is added +by the Contributor, such addition of the Contribution causes such combination +to be covered by the Licensed Patents. The patent license shall not apply to +any other combinations which include the Contribution. No hardware per se is +licensed hereunder. </span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">c) +Recipient understands that although each Contributor grants the licenses to its +Contributions set forth herein, no assurances are provided by any Contributor +that the Program does not infringe the patent or other intellectual property +rights of any other entity. Each Contributor disclaims any liability to Recipient +for claims brought by any other entity based on infringement of intellectual +property rights or otherwise. As a condition to exercising the rights and +licenses granted hereunder, each Recipient hereby assumes sole responsibility +to secure any other intellectual property rights needed, if any. For example, +if a third party patent license is required to allow Recipient to distribute +the Program, it is Recipient's responsibility to acquire that license before +distributing the Program.</span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">d) +Each Contributor represents that to its knowledge it has sufficient copyright +rights in its Contribution, if any, to grant the copyright license set forth in +this Agreement. </span></p> + +<p><b><span style="font-size: 10pt;">3. REQUIREMENTS</span></b> </p> + +<p><span style="font-size: 10pt;">A Contributor may choose to distribute the +Program in object code form under its own license agreement, provided that:</span> +</p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">a) +it complies with the terms and conditions of this Agreement; and</span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">b) +its license agreement:</span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">i) +effectively disclaims on behalf of all Contributors all warranties and +conditions, express and implied, including warranties or conditions of title +and non-infringement, and implied warranties or conditions of merchantability +and fitness for a particular purpose; </span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">ii) +effectively excludes on behalf of all Contributors all liability for damages, +including direct, indirect, special, incidental and consequential damages, such +as lost profits; </span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">iii) +states that any provisions which differ from this Agreement are offered by that +Contributor alone and not by any other party; and</span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">iv) +states that source code for the Program is available from such Contributor, and +informs licensees how to obtain it in a reasonable manner on or through a +medium customarily used for software exchange.<span style="color: blue;"> </span></span></p> + +<p><span style="font-size: 10pt;">When the Program is made available in source +code form:</span> </p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">a) +it must be made available under this Agreement; and </span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">b) a +copy of this Agreement must be included with each copy of the Program. </span></p> + +<p><span style="font-size: 10pt;">Contributors may not remove or alter any +copyright notices contained within the Program. </span></p> + +<p><span style="font-size: 10pt;">Each Contributor must identify itself as the +originator of its Contribution, if any, in a manner that reasonably allows +subsequent Recipients to identify the originator of the Contribution. </span></p> + +<p><b><span style="font-size: 10pt;">4. COMMERCIAL DISTRIBUTION</span></b> </p> + +<p><span style="font-size: 10pt;">Commercial distributors of software may +accept certain responsibilities with respect to end users, business partners +and the like. While this license is intended to facilitate the commercial use +of the Program, the Contributor who includes the Program in a commercial +product offering should do so in a manner which does not create potential +liability for other Contributors. Therefore, if a Contributor includes the +Program in a commercial product offering, such Contributor ("Commercial +Contributor") hereby agrees to defend and indemnify every other +Contributor ("Indemnified Contributor") against any losses, damages and +costs (collectively "Losses") arising from claims, lawsuits and other +legal actions brought by a third party against the Indemnified Contributor to +the extent caused by the acts or omissions of such Commercial Contributor in +connection with its distribution of the Program in a commercial product +offering. The obligations in this section do not apply to any claims or Losses +relating to any actual or alleged intellectual property infringement. In order +to qualify, an Indemnified Contributor must: a) promptly notify the Commercial +Contributor in writing of such claim, and b) allow the Commercial Contributor +to control, and cooperate with the Commercial Contributor in, the defense and +any related settlement negotiations. The Indemnified Contributor may participate +in any such claim at its own expense.</span> </p> + +<p><span style="font-size: 10pt;">For example, a Contributor might include the +Program in a commercial product offering, Product X. That Contributor is then a +Commercial Contributor. If that Commercial Contributor then makes performance +claims, or offers warranties related to Product X, those performance claims and +warranties are such Commercial Contributor's responsibility alone. Under this +section, the Commercial Contributor would have to defend claims against the +other Contributors related to those performance claims and warranties, and if a +court requires any other Contributor to pay any damages as a result, the +Commercial Contributor must pay those damages.</span> </p> + +<p><b><span style="font-size: 10pt;">5. NO WARRANTY</span></b> </p> + +<p><span style="font-size: 10pt;">EXCEPT AS EXPRESSLY SET FORTH IN THIS +AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT +WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, +WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, +MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely +responsible for determining the appropriateness of using and distributing the +Program and assumes all risks associated with its exercise of rights under this +Agreement , including but not limited to the risks and costs of program errors, +compliance with applicable laws, damage to or loss of data, programs or +equipment, and unavailability or interruption of operations. </span></p> + +<p><b><span style="font-size: 10pt;">6. DISCLAIMER OF LIABILITY</span></b> </p> + +<p><span style="font-size: 10pt;">EXCEPT AS EXPRESSLY SET FORTH IN THIS +AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF +THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGES.</span> </p> + +<p><b><span style="font-size: 10pt;">7. GENERAL</span></b> </p> + +<p><span style="font-size: 10pt;">If any provision of this Agreement is invalid +or unenforceable under applicable law, it shall not affect the validity or +enforceability of the remainder of the terms of this Agreement, and without +further action by the parties hereto, such provision shall be reformed to the +minimum extent necessary to make such provision valid and enforceable.</span> </p> + +<p><span style="font-size: 10pt;">If Recipient institutes patent litigation +against any entity (including a cross-claim or counterclaim in a lawsuit) +alleging that the Program itself (excluding combinations of the Program with +other software or hardware) infringes such Recipient's patent(s), then such +Recipient's rights granted under Section 2(b) shall terminate as of the date +such litigation is filed. </span></p> + +<p><span style="font-size: 10pt;">All Recipient's rights under this Agreement +shall terminate if it fails to comply with any of the material terms or +conditions of this Agreement and does not cure such failure in a reasonable +period of time after becoming aware of such noncompliance. If all Recipient's +rights under this Agreement terminate, Recipient agrees to cease use and +distribution of the Program as soon as reasonably practicable. However, +Recipient's obligations under this Agreement and any licenses granted by +Recipient relating to the Program shall continue and survive. </span></p> + +<p><span style="font-size: 10pt;">Everyone is permitted to copy and distribute +copies of this Agreement, but in order to avoid inconsistency the Agreement is +copyrighted and may only be modified in the following manner. The Agreement +Steward reserves the right to publish new versions (including revisions) of +this Agreement from time to time. No one other than the Agreement Steward has +the right to modify this Agreement. The Eclipse Foundation is the initial +Agreement Steward. The Eclipse Foundation may assign the responsibility to +serve as the Agreement Steward to a suitable separate entity. Each new version +of the Agreement will be given a distinguishing version number. The Program +(including Contributions) may always be distributed subject to the version of +the Agreement under which it was received. In addition, after a new version of +the Agreement is published, Contributor may elect to distribute the Program +(including its Contributions) under the new version. Except as expressly stated +in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to +the intellectual property of any Contributor under this Agreement, whether +expressly, by implication, estoppel or otherwise. All rights in the Program not +expressly granted under this Agreement are reserved.</span> </p> + +<p><span style="font-size: 10pt;">This Agreement is governed by the laws of the +State of New York and the intellectual property laws of the United States of +America. No party to this Agreement will bring a legal action under this +Agreement more than one year after the cause of action arose. Each party waives +its rights to a jury trial in any resulting litigation.</span> </p> + +<p class="MsoNormal"><!--[if !supportEmptyParas]--> <!--[endif]--><o:p></o:p></p> + +</div> + +</body></html>
\ No newline at end of file diff --git a/plugins/org.eclipse.emf.cdo/license.html b/plugins/org.eclipse.emf.cdo/license.html new file mode 100644 index 0000000000..d7b88e9416 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/license.html @@ -0,0 +1,319 @@ +<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40"><head> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta name="ProgId" content="Word.Document"> +<meta name="Generator" content="Microsoft Word 9"> +<meta name="Originator" content="Microsoft Word 9"> +<link rel="File-List" href="http://www.eclipse.org/org/documents/Eclipse%20EPL%202003_11_10%20Final_files/filelist.xml"><title>Eclipse Public License - Version 1.0</title><!--[if gte mso 9]><xml> + <o:DocumentProperties> + <o:Revision>2</o:Revision> + <o:TotalTime>3</o:TotalTime> + <o:Created>2004-03-05T23:03:00Z</o:Created> + <o:LastSaved>2004-03-05T23:03:00Z</o:LastSaved> + <o:Pages>4</o:Pages> + <o:Words>1626</o:Words> + <o:Characters>9270</o:Characters> + <o:Lines>77</o:Lines> + <o:Paragraphs>18</o:Paragraphs> + <o:CharactersWithSpaces>11384</o:CharactersWithSpaces> + <o:Version>9.4402</o:Version> + </o:DocumentProperties> +</xml><![endif]--><!--[if gte mso 9]><xml> + <w:WordDocument> + <w:TrackRevisions/> + </w:WordDocument> +</xml><![endif]--> + + +<style> +<!-- + /* Font Definitions */ +@font-face + {font-family:Tahoma; + panose-1:2 11 6 4 3 5 4 4 2 4; + mso-font-charset:0; + mso-generic-font-family:swiss; + mso-font-pitch:variable; + mso-font-signature:553679495 -2147483648 8 0 66047 0;} + /* Style Definitions */ +p.MsoNormal, li.MsoNormal, div.MsoNormal + {mso-style-parent:""; + margin:0in; + margin-bottom:.0001pt; + mso-pagination:widow-orphan; + font-size:12.0pt; + font-family:"Times New Roman"; + mso-fareast-font-family:"Times New Roman";} +p + {margin-right:0in; + mso-margin-top-alt:auto; + mso-margin-bottom-alt:auto; + margin-left:0in; + mso-pagination:widow-orphan; + font-size:12.0pt; + font-family:"Times New Roman"; + mso-fareast-font-family:"Times New Roman";} +p.BalloonText, li.BalloonText, div.BalloonText + {mso-style-name:"Balloon Text"; + margin:0in; + margin-bottom:.0001pt; + mso-pagination:widow-orphan; + font-size:8.0pt; + font-family:Tahoma; + mso-fareast-font-family:"Times New Roman";} +@page Section1 + {size:8.5in 11.0in; + margin:1.0in 1.25in 1.0in 1.25in; + mso-header-margin:.5in; + mso-footer-margin:.5in; + mso-paper-source:0;} +div.Section1 + {page:Section1;} +--> +</style></head> + +<body style="" lang="EN-US"> + +<div class="Section1"> + +<p style="text-align: center;" align="center"><b>Eclipse Public License - v 1.0</b> +</p> + +<p><span style="font-size: 10pt;">THE ACCOMPANYING PROGRAM IS PROVIDED UNDER +THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, +REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE +OF THIS AGREEMENT.</span> </p> + +<p><b><span style="font-size: 10pt;">1. DEFINITIONS</span></b> </p> + +<p><span style="font-size: 10pt;">"Contribution" means:</span> </p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">a) +in the case of the initial Contributor, the initial code and documentation +distributed under this Agreement, and<br clear="left"> +b) in the case of each subsequent Contributor:</span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">i) +changes to the Program, and</span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">ii) +additions to the Program;</span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">where +such changes and/or additions to the Program originate from and are distributed +by that particular Contributor. A Contribution 'originates' from a Contributor +if it was added to the Program by such Contributor itself or anyone acting on +such Contributor's behalf. Contributions do not include additions to the +Program which: (i) are separate modules of software distributed in conjunction +with the Program under their own license agreement, and (ii) are not derivative +works of the Program. </span></p> + +<p><span style="font-size: 10pt;">"Contributor" means any person or +entity that distributes the Program.</span> </p> + +<p><span style="font-size: 10pt;">"Licensed Patents " mean patent +claims licensable by a Contributor which are necessarily infringed by the use +or sale of its Contribution alone or when combined with the Program. </span></p> + +<p><span style="font-size: 10pt;">"Program" means the Contributions +distributed in accordance with this Agreement.</span> </p> + +<p><span style="font-size: 10pt;">"Recipient" means anyone who +receives the Program under this Agreement, including all Contributors.</span> </p> + +<p><b><span style="font-size: 10pt;">2. GRANT OF RIGHTS</span></b> </p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">a) +Subject to the terms of this Agreement, each Contributor hereby grants Recipient +a non-exclusive, worldwide, royalty-free copyright license to<span style="color: red;"> </span>reproduce, prepare derivative works of, publicly +display, publicly perform, distribute and sublicense the Contribution of such +Contributor, if any, and such derivative works, in source code and object code +form.</span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">b) +Subject to the terms of this Agreement, each Contributor hereby grants +Recipient a non-exclusive, worldwide,<span style="color: green;"> </span>royalty-free +patent license under Licensed Patents to make, use, sell, offer to sell, import +and otherwise transfer the Contribution of such Contributor, if any, in source +code and object code form. This patent license shall apply to the combination +of the Contribution and the Program if, at the time the Contribution is added +by the Contributor, such addition of the Contribution causes such combination +to be covered by the Licensed Patents. The patent license shall not apply to +any other combinations which include the Contribution. No hardware per se is +licensed hereunder. </span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">c) +Recipient understands that although each Contributor grants the licenses to its +Contributions set forth herein, no assurances are provided by any Contributor +that the Program does not infringe the patent or other intellectual property +rights of any other entity. Each Contributor disclaims any liability to Recipient +for claims brought by any other entity based on infringement of intellectual +property rights or otherwise. As a condition to exercising the rights and +licenses granted hereunder, each Recipient hereby assumes sole responsibility +to secure any other intellectual property rights needed, if any. For example, +if a third party patent license is required to allow Recipient to distribute +the Program, it is Recipient's responsibility to acquire that license before +distributing the Program.</span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">d) +Each Contributor represents that to its knowledge it has sufficient copyright +rights in its Contribution, if any, to grant the copyright license set forth in +this Agreement. </span></p> + +<p><b><span style="font-size: 10pt;">3. REQUIREMENTS</span></b> </p> + +<p><span style="font-size: 10pt;">A Contributor may choose to distribute the +Program in object code form under its own license agreement, provided that:</span> +</p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">a) +it complies with the terms and conditions of this Agreement; and</span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">b) +its license agreement:</span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">i) +effectively disclaims on behalf of all Contributors all warranties and +conditions, express and implied, including warranties or conditions of title +and non-infringement, and implied warranties or conditions of merchantability +and fitness for a particular purpose; </span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">ii) +effectively excludes on behalf of all Contributors all liability for damages, +including direct, indirect, special, incidental and consequential damages, such +as lost profits; </span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">iii) +states that any provisions which differ from this Agreement are offered by that +Contributor alone and not by any other party; and</span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">iv) +states that source code for the Program is available from such Contributor, and +informs licensees how to obtain it in a reasonable manner on or through a +medium customarily used for software exchange.<span style="color: blue;"> </span></span></p> + +<p><span style="font-size: 10pt;">When the Program is made available in source +code form:</span> </p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">a) +it must be made available under this Agreement; and </span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">b) a +copy of this Agreement must be included with each copy of the Program. </span></p> + +<p><span style="font-size: 10pt;">Contributors may not remove or alter any +copyright notices contained within the Program. </span></p> + +<p><span style="font-size: 10pt;">Each Contributor must identify itself as the +originator of its Contribution, if any, in a manner that reasonably allows +subsequent Recipients to identify the originator of the Contribution. </span></p> + +<p><b><span style="font-size: 10pt;">4. COMMERCIAL DISTRIBUTION</span></b> </p> + +<p><span style="font-size: 10pt;">Commercial distributors of software may +accept certain responsibilities with respect to end users, business partners +and the like. While this license is intended to facilitate the commercial use +of the Program, the Contributor who includes the Program in a commercial +product offering should do so in a manner which does not create potential +liability for other Contributors. Therefore, if a Contributor includes the +Program in a commercial product offering, such Contributor ("Commercial +Contributor") hereby agrees to defend and indemnify every other +Contributor ("Indemnified Contributor") against any losses, damages and +costs (collectively "Losses") arising from claims, lawsuits and other +legal actions brought by a third party against the Indemnified Contributor to +the extent caused by the acts or omissions of such Commercial Contributor in +connection with its distribution of the Program in a commercial product +offering. The obligations in this section do not apply to any claims or Losses +relating to any actual or alleged intellectual property infringement. In order +to qualify, an Indemnified Contributor must: a) promptly notify the Commercial +Contributor in writing of such claim, and b) allow the Commercial Contributor +to control, and cooperate with the Commercial Contributor in, the defense and +any related settlement negotiations. The Indemnified Contributor may participate +in any such claim at its own expense.</span> </p> + +<p><span style="font-size: 10pt;">For example, a Contributor might include the +Program in a commercial product offering, Product X. That Contributor is then a +Commercial Contributor. If that Commercial Contributor then makes performance +claims, or offers warranties related to Product X, those performance claims and +warranties are such Commercial Contributor's responsibility alone. Under this +section, the Commercial Contributor would have to defend claims against the +other Contributors related to those performance claims and warranties, and if a +court requires any other Contributor to pay any damages as a result, the +Commercial Contributor must pay those damages.</span> </p> + +<p><b><span style="font-size: 10pt;">5. NO WARRANTY</span></b> </p> + +<p><span style="font-size: 10pt;">EXCEPT AS EXPRESSLY SET FORTH IN THIS +AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT +WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, +WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, +MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely +responsible for determining the appropriateness of using and distributing the +Program and assumes all risks associated with its exercise of rights under this +Agreement , including but not limited to the risks and costs of program errors, +compliance with applicable laws, damage to or loss of data, programs or +equipment, and unavailability or interruption of operations. </span></p> + +<p><b><span style="font-size: 10pt;">6. DISCLAIMER OF LIABILITY</span></b> </p> + +<p><span style="font-size: 10pt;">EXCEPT AS EXPRESSLY SET FORTH IN THIS +AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF +THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGES.</span> </p> + +<p><b><span style="font-size: 10pt;">7. GENERAL</span></b> </p> + +<p><span style="font-size: 10pt;">If any provision of this Agreement is invalid +or unenforceable under applicable law, it shall not affect the validity or +enforceability of the remainder of the terms of this Agreement, and without +further action by the parties hereto, such provision shall be reformed to the +minimum extent necessary to make such provision valid and enforceable.</span> </p> + +<p><span style="font-size: 10pt;">If Recipient institutes patent litigation +against any entity (including a cross-claim or counterclaim in a lawsuit) +alleging that the Program itself (excluding combinations of the Program with +other software or hardware) infringes such Recipient's patent(s), then such +Recipient's rights granted under Section 2(b) shall terminate as of the date +such litigation is filed. </span></p> + +<p><span style="font-size: 10pt;">All Recipient's rights under this Agreement +shall terminate if it fails to comply with any of the material terms or +conditions of this Agreement and does not cure such failure in a reasonable +period of time after becoming aware of such noncompliance. If all Recipient's +rights under this Agreement terminate, Recipient agrees to cease use and +distribution of the Program as soon as reasonably practicable. However, +Recipient's obligations under this Agreement and any licenses granted by +Recipient relating to the Program shall continue and survive. </span></p> + +<p><span style="font-size: 10pt;">Everyone is permitted to copy and distribute +copies of this Agreement, but in order to avoid inconsistency the Agreement is +copyrighted and may only be modified in the following manner. The Agreement +Steward reserves the right to publish new versions (including revisions) of +this Agreement from time to time. No one other than the Agreement Steward has +the right to modify this Agreement. The Eclipse Foundation is the initial +Agreement Steward. The Eclipse Foundation may assign the responsibility to +serve as the Agreement Steward to a suitable separate entity. Each new version +of the Agreement will be given a distinguishing version number. The Program +(including Contributions) may always be distributed subject to the version of +the Agreement under which it was received. In addition, after a new version of +the Agreement is published, Contributor may elect to distribute the Program +(including its Contributions) under the new version. Except as expressly stated +in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to +the intellectual property of any Contributor under this Agreement, whether +expressly, by implication, estoppel or otherwise. All rights in the Program not +expressly granted under this Agreement are reserved.</span> </p> + +<p><span style="font-size: 10pt;">This Agreement is governed by the laws of the +State of New York and the intellectual property laws of the United States of +America. No party to this Agreement will bring a legal action under this +Agreement more than one year after the cause of action arose. Each party waives +its rights to a jury trial in any resulting litigation.</span> </p> + +<p class="MsoNormal"><!--[if !supportEmptyParas]--> <!--[endif]--><o:p></o:p></p> + +</div> + +</body></html>
\ No newline at end of file diff --git a/plugins/org.eclipse.emf.cdo/model/eresource.ecore b/plugins/org.eclipse.emf.cdo/model/eresource.ecore new file mode 100644 index 0000000000..6e820057fe --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/model/eresource.ecore @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ecore:EPackage xmi:version="2.0" + xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="eresource" + nsURI="http://www.eclipse.org/emf/CDO/resource/1.0.0" nsPrefix="eresource"> + <eClassifiers xsi:type="ecore:EClass" name="CDOResource"> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="resourceSet" eType="#//ResourceSet" + transient="true"/> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="uRI" eType="#//URI" transient="true"/> + <eStructuralFeatures xsi:type="ecore:EReference" name="contents" upperBound="-1" + eType="ecore:EClass ../../../plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EObject" + containment="true"/> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="modified" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean" + transient="true"/> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="loaded" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean" + transient="true"/> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="trackingModification" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean" + transient="true"/> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="errors" upperBound="-1" + eType="#//Diagnostic" transient="true"/> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="warnings" upperBound="-1" + eType="#//Diagnostic" transient="true"/> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="path" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> + </eClassifiers> + <eClassifiers xsi:type="ecore:EDataType" name="ResourceSet" instanceClassName="org.eclipse.emf.ecore.resource.ResourceSet" + serializable="false"/> + <eClassifiers xsi:type="ecore:EDataType" name="URI" instanceClassName="org.eclipse.emf.common.util.URI"/> + <eClassifiers xsi:type="ecore:EDataType" name="Diagnostic" instanceClassName="org.eclipse.emf.ecore.resource.Resource.Diagnostic" + serializable="false"/> +</ecore:EPackage> diff --git a/plugins/org.eclipse.emf.cdo/model/resource.genmodel b/plugins/org.eclipse.emf.cdo/model/resource.genmodel new file mode 100644 index 0000000000..a40d9222e7 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/model/resource.genmodel @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> +<genmodel:GenModel xmi:version="2.0" + xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" + xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel" copyrightText="" + modelDirectory="/cdo2/src" editDirectory="" editorDirectory="" modelPluginID="org.eclipse.emf.cdo" + modelName="Eresource" updateClasspath="false" rootExtendsInterface="org.eclipse.emf.cdo.eresource.EresourceObject" + rootExtendsClass="org.eclipse.emf.internal.cdo.CDOObjectImpl" reflectiveDelegation="true" + codeFormatting="true" testsDirectory="" importerID="org.eclipse.emf.importer.ecore" + featureDelegation="Reflective" complianceLevel="5.0" usedGenPackages="../../../plugin/org.eclipse.emf.ecore/model/Ecore.genmodel#//ecore"> + <foreignModel>eresource.ecore</foreignModel> + <genPackages prefix="Eresource" basePackage="org.eclipse.emf.cdo" disposableProviderFactory="true" + ecorePackage="eresource.ecore#/"> + <genDataTypes ecoreDataType="eresource.ecore#//ResourceSet"/> + <genDataTypes ecoreDataType="eresource.ecore#//URI"/> + <genDataTypes ecoreDataType="eresource.ecore#//Diagnostic"/> + <genClasses ecoreClass="eresource.ecore#//CDOResource"> + <genFeatures createChild="false" ecoreFeature="ecore:EAttribute eresource.ecore#//CDOResource/resourceSet"/> + <genFeatures createChild="false" ecoreFeature="ecore:EAttribute eresource.ecore#//CDOResource/uRI"/> + <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference eresource.ecore#//CDOResource/contents"/> + <genFeatures createChild="false" ecoreFeature="ecore:EAttribute eresource.ecore#//CDOResource/modified"/> + <genFeatures createChild="false" ecoreFeature="ecore:EAttribute eresource.ecore#//CDOResource/loaded"/> + <genFeatures createChild="false" ecoreFeature="ecore:EAttribute eresource.ecore#//CDOResource/trackingModification"/> + <genFeatures createChild="false" ecoreFeature="ecore:EAttribute eresource.ecore#//CDOResource/errors"/> + <genFeatures createChild="false" ecoreFeature="ecore:EAttribute eresource.ecore#//CDOResource/warnings"/> + </genClasses> + </genPackages> +</genmodel:GenModel> diff --git a/plugins/org.eclipse.emf.cdo/plugin.properties b/plugins/org.eclipse.emf.cdo/plugin.properties new file mode 100644 index 0000000000..438583d6a7 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/plugin.properties @@ -0,0 +1,19 @@ +# <copyright> +# </copyright> +# +# $Id$ + +# ==================================================================== +# To code developer: +# Do NOT change the properties between this line and the +# "%%% END OF TRANSLATED PROPERTIES %%%" line. +# Make a new property name, append to the end of the file and change +# the code to use the new property. +# ==================================================================== + +# ==================================================================== +# %%% END OF TRANSLATED PROPERTIES %%% +# ==================================================================== + +pluginName = CDO +providerName = Eclipse.org diff --git a/plugins/org.eclipse.emf.cdo/plugin.xml b/plugins/org.eclipse.emf.cdo/plugin.xml new file mode 100644 index 0000000000..a26c6c4a2f --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/plugin.xml @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.0"?> + +<plugin> + + <extension + point="org.eclipse.net4j.factories"> + <factory + class="org.eclipse.emf.internal.cdo.protocol.CDOClientProtocolFactory" + productGroup="org.eclipse.net4j.clientProtocols" + type="cdo"/> + <factory + class="org.eclipse.emf.internal.cdo.CDOSessionFactory" + productGroup="org.eclipse.emf.cdo.sessions" + type="cdo"/> + </extension> + + <extension + point="org.eclipse.net4j.elementProcessors"> + <elementProcessor + class="org.eclipse.emf.internal.cdo.ChannelInjector"> + </elementProcessor> + </extension> + + <extension + point="org.eclipse.emf.ecore.generated_package"> + <package + uri="http://www.eclipse.org/emf/CDO/Eresource/1.0.0" + class="org.eclipse.emf.cdo.eresource.EresourcePackage" + genModel="model/resource.genmodel" /> + </extension> + +</plugin> diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOConstants.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOConstants.java new file mode 100644 index 0000000000..48d5b65f8a --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOConstants.java @@ -0,0 +1,21 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.cdo; + +import org.eclipse.emf.cdo.protocol.CDOProtocolConstants; + +/** + * @author Eike Stepper + */ +public interface CDOConstants +{ + public static final String TYPE = CDOProtocolConstants.PROTOCOL_NAME + "client"; +} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOObject.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOObject.java new file mode 100644 index 0000000000..d5debd01f2 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOObject.java @@ -0,0 +1,38 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.cdo; + +import org.eclipse.emf.cdo.eresource.CDOResource; +import org.eclipse.emf.cdo.protocol.CDOID; +import org.eclipse.emf.cdo.protocol.model.CDOClass; +import org.eclipse.emf.cdo.protocol.revision.CDORevision; + +import org.eclipse.emf.ecore.EObject; + +/** + * @author Eike Stepper + */ +public interface CDOObject extends EObject +{ + public CDOClass cdoClass(); + + public CDOID cdoID(); + + public CDOState cdoState(); + + public CDOAdapter cdoAdapter(); + + public CDOResource cdoResource(); + + public CDORevision cdoRevision(); + + public boolean cdoTransient(); +} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDORevisionManager.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDORevisionManager.java new file mode 100644 index 0000000000..5552f939c6 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDORevisionManager.java @@ -0,0 +1,21 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.cdo; + +import org.eclipse.emf.cdo.protocol.revision.CDORevisionResolver; + +/** + * @author Eike Stepper + */ +public interface CDORevisionManager extends CDORevisionResolver +{ + public CDOSession getSession(); +} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOSession.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOSession.java new file mode 100644 index 0000000000..82788edd27 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOSession.java @@ -0,0 +1,44 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.cdo; + +import org.eclipse.net4j.IChannel; +import org.eclipse.net4j.util.container.IContainer; + +import org.eclipse.emf.ecore.resource.ResourceSet; + +/** + * @author Eike Stepper + */ +public interface CDOSession extends IContainer<CDOAdapter> +{ + public int getSessionID(); + + public IChannel getChannel(); + + public boolean isOpen(); + + public void close(); + + public String getRepositoryName(); + + public String getRepositoryUUID(); + + public CDORevisionManager getRevisionManager(); + + public CDOAdapter attach(ResourceSet resourceSet, long timeStamp); + + public CDOAdapter attach(ResourceSet resourceSet, boolean readOnly); + + public CDOAdapter attach(ResourceSet resourceSet); + + public CDOAdapter[] getAdapters(); +} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOSessionAdaptersEvent.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOSessionAdaptersEvent.java new file mode 100644 index 0000000000..665acc7e15 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOSessionAdaptersEvent.java @@ -0,0 +1,23 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.cdo; + +import org.eclipse.net4j.util.container.IContainerEvent; + +/** + * @author Eike Stepper + */ +public interface CDOSessionAdaptersEvent extends IContainerEvent<CDOAdapter> +{ + public CDOSession getSession(); + + public CDOAdapter getAdapter(); +} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOState.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOState.java new file mode 100644 index 0000000000..be2128669f --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOState.java @@ -0,0 +1,9 @@ +package org.eclipse.emf.cdo; + +/** + * @author Eike Stepper + */ +public enum CDOState +{ + TRANSIENT, NEW, CLEAN, DIRTY, PROXY, CONFLICT, PREPARED_ATTACH +}
\ No newline at end of file diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOTransaction.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOTransaction.java new file mode 100644 index 0000000000..76634cda8c --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOTransaction.java @@ -0,0 +1,23 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.cdo; + +/** + * @author Eike Stepper + */ +public interface CDOTransaction +{ + public CDOAdapter getAdapter(); + + public void commit(); + + public void rollback(); +} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java new file mode 100644 index 0000000000..7bd0bba4b8 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java @@ -0,0 +1,32 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.cdo; + +import org.eclipse.emf.cdo.protocol.CDOID; +import org.eclipse.emf.cdo.protocol.revision.CDORevision; + +/** + * @author Eike Stepper + */ +public interface CDOView +{ + public static final long UNSPECIFIED_DATE = CDORevision.UNSPECIFIED_DATE; + + public CDOAdapter getAdapter(); + + public boolean isActual(); + + public boolean isHistorical(); + + public long getTimeStamp(); + + public CDORevision resolve(CDOID id); +} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/CDOResource.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/CDOResource.java new file mode 100644 index 0000000000..4b1907f162 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/CDOResource.java @@ -0,0 +1,272 @@ +/** + * <copyright> + * </copyright> + * + * $Id$ + */ +package org.eclipse.emf.cdo.eresource; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.ResourceSet; + +/** + * <!-- begin-user-doc --> A representation of the model object '<em><b>CDO Resource</b></em>'. + * <!-- end-user-doc --> + * <p> + * The following features are supported: + * <ul> + * <li>{@link org.eclipse.emf.cdo.eresource.CDOResource#getResourceSet <em>Resource Set</em>}</li> + * <li>{@link org.eclipse.emf.cdo.eresource.CDOResource#getURI <em>URI</em>}</li> + * <li>{@link org.eclipse.emf.cdo.eresource.CDOResource#getContents <em>Contents</em>}</li> + * <li>{@link org.eclipse.emf.cdo.eresource.CDOResource#isModified <em>Modified</em>}</li> + * <li>{@link org.eclipse.emf.cdo.eresource.CDOResource#isLoaded <em>Loaded</em>}</li> + * <li>{@link org.eclipse.emf.cdo.eresource.CDOResource#isTrackingModification <em>Tracking Modification</em>}</li> + * <li>{@link org.eclipse.emf.cdo.eresource.CDOResource#getErrors <em>Errors</em>}</li> + * <li>{@link org.eclipse.emf.cdo.eresource.CDOResource#getWarnings <em>Warnings</em>}</li> + * <li>{@link org.eclipse.emf.cdo.eresource.CDOResource#getPath <em>Path</em>}</li> + * </ul> + * </p> + * + * @see org.eclipse.emf.cdo.eresource.EresourcePackage#getCDOResource() + * @model + * @extends EresourceObject + * @generated + */ +public interface CDOResource extends EresourceObject +{ + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + String copyright = ""; + + /** + * Returns the value of the '<em><b>Resource Set</b></em>' attribute. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Resource Set</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * + * @return the value of the '<em>Resource Set</em>' attribute. + * @see #setResourceSet(ResourceSet) + * @see org.eclipse.emf.cdo.eresource.EresourcePackage#getCDOResource_ResourceSet() + * @model dataType="org.eclipse.emf.cdo.eresource.ResourceSet" + * transient="true" + * @generated + */ + ResourceSet getResourceSet(); + + /** + * Sets the value of the '{@link org.eclipse.emf.cdo.eresource.CDOResource#getResourceSet <em>Resource Set</em>}' + * attribute. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @param value + * the new value of the '<em>Resource Set</em>' attribute. + * @see #getResourceSet() + * @generated + */ + void setResourceSet(ResourceSet value); + + /** + * Returns the value of the '<em><b>URI</b></em>' attribute. <!-- + * begin-user-doc --> + * <p> + * If the meaning of the '<em>URI</em>' attribute isn't clear, there + * really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * + * @return the value of the '<em>URI</em>' attribute. + * @see #setURI(URI) + * @see org.eclipse.emf.cdo.eresource.EresourcePackage#getCDOResource_URI() + * @model dataType="org.eclipse.emf.cdo.eresource.URI" transient="true" + * @generated + */ + URI getURI(); + + /** + * Sets the value of the '{@link org.eclipse.emf.cdo.eresource.CDOResource#getURI <em>URI</em>}' + * attribute. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @param value + * the new value of the '<em>URI</em>' attribute. + * @see #getURI() + * @generated + */ + void setURI(URI value); + + /** + * Returns the value of the '<em><b>Contents</b></em>' containment + * reference list. The list contents are of type + * {@link org.eclipse.emf.ecore.EObject}. <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Contents</em>' containment reference list + * isn't clear, there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * + * @return the value of the '<em>Contents</em>' containment reference + * list. + * @see org.eclipse.emf.cdo.eresource.EresourcePackage#getCDOResource_Contents() + * @model type="org.eclipse.emf.ecore.EObject" containment="true" + * @generated + */ + EList<EObject> getContents(); + + /** + * Returns the value of the '<em><b>Modified</b></em>' attribute. <!-- + * begin-user-doc --> + * <p> + * If the meaning of the '<em>Modified</em>' attribute isn't clear, there + * really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * + * @return the value of the '<em>Modified</em>' attribute. + * @see #setModified(boolean) + * @see org.eclipse.emf.cdo.eresource.EresourcePackage#getCDOResource_Modified() + * @model transient="true" + * @generated + */ + boolean isModified(); + + /** + * Sets the value of the '{@link org.eclipse.emf.cdo.eresource.CDOResource#isModified <em>Modified</em>}' + * attribute. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @param value + * the new value of the '<em>Modified</em>' attribute. + * @see #isModified() + * @generated + */ + void setModified(boolean value); + + /** + * Returns the value of the '<em><b>Loaded</b></em>' attribute. <!-- + * begin-user-doc --> + * <p> + * If the meaning of the '<em>Loaded</em>' attribute isn't clear, there + * really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * + * @return the value of the '<em>Loaded</em>' attribute. + * @see #setLoaded(boolean) + * @see org.eclipse.emf.cdo.eresource.EresourcePackage#getCDOResource_Loaded() + * @model transient="true" + * @generated + */ + boolean isLoaded(); + + /** + * Sets the value of the '{@link org.eclipse.emf.cdo.eresource.CDOResource#isLoaded <em>Loaded</em>}' + * attribute. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @param value + * the new value of the '<em>Loaded</em>' attribute. + * @see #isLoaded() + * @generated + */ + void setLoaded(boolean value); + + /** + * Returns the value of the '<em><b>Tracking Modification</b></em>' + * attribute. <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Tracking Modification</em>' attribute isn't + * clear, there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * + * @return the value of the '<em>Tracking Modification</em>' attribute. + * @see #setTrackingModification(boolean) + * @see org.eclipse.emf.cdo.eresource.EresourcePackage#getCDOResource_TrackingModification() + * @model transient="true" + * @generated + */ + boolean isTrackingModification(); + + /** + * Sets the value of the '{@link org.eclipse.emf.cdo.eresource.CDOResource#isTrackingModification <em>Tracking Modification</em>}' + * attribute. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @param value + * the new value of the '<em>Tracking Modification</em>' + * attribute. + * @see #isTrackingModification() + * @generated + */ + void setTrackingModification(boolean value); + + /** + * Returns the value of the '<em><b>Errors</b></em>' attribute list. The + * list contents are of type + * {@link org.eclipse.emf.ecore.resource.Resource.Diagnostic}. <!-- + * begin-user-doc --> + * <p> + * If the meaning of the '<em>Errors</em>' attribute list isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * + * @return the value of the '<em>Errors</em>' attribute list. + * @see org.eclipse.emf.cdo.eresource.EresourcePackage#getCDOResource_Errors() + * @model type="org.eclipse.emf.ecore.resource.Resource.Diagnostic" + * dataType="org.eclipse.emf.cdo.eresource.Diagnostic" transient="true" + * @generated + */ + EList<Diagnostic> getErrors(); + + /** + * Returns the value of the '<em><b>Warnings</b></em>' attribute list. + * The list contents are of type + * {@link org.eclipse.emf.ecore.resource.Resource.Diagnostic}. <!-- + * begin-user-doc --> + * <p> + * If the meaning of the '<em>Warnings</em>' attribute list isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * + * @return the value of the '<em>Warnings</em>' attribute list. + * @see org.eclipse.emf.cdo.eresource.EresourcePackage#getCDOResource_Warnings() + * @model type="org.eclipse.emf.ecore.resource.Resource.Diagnostic" + * dataType="org.eclipse.emf.cdo.eresource.Diagnostic" transient="true" + * @generated + */ + EList<Diagnostic> getWarnings(); + + /** + * Returns the value of the '<em><b>Path</b></em>' attribute. <!-- + * begin-user-doc --> + * <p> + * If the meaning of the '<em>Path</em>' attribute isn't clear, there + * really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * + * @return the value of the '<em>Path</em>' attribute. + * @see #setPath(String) + * @see org.eclipse.emf.cdo.eresource.EresourcePackage#getCDOResource_Path() + * @model + * @generated + */ + String getPath(); + + /** + * Sets the value of the '{@link org.eclipse.emf.cdo.eresource.CDOResource#getPath <em>Path</em>}' + * attribute. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @param value + * the new value of the '<em>Path</em>' attribute. + * @see #getPath() + * @generated + */ + void setPath(String value); + +} // CDOResource diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/CDOResourceFactory.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/CDOResourceFactory.java new file mode 100644 index 0000000000..cbf4dfa4c2 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/CDOResourceFactory.java @@ -0,0 +1,23 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.cdo.eresource; + +import org.eclipse.emf.cdo.eresource.impl.CDOResourceFactoryImpl; + +import org.eclipse.emf.ecore.resource.Resource; + +/** + * @author Eike Stepper + */ +public interface CDOResourceFactory extends Resource.Factory +{ + public static final CDOResourceFactory INSTANCE = CDOResourceFactoryImpl.INSTANCE; +}
\ No newline at end of file diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/EresourceFactory.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/EresourceFactory.java new file mode 100644 index 0000000000..1b9fa81afc --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/EresourceFactory.java @@ -0,0 +1,53 @@ +/** + * <copyright> + * </copyright> + * + * $Id$ + */ +package org.eclipse.emf.cdo.eresource; + +import org.eclipse.emf.ecore.EFactory; + +/** + * <!-- begin-user-doc --> The <b>Factory</b> for the model. It provides a + * create method for each non-abstract class of the model. <!-- end-user-doc --> + * + * @see org.eclipse.emf.cdo.eresource.EresourcePackage + * @generated + */ +public interface EresourceFactory extends EFactory +{ + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + String copyright = ""; + + /** + * The singleton instance of the factory. <!-- begin-user-doc --> <!-- + * end-user-doc --> + * + * @generated + */ + EresourceFactory eINSTANCE = org.eclipse.emf.cdo.eresource.impl.EresourceFactoryImpl.init(); + + /** + * Returns a new object of class '<em>CDO Resource</em>'. <!-- + * begin-user-doc --> <!-- end-user-doc --> + * + * @return a new object of class '<em>CDO Resource</em>'. + * @generated + */ + CDOResource createCDOResource(); + + /** + * Returns the package supported by this factory. <!-- begin-user-doc --> <!-- + * end-user-doc --> + * + * @return the package supported by this factory. + * @generated + */ + EresourcePackage getEresourcePackage(); + +} // EresourceFactory diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/EresourceObject.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/EresourceObject.java new file mode 100644 index 0000000000..d40b89f10d --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/EresourceObject.java @@ -0,0 +1,22 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.cdo.eresource; + +import org.eclipse.emf.cdo.CDOObject; + +import org.eclipse.emf.ecore.resource.Resource; + +/** + * @author Eike Stepper + */ +public interface EresourceObject extends CDOObject, Resource.Internal +{ +} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/EresourcePackage.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/EresourcePackage.java new file mode 100644 index 0000000000..dd08c03198 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/EresourcePackage.java @@ -0,0 +1,481 @@ +/** + * <copyright> + * </copyright> + * + * $Id$ + */ +package org.eclipse.emf.cdo.eresource; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; + +/** + * <!-- begin-user-doc --> The <b>Package</b> for the model. It contains + * accessors for the meta objects to represent + * <ul> + * <li>each class,</li> + * <li>each feature of each class,</li> + * <li>each enum,</li> + * <li>and each data type</li> + * </ul> + * <!-- end-user-doc --> + * + * @see org.eclipse.emf.cdo.eresource.EresourceFactory + * @model kind="package" + * @generated + */ +public interface EresourcePackage extends EPackage +{ + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + String copyright = ""; + + /** + * The package name. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + String eNAME = "eresource"; + + /** + * The package namespace URI. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + String eNS_URI = "http://www.eclipse.org/emf/CDO/resource/1.0.0"; + + /** + * The package namespace name. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + String eNS_PREFIX = "eresource"; + + /** + * The singleton instance of the package. <!-- begin-user-doc --> <!-- + * end-user-doc --> + * + * @generated + */ + EresourcePackage eINSTANCE = org.eclipse.emf.cdo.eresource.impl.EresourcePackageImpl.init(); + + /** + * The meta object id for the '{@link org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl <em>CDO Resource</em>}' + * class. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @see org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl + * @see org.eclipse.emf.cdo.eresource.impl.EresourcePackageImpl#getCDOResource() + * @generated + */ + int CDO_RESOURCE = 0; + + /** + * The feature id for the '<em><b>Resource Set</b></em>' attribute. <!-- + * begin-user-doc --> <!-- end-user-doc --> + * + * @generated + * @ordered + */ + int CDO_RESOURCE__RESOURCE_SET = 0; + + /** + * The feature id for the '<em><b>URI</b></em>' attribute. <!-- + * begin-user-doc --> <!-- end-user-doc --> + * + * @generated + * @ordered + */ + int CDO_RESOURCE__URI = 1; + + /** + * The feature id for the '<em><b>Contents</b></em>' containment + * reference list. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + * @ordered + */ + int CDO_RESOURCE__CONTENTS = 2; + + /** + * The feature id for the '<em><b>Modified</b></em>' attribute. <!-- + * begin-user-doc --> <!-- end-user-doc --> + * + * @generated + * @ordered + */ + int CDO_RESOURCE__MODIFIED = 3; + + /** + * The feature id for the '<em><b>Loaded</b></em>' attribute. <!-- + * begin-user-doc --> <!-- end-user-doc --> + * + * @generated + * @ordered + */ + int CDO_RESOURCE__LOADED = 4; + + /** + * The feature id for the '<em><b>Tracking Modification</b></em>' + * attribute. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + * @ordered + */ + int CDO_RESOURCE__TRACKING_MODIFICATION = 5; + + /** + * The feature id for the '<em><b>Errors</b></em>' attribute list. <!-- + * begin-user-doc --> <!-- end-user-doc --> + * + * @generated + * @ordered + */ + int CDO_RESOURCE__ERRORS = 6; + + /** + * The feature id for the '<em><b>Warnings</b></em>' attribute list. <!-- + * begin-user-doc --> <!-- end-user-doc --> + * + * @generated + * @ordered + */ + int CDO_RESOURCE__WARNINGS = 7; + + /** + * The feature id for the '<em><b>Path</b></em>' attribute. <!-- + * begin-user-doc --> <!-- end-user-doc --> + * + * @generated + * @ordered + */ + int CDO_RESOURCE__PATH = 8; + + /** + * The number of structural features of the '<em>CDO Resource</em>' class. + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + * @ordered + */ + int CDO_RESOURCE_FEATURE_COUNT = 9; + + /** + * The meta object id for the '<em>Resource Set</em>' data type. <!-- + * begin-user-doc --> <!-- end-user-doc --> + * + * @see org.eclipse.emf.ecore.resource.ResourceSet + * @see org.eclipse.emf.cdo.eresource.impl.EresourcePackageImpl#getResourceSet() + * @generated + */ + int RESOURCE_SET = 1; + + /** + * The meta object id for the '<em>URI</em>' data type. <!-- + * begin-user-doc --> <!-- end-user-doc --> + * + * @see org.eclipse.emf.common.util.URI + * @see org.eclipse.emf.cdo.eresource.impl.EresourcePackageImpl#getURI() + * @generated + */ + int URI = 2; + + /** + * The meta object id for the '<em>Diagnostic</em>' data type. <!-- + * begin-user-doc --> <!-- end-user-doc --> + * + * @see org.eclipse.emf.ecore.resource.Resource.Diagnostic + * @see org.eclipse.emf.cdo.eresource.impl.EresourcePackageImpl#getDiagnostic() + * @generated + */ + int DIAGNOSTIC = 3; + + /** + * Returns the meta object for class '{@link org.eclipse.emf.cdo.eresource.CDOResource <em>CDO Resource</em>}'. + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @return the meta object for class '<em>CDO Resource</em>'. + * @see org.eclipse.emf.cdo.eresource.CDOResource + * @generated + */ + EClass getCDOResource(); + + /** + * Returns the meta object for the attribute '{@link org.eclipse.emf.cdo.eresource.CDOResource#getResourceSet <em>Resource Set</em>}'. + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @return the meta object for the attribute '<em>Resource Set</em>'. + * @see org.eclipse.emf.cdo.eresource.CDOResource#getResourceSet() + * @see #getCDOResource() + * @generated + */ + EAttribute getCDOResource_ResourceSet(); + + /** + * Returns the meta object for the attribute '{@link org.eclipse.emf.cdo.eresource.CDOResource#getURI <em>URI</em>}'. + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @return the meta object for the attribute '<em>URI</em>'. + * @see org.eclipse.emf.cdo.eresource.CDOResource#getURI() + * @see #getCDOResource() + * @generated + */ + EAttribute getCDOResource_URI(); + + /** + * Returns the meta object for the containment reference list '{@link org.eclipse.emf.cdo.eresource.CDOResource#getContents <em>Contents</em>}'. + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @return the meta object for the containment reference list '<em>Contents</em>'. + * @see org.eclipse.emf.cdo.eresource.CDOResource#getContents() + * @see #getCDOResource() + * @generated + */ + EReference getCDOResource_Contents(); + + /** + * Returns the meta object for the attribute '{@link org.eclipse.emf.cdo.eresource.CDOResource#isModified <em>Modified</em>}'. + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @return the meta object for the attribute '<em>Modified</em>'. + * @see org.eclipse.emf.cdo.eresource.CDOResource#isModified() + * @see #getCDOResource() + * @generated + */ + EAttribute getCDOResource_Modified(); + + /** + * Returns the meta object for the attribute '{@link org.eclipse.emf.cdo.eresource.CDOResource#isLoaded <em>Loaded</em>}'. + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @return the meta object for the attribute '<em>Loaded</em>'. + * @see org.eclipse.emf.cdo.eresource.CDOResource#isLoaded() + * @see #getCDOResource() + * @generated + */ + EAttribute getCDOResource_Loaded(); + + /** + * Returns the meta object for the attribute '{@link org.eclipse.emf.cdo.eresource.CDOResource#isTrackingModification <em>Tracking Modification</em>}'. + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @return the meta object for the attribute '<em>Tracking Modification</em>'. + * @see org.eclipse.emf.cdo.eresource.CDOResource#isTrackingModification() + * @see #getCDOResource() + * @generated + */ + EAttribute getCDOResource_TrackingModification(); + + /** + * Returns the meta object for the attribute list '{@link org.eclipse.emf.cdo.eresource.CDOResource#getErrors <em>Errors</em>}'. + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @return the meta object for the attribute list '<em>Errors</em>'. + * @see org.eclipse.emf.cdo.eresource.CDOResource#getErrors() + * @see #getCDOResource() + * @generated + */ + EAttribute getCDOResource_Errors(); + + /** + * Returns the meta object for the attribute list '{@link org.eclipse.emf.cdo.eresource.CDOResource#getWarnings <em>Warnings</em>}'. + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @return the meta object for the attribute list '<em>Warnings</em>'. + * @see org.eclipse.emf.cdo.eresource.CDOResource#getWarnings() + * @see #getCDOResource() + * @generated + */ + EAttribute getCDOResource_Warnings(); + + /** + * Returns the meta object for the attribute '{@link org.eclipse.emf.cdo.eresource.CDOResource#getPath <em>Path</em>}'. + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @return the meta object for the attribute '<em>Path</em>'. + * @see org.eclipse.emf.cdo.eresource.CDOResource#getPath() + * @see #getCDOResource() + * @generated + */ + EAttribute getCDOResource_Path(); + + /** + * Returns the meta object for data type '{@link org.eclipse.emf.ecore.resource.ResourceSet <em>Resource Set</em>}'. + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @return the meta object for data type '<em>Resource Set</em>'. + * @see org.eclipse.emf.ecore.resource.ResourceSet + * @model instanceClass="org.eclipse.emf.ecore.resource.ResourceSet" + * serializable="false" + * @generated + */ + EDataType getResourceSet(); + + /** + * Returns the meta object for data type '{@link org.eclipse.emf.common.util.URI <em>URI</em>}'. + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @return the meta object for data type '<em>URI</em>'. + * @see org.eclipse.emf.common.util.URI + * @model instanceClass="org.eclipse.emf.common.util.URI" + * @generated + */ + EDataType getURI(); + + /** + * Returns the meta object for data type '{@link org.eclipse.emf.ecore.resource.Resource.Diagnostic <em>Diagnostic</em>}'. + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @return the meta object for data type '<em>Diagnostic</em>'. + * @see org.eclipse.emf.ecore.resource.Resource.Diagnostic + * @model instanceClass="org.eclipse.emf.ecore.resource.Resource.Diagnostic" + * serializable="false" + * @generated + */ + EDataType getDiagnostic(); + + /** + * Returns the factory that creates the instances of the model. <!-- + * begin-user-doc --> <!-- end-user-doc --> + * + * @return the factory that creates the instances of the model. + * @generated + */ + EresourceFactory getEresourceFactory(); + + /** + * <!-- begin-user-doc --> Defines literals for the meta objects that + * represent + * <ul> + * <li>each class,</li> + * <li>each feature of each class,</li> + * <li>each enum,</li> + * <li>and each data type</li> + * </ul> + * <!-- end-user-doc --> + * + * @generated + */ + interface Literals + { + /** + * The meta object literal for the '{@link org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl <em>CDO Resource</em>}' + * class. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @see org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl + * @see org.eclipse.emf.cdo.eresource.impl.EresourcePackageImpl#getCDOResource() + * @generated + */ + EClass CDO_RESOURCE = eINSTANCE.getCDOResource(); + + /** + * The meta object literal for the '<em><b>Resource Set</b></em>' + * attribute feature. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + EAttribute CDO_RESOURCE__RESOURCE_SET = eINSTANCE.getCDOResource_ResourceSet(); + + /** + * The meta object literal for the '<em><b>URI</b></em>' attribute + * feature. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + EAttribute CDO_RESOURCE__URI = eINSTANCE.getCDOResource_URI(); + + /** + * The meta object literal for the '<em><b>Contents</b></em>' + * containment reference list feature. <!-- begin-user-doc --> <!-- + * end-user-doc --> + * + * @generated + */ + EReference CDO_RESOURCE__CONTENTS = eINSTANCE.getCDOResource_Contents(); + + /** + * The meta object literal for the '<em><b>Modified</b></em>' attribute + * feature. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + EAttribute CDO_RESOURCE__MODIFIED = eINSTANCE.getCDOResource_Modified(); + + /** + * The meta object literal for the '<em><b>Loaded</b></em>' attribute + * feature. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + EAttribute CDO_RESOURCE__LOADED = eINSTANCE.getCDOResource_Loaded(); + + /** + * The meta object literal for the '<em><b>Tracking Modification</b></em>' + * attribute feature. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + EAttribute CDO_RESOURCE__TRACKING_MODIFICATION = eINSTANCE.getCDOResource_TrackingModification(); + + /** + * The meta object literal for the '<em><b>Errors</b></em>' attribute + * list feature. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + EAttribute CDO_RESOURCE__ERRORS = eINSTANCE.getCDOResource_Errors(); + + /** + * The meta object literal for the '<em><b>Warnings</b></em>' attribute + * list feature. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + EAttribute CDO_RESOURCE__WARNINGS = eINSTANCE.getCDOResource_Warnings(); + + /** + * The meta object literal for the '<em><b>Path</b></em>' attribute + * feature. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + EAttribute CDO_RESOURCE__PATH = eINSTANCE.getCDOResource_Path(); + + /** + * The meta object literal for the '<em>Resource Set</em>' data type. + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @see org.eclipse.emf.ecore.resource.ResourceSet + * @see org.eclipse.emf.cdo.eresource.impl.EresourcePackageImpl#getResourceSet() + * @generated + */ + EDataType RESOURCE_SET = eINSTANCE.getResourceSet(); + + /** + * The meta object literal for the '<em>URI</em>' data type. <!-- + * begin-user-doc --> <!-- end-user-doc --> + * + * @see org.eclipse.emf.common.util.URI + * @see org.eclipse.emf.cdo.eresource.impl.EresourcePackageImpl#getURI() + * @generated + */ + EDataType URI = eINSTANCE.getURI(); + + /** + * The meta object literal for the '<em>Diagnostic</em>' data type. <!-- + * begin-user-doc --> <!-- end-user-doc --> + * + * @see org.eclipse.emf.ecore.resource.Resource.Diagnostic + * @see org.eclipse.emf.cdo.eresource.impl.EresourcePackageImpl#getDiagnostic() + * @generated + */ + EDataType DIAGNOSTIC = eINSTANCE.getDiagnostic(); + + } + +} // EresourcePackage diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceFactoryImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceFactoryImpl.java new file mode 100644 index 0000000000..29db35d419 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceFactoryImpl.java @@ -0,0 +1,66 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.cdo.eresource.impl; + +import org.eclipse.emf.cdo.eresource.CDOResourceFactory; +import org.eclipse.emf.cdo.eresource.EresourceFactory; +import org.eclipse.emf.cdo.protocol.util.ImplementationError; + +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; + +/** + * @author Eike Stepper + */ +public class CDOResourceFactoryImpl implements Resource.Factory, CDOResourceFactory +{ + // @Singleton + public static final CDOResourceFactoryImpl INSTANCE = new CDOResourceFactoryImpl(); + + private static final String RESOURCE_SET_CLASS_NAME = ResourceSetImpl.class.getName(); + + public CDOResourceFactoryImpl() + { + } + + public Resource createResource(URI uri) + { + CDOResourceImpl resource = (CDOResourceImpl)EresourceFactory.eINSTANCE.createCDOResource(); + resource.setURI(uri); + resource.setExisting(isExistingResource()); + return resource; + } + + private boolean isExistingResource() + { + StackTraceElement[] elements = Thread.currentThread().getStackTrace(); + if (elements.length >= 6) + { + if (isResourceSetMethod(elements[6], "getResource")) + { + return true; + } + + if (isResourceSetMethod(elements[4], "createResource")) + { + return false; + } + } + + throw new ImplementationError("Call stack is in unexpected state"); + } + + private boolean isResourceSetMethod(StackTraceElement element, String methodName) + { + return methodName.equals(element.getMethodName()) && RESOURCE_SET_CLASS_NAME.equals(element.getClassName()); + } +} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java new file mode 100644 index 0000000000..04ee27763e --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java @@ -0,0 +1,654 @@ +/** + * <copyright> + * </copyright> + * + * $Id$ + */ +package org.eclipse.emf.cdo.eresource.impl; + +import org.eclipse.emf.cdo.CDOState; +import org.eclipse.emf.cdo.eresource.CDOResource; +import org.eclipse.emf.cdo.eresource.EresourcePackage; +import org.eclipse.emf.cdo.util.CDOUtil; + +import org.eclipse.net4j.util.om.trace.ContextTracer; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; +import org.eclipse.emf.common.notify.impl.NotificationChainImpl; +import org.eclipse.emf.common.notify.impl.NotificationImpl; +import org.eclipse.emf.common.notify.impl.NotifyingListImpl; +import org.eclipse.emf.common.util.AbstractTreeIterator; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.TreeIterator; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.InternalEObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.resource.impl.ResourceImpl; +import org.eclipse.emf.ecore.util.InternalEList; +import org.eclipse.emf.internal.cdo.CDOAdapterImpl; +import org.eclipse.emf.internal.cdo.CDOObjectImpl; +import org.eclipse.emf.internal.cdo.bundle.CDO; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.Map; + +/** + * <!-- begin-user-doc --> An implementation of the model object '<em><b>CDO Resource</b></em>'. + * <!-- end-user-doc --> + * <p> + * The following features are implemented: + * <ul> + * <li>{@link org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl#getResourceSet <em>Resource Set</em>}</li> + * <li>{@link org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl#getURI <em>URI</em>}</li> + * <li>{@link org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl#getContents <em>Contents</em>}</li> + * <li>{@link org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl#isModified <em>Modified</em>}</li> + * <li>{@link org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl#isLoaded <em>Loaded</em>}</li> + * <li>{@link org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl#isTrackingModification <em>Tracking Modification</em>}</li> + * <li>{@link org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl#getErrors <em>Errors</em>}</li> + * <li>{@link org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl#getWarnings <em>Warnings</em>}</li> + * <li>{@link org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl#getPath <em>Path</em>}</li> + * </ul> + * </p> + * + * @generated + */ +public class CDOResourceImpl extends CDOObjectImpl implements CDOResource +{ + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public static final String copyright = ""; + + /** + * @ADDED + */ + private static final ContextTracer TRACER = new ContextTracer(CDO.DEBUG_OBJECT, CDOResourceImpl.class); + + /** + * @ADDED + */ + private CDOAdapterImpl adapter; + + /** + * @ADDED + */ + private boolean existing; + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + protected CDOResourceImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + @Override + protected EClass eStaticClass() + { + return EresourcePackage.Literals.CDO_RESOURCE; + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public ResourceSet getResourceSet() + { + return (ResourceSet)eGet(EresourcePackage.Literals.CDO_RESOURCE__RESOURCE_SET, true); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public void setResourceSet(ResourceSet newResourceSet) + { + eSet(EresourcePackage.Literals.CDO_RESOURCE__RESOURCE_SET, newResourceSet); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public URI getURI() + { + return (URI)eGet(EresourcePackage.Literals.CDO_RESOURCE__URI, true); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated NOT + */ + public void setURI(URI newURI) + { + eSet(EresourcePackage.Literals.CDO_RESOURCE__URI, newURI); + basicSetPath(CDOUtil.extractPath(newURI)); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated NOT + */ + public EList<EObject> getContents() + { + if (cdoTransient()) + { + EList<EObject> transientContents = (EList<EObject>)eSettings[EresourcePackage.CDO_RESOURCE__CONTENTS]; + if (transientContents == null) + { + transientContents = new TransientContents(); + eSettings[EresourcePackage.CDO_RESOURCE__CONTENTS] = transientContents; + } + + return transientContents; + } + + return (EList<EObject>)eGet(EresourcePackage.Literals.CDO_RESOURCE__CONTENTS, true); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public boolean isModified() + { + return ((Boolean)eGet(EresourcePackage.Literals.CDO_RESOURCE__MODIFIED, true)).booleanValue(); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public void setModified(boolean newModified) + { + eSet(EresourcePackage.Literals.CDO_RESOURCE__MODIFIED, new Boolean(newModified)); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public boolean isLoaded() + { + return ((Boolean)eGet(EresourcePackage.Literals.CDO_RESOURCE__LOADED, true)).booleanValue(); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public void setLoaded(boolean newLoaded) + { + eSet(EresourcePackage.Literals.CDO_RESOURCE__LOADED, new Boolean(newLoaded)); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public boolean isTrackingModification() + { + return ((Boolean)eGet(EresourcePackage.Literals.CDO_RESOURCE__TRACKING_MODIFICATION, true)).booleanValue(); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public void setTrackingModification(boolean newTrackingModification) + { + eSet(EresourcePackage.Literals.CDO_RESOURCE__TRACKING_MODIFICATION, new Boolean(newTrackingModification)); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public EList<Diagnostic> getErrors() + { + return (EList<Diagnostic>)eGet(EresourcePackage.Literals.CDO_RESOURCE__ERRORS, true); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public EList<Diagnostic> getWarnings() + { + return (EList<Diagnostic>)eGet(EresourcePackage.Literals.CDO_RESOURCE__WARNINGS, true); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public String getPath() + { + return (String)eGet(EresourcePackage.Literals.CDO_RESOURCE__PATH, true); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated NOT + */ + public void setPath(String newPath) + { + setURI(CDOUtil.createURI(newPath)); + } + + /** + * @ADDED + * @see ResourceImpl#getAllContents() + */ + public TreeIterator<EObject> getAllContents() + { + return new AbstractTreeIterator<EObject>(this, false) + { + private static final long serialVersionUID = 1L; + + @Override + public Iterator<EObject> getChildren(Object object) + { + return object == CDOResourceImpl.this ? CDOResourceImpl.this.getContents().iterator() : ((EObject)object) + .eContents().iterator(); + } + }; + } + + /** + * @ADDED + */ + public EObject getEObject(String uriFragment) + { + // TODO Implement method CDOResourceImpl.getEObject() + throw new UnsupportedOperationException("Not yet implemented"); + } + + /** + * @ADDED + */ + public String getURIFragment(EObject object) + { + // TODO Implement method CDOResourceImpl.getURIFragment() + throw new UnsupportedOperationException("Not yet implemented"); + } + + /** + * @ADDED + */ + public void load(InputStream inputStream, Map<?, ?> options) throws IOException + { + // Do nothing + } + + /** + * @ADDED + */ + public void load(Map<?, ?> options) throws IOException + { + // Do nothing + } + + /** + * @ADDED + */ + public void save(Map<?, ?> options) throws IOException + { + // Do nothing + } + + /** + * @ADDED + */ + public void save(OutputStream outputStream, Map<?, ?> options) throws IOException + { + // Do nothing + } + + /** + * @ADDED + */ + public void unload() + { + // Do nothing + } + + /** + * @ADDED + */ + public void attached(EObject object) + { + throw new UnsupportedOperationException(); + } + + /** + * @ADDED + */ + public void detached(EObject object) + { + throw new UnsupportedOperationException(); + } + + /** + * @ADDED + * @see ResourceImpl#basicSetResourceSet(ResourceSet, NotificationChain) + */ + public NotificationChain basicSetResourceSet(ResourceSet resourceSet, NotificationChain notifications) + { + ResourceSet oldResourceSet = getResourceSet(); + if (oldResourceSet != null) + { + notifications = ((InternalEList<Resource>)oldResourceSet.getResources()).basicRemove(this, notifications); + } + + setResourceSet(resourceSet); + + if (eNotificationRequired()) + { + if (notifications == null) + { + notifications = new NotificationChainImpl(2); + } + notifications.add(new NotificationImpl(Notification.SET, oldResourceSet, resourceSet) + { + @Override + public Object getNotifier() + { + return CDOResourceImpl.this; + } + + @Override + public int getFeatureID(Class<?> expectedClass) + { + return RESOURCE__RESOURCE_SET; + } + }); + } + + return notifications; + } + + /** + * @ADDED + */ + public boolean isLoading() + { + // TODO Implement method CDOResourceImpl.isLoading() + throw new UnsupportedOperationException("Not yet implemented"); + } + + /** + * @ADDED + */ + @Override + public CDOState cdoState() + { + if (isExisting() && super.cdoState() == CDOState.TRANSIENT) + { + return CDOState.PROXY; + } + + return super.cdoState(); + } + + /** + * @ADDED + */ + @Override + public CDOAdapterImpl cdoAdapter() + { + return adapter; + } + + /** + * @ADDED + */ + public void cdoSetAdapter(CDOAdapterImpl adapter) + { + if (TRACER.isEnabled()) + { + TRACER.format("Setting adpter: {0}", adapter); + } + + this.adapter = adapter; + } + + /** + * @ADDED + */ + public boolean isExisting() + { + return existing; + } + + /** + * @ADDED + */ + void setExisting(boolean existing) + { + this.existing = existing; + } + + /** + * @ADDED + */ + private void basicSetPath(String newPath) + { + eSet(EresourcePackage.Literals.CDO_RESOURCE__PATH, newPath); + } + + /** + * @ADDED + * @author Eike Stepper + */ + protected class TransientContents<E extends Object & EObject> extends NotifyingListImpl<E> implements + InternalEList<E> + { + private static final long serialVersionUID = 1L; + + @Override + public Object getNotifier() + { + return CDOResourceImpl.this; + } + + @Override + public int getFeatureID() + { + return EresourcePackage.CDO_RESOURCE__CONTENTS; + } + + @Override + protected boolean isNotificationRequired() + { + return CDOResourceImpl.this.eNotificationRequired(); + } + + @Override + protected boolean useEquals() + { + return false; + } + + @Override + protected boolean hasInverse() + { + return true; + } + + @Override + protected boolean isUnique() + { + return true; + } + + @Override + public NotificationChain inverseAdd(E object, NotificationChain notifications) + { + InternalEObject eObject = (InternalEObject)object; + notifications = eObject.eSetResource(CDOResourceImpl.this, notifications); + // CDOResourceImpl.this.attached(eObject); + return notifications; + } + + @Override + public NotificationChain inverseRemove(E object, NotificationChain notifications) + { + InternalEObject eObject = (InternalEObject)object; + // CDOResourceImpl.this.detached(eObject); + return eObject.eSetResource(null, notifications); + } + + @Override + public Iterator<E> basicIterator() + { + return super.basicIterator(); + } + + @Override + public ListIterator<E> basicListIterator() + { + return super.basicListIterator(); + } + + @Override + public ListIterator<E> basicListIterator(int index) + { + return super.basicListIterator(index); + } + + @Override + public List<E> basicList() + { + return super.basicList(); + } + + @Override + protected Object[] newData(int capacity) + { + return new EObject[capacity]; + } + + @Override + protected void didAdd(int index, E object) + { + super.didAdd(index, object); + // if (index == size - 1) + // { + // loaded(); + // } + modified(); + } + + @Override + protected void didRemove(int index, E object) + { + super.didRemove(index, object); + modified(); + } + + @Override + protected void didSet(int index, E newObject, E oldObject) + { + super.didSet(index, newObject, oldObject); + modified(); + } + + @Override + protected void didClear(int oldSize, Object[] oldData) + { + // if (oldSize == 0) + // { + // loaded(); + // } + // else + { + super.didClear(oldSize, oldData); + } + } + + // protected void loaded() + // { + // if (!CDOResourceImpl.this.isLoaded()) + // { + // Notification notification = CDOResourceImpl.this.setLoaded(true); + // if (notification != null) + // { + // CDOResourceImpl.this.eNotify(notification); + // } + // } + // } + + protected void modified() + { + if (isTrackingModification()) + { + setModified(true); + } + } + } + + // /** + // * @ADDED + // * @author Eike Stepper + // */ + // private final class PersistentContents extends EStoreEList<EObject> + // { + // private static final long serialVersionUID = 1L; + // + // public PersistentContents() + // { + // super(CDOResourceImpl.this, + // EresourcePackage.eINSTANCE.getCDOResource_Contents(), eStore()); + // } + // + // @Override + // public NotificationChain inverseAdd(EObject object, NotificationChain + // notifications) + // { + // InternalEObject eObject = (InternalEObject)object; + // return eObject.eSetResource(CDOResourceImpl.this, notifications); + // } + // + // @Override + // public NotificationChain inverseRemove(EObject object, NotificationChain + // notifications) + // { + // InternalEObject eObject = (InternalEObject)object; + // return eObject.eSetResource(null, notifications); + // } + // } +} // CDOResourceImpl diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/EresourceFactoryImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/EresourceFactoryImpl.java new file mode 100644 index 0000000000..ad15b6088b --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/EresourceFactoryImpl.java @@ -0,0 +1,175 @@ +/** + * <copyright> + * </copyright> + * + * $Id$ + */ +package org.eclipse.emf.cdo.eresource.impl; + +import org.eclipse.emf.cdo.eresource.CDOResource; +import org.eclipse.emf.cdo.eresource.EresourceFactory; +import org.eclipse.emf.cdo.eresource.EresourcePackage; + +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.impl.EFactoryImpl; +import org.eclipse.emf.ecore.plugin.EcorePlugin; + +/** + * <!-- begin-user-doc --> An implementation of the model <b>Factory</b>. <!-- + * end-user-doc --> + * + * @generated + */ +public class EresourceFactoryImpl extends EFactoryImpl implements EresourceFactory +{ + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public static final String copyright = ""; + + /** + * Creates the default factory implementation. <!-- begin-user-doc --> <!-- + * end-user-doc --> + * + * @generated + */ + public static EresourceFactory init() + { + try + { + EresourceFactory theEresourceFactory = (EresourceFactory)EPackage.Registry.INSTANCE + .getEFactory("http://www.eclipse.org/emf/CDO/resource/1.0.0"); + if (theEresourceFactory != null) + { + return theEresourceFactory; + } + } + catch (Exception exception) + { + EcorePlugin.INSTANCE.log(exception); + } + return new EresourceFactoryImpl(); + } + + /** + * Creates an instance of the factory. <!-- begin-user-doc --> <!-- + * end-user-doc --> + * + * @generated + */ + public EresourceFactoryImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated NOT + */ + @Override + public EObject create(EClass eClass) + { + switch (eClass.getClassifierID()) + { + case EresourcePackage.CDO_RESOURCE: + return createCDOResource(); + default: + throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); + } + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + @Override + public Object createFromString(EDataType eDataType, String initialValue) + { + switch (eDataType.getClassifierID()) + { + case EresourcePackage.URI: + return createURIFromString(eDataType, initialValue); + default: + throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier"); + } + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + @Override + public String convertToString(EDataType eDataType, Object instanceValue) + { + switch (eDataType.getClassifierID()) + { + case EresourcePackage.URI: + return convertURIToString(eDataType, instanceValue); + default: + throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier"); + } + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public CDOResource createCDOResource() + { + CDOResourceImpl cdoResource = new CDOResourceImpl(); + return cdoResource; + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated NOT + */ + public URI createURIFromString(EDataType eDataType, String initialValue) + { + return URI.createURI(initialValue); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated NOT + */ + public String convertURIToString(EDataType eDataType, Object instanceValue) + { + return instanceValue.toString(); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public EresourcePackage getEresourcePackage() + { + return (EresourcePackage)getEPackage(); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @deprecated + * @generated + */ + @Deprecated + public static EresourcePackage getPackage() + { + return EresourcePackage.eINSTANCE; + } + +} // EresourceFactoryImpl diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/EresourcePackageImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/EresourcePackageImpl.java new file mode 100644 index 0000000000..d911145a52 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/EresourcePackageImpl.java @@ -0,0 +1,388 @@ +/** + * <copyright> + * </copyright> + * + * $Id$ + */ +package org.eclipse.emf.cdo.eresource.impl; + +import org.eclipse.emf.cdo.eresource.CDOResource; +import org.eclipse.emf.cdo.eresource.EresourceFactory; +import org.eclipse.emf.cdo.eresource.EresourcePackage; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.EcorePackage; +import org.eclipse.emf.ecore.impl.EPackageImpl; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.resource.Resource.Diagnostic; + +/** + * <!-- begin-user-doc --> An implementation of the model <b>Package</b>. <!-- + * end-user-doc --> + * + * @generated + */ +public class EresourcePackageImpl extends EPackageImpl implements EresourcePackage +{ + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public static final String copyright = ""; + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + private EClass cdoResourceEClass = null; + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + private EDataType resourceSetEDataType = null; + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + private EDataType uriEDataType = null; + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + private EDataType diagnosticEDataType = null; + + /** + * Creates an instance of the model <b>Package</b>, registered with + * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the + * package package URI value. + * <p> + * Note: the correct way to create the package is via the static factory + * method {@link #init init()}, which also performs initialization of the + * package, or returns the registered package, if one already exists. <!-- + * begin-user-doc --> <!-- end-user-doc --> + * + * @see org.eclipse.emf.ecore.EPackage.Registry + * @see org.eclipse.emf.cdo.eresource.EresourcePackage#eNS_URI + * @see #init() + * @generated + */ + private EresourcePackageImpl() + { + super(eNS_URI, EresourceFactory.eINSTANCE); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + private static boolean isInited = false; + + /** + * Creates, registers, and initializes the <b>Package</b> for this model, and + * for any others upon which it depends. Simple dependencies are satisfied by + * calling this method on all dependent packages before doing anything else. + * This method drives initialization for interdependent packages directly, in + * parallel with this package, itself. + * <p> + * Of this package and its interdependencies, all packages which have not yet + * been registered by their URI values are first created and registered. The + * packages are then initialized in two steps: meta-model objects for all of + * the packages are created before any are initialized, since one package's + * meta-model objects may refer to those of another. + * <p> + * Invocation of this method will not affect any packages that have already + * been initialized. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @see #eNS_URI + * @see #createPackageContents() + * @see #initializePackageContents() + * @generated + */ + public static EresourcePackage init() + { + if (isInited) + return (EresourcePackage)EPackage.Registry.INSTANCE.getEPackage(EresourcePackage.eNS_URI); + + // Obtain or create and register package + EresourcePackageImpl theEresourcePackage = (EresourcePackageImpl)(EPackage.Registry.INSTANCE.getEPackage(eNS_URI) instanceof EresourcePackageImpl ? EPackage.Registry.INSTANCE + .getEPackage(eNS_URI) + : new EresourcePackageImpl()); + + isInited = true; + + // Initialize simple dependencies + EcorePackage.eINSTANCE.eClass(); + + // Create package meta-data objects + theEresourcePackage.createPackageContents(); + + // Initialize created meta-data + theEresourcePackage.initializePackageContents(); + + // Mark meta-data to indicate it can't be changed + theEresourcePackage.freeze(); + + return theEresourcePackage; + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public EClass getCDOResource() + { + return cdoResourceEClass; + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public EAttribute getCDOResource_ResourceSet() + { + return (EAttribute)cdoResourceEClass.getEStructuralFeatures().get(0); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public EAttribute getCDOResource_URI() + { + return (EAttribute)cdoResourceEClass.getEStructuralFeatures().get(1); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public EReference getCDOResource_Contents() + { + return (EReference)cdoResourceEClass.getEStructuralFeatures().get(2); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public EAttribute getCDOResource_Modified() + { + return (EAttribute)cdoResourceEClass.getEStructuralFeatures().get(3); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public EAttribute getCDOResource_Loaded() + { + return (EAttribute)cdoResourceEClass.getEStructuralFeatures().get(4); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public EAttribute getCDOResource_TrackingModification() + { + return (EAttribute)cdoResourceEClass.getEStructuralFeatures().get(5); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public EAttribute getCDOResource_Errors() + { + return (EAttribute)cdoResourceEClass.getEStructuralFeatures().get(6); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public EAttribute getCDOResource_Warnings() + { + return (EAttribute)cdoResourceEClass.getEStructuralFeatures().get(7); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public EAttribute getCDOResource_Path() + { + return (EAttribute)cdoResourceEClass.getEStructuralFeatures().get(8); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public EDataType getResourceSet() + { + return resourceSetEDataType; + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public EDataType getURI() + { + return uriEDataType; + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public EDataType getDiagnostic() + { + return diagnosticEDataType; + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public EresourceFactory getEresourceFactory() + { + return (EresourceFactory)getEFactoryInstance(); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + private boolean isCreated = false; + + /** + * Creates the meta-model objects for the package. This method is guarded to + * have no affect on any invocation but its first. <!-- begin-user-doc --> + * <!-- end-user-doc --> + * + * @generated + */ + public void createPackageContents() + { + if (isCreated) + return; + isCreated = true; + + // Create classes and their features + cdoResourceEClass = createEClass(CDO_RESOURCE); + createEAttribute(cdoResourceEClass, CDO_RESOURCE__RESOURCE_SET); + createEAttribute(cdoResourceEClass, CDO_RESOURCE__URI); + createEReference(cdoResourceEClass, CDO_RESOURCE__CONTENTS); + createEAttribute(cdoResourceEClass, CDO_RESOURCE__MODIFIED); + createEAttribute(cdoResourceEClass, CDO_RESOURCE__LOADED); + createEAttribute(cdoResourceEClass, CDO_RESOURCE__TRACKING_MODIFICATION); + createEAttribute(cdoResourceEClass, CDO_RESOURCE__ERRORS); + createEAttribute(cdoResourceEClass, CDO_RESOURCE__WARNINGS); + createEAttribute(cdoResourceEClass, CDO_RESOURCE__PATH); + + // Create data types + resourceSetEDataType = createEDataType(RESOURCE_SET); + uriEDataType = createEDataType(URI); + diagnosticEDataType = createEDataType(DIAGNOSTIC); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + private boolean isInitialized = false; + + /** + * Complete the initialization of the package and its meta-model. This method + * is guarded to have no affect on any invocation but its first. <!-- + * begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public void initializePackageContents() + { + if (isInitialized) + return; + isInitialized = true; + + // Initialize package + setName(eNAME); + setNsPrefix(eNS_PREFIX); + setNsURI(eNS_URI); + + // Obtain other dependent packages + EcorePackage theEcorePackage = (EcorePackage)EPackage.Registry.INSTANCE.getEPackage(EcorePackage.eNS_URI); + + // Create type parameters + + // Set bounds for type parameters + + // Add supertypes to classes + + // Initialize classes and features; add operations and parameters + initEClass(cdoResourceEClass, CDOResource.class, "CDOResource", !IS_ABSTRACT, !IS_INTERFACE, + IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getCDOResource_ResourceSet(), this.getResourceSet(), "resourceSet", null, 0, 1, CDOResource.class, + IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getCDOResource_URI(), this.getURI(), "uRI", null, 0, 1, CDOResource.class, IS_TRANSIENT, + !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getCDOResource_Contents(), theEcorePackage.getEObject(), null, "contents", null, 0, -1, + CDOResource.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, + !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getCDOResource_Modified(), ecorePackage.getEBoolean(), "modified", null, 0, 1, CDOResource.class, + IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getCDOResource_Loaded(), ecorePackage.getEBoolean(), "loaded", null, 0, 1, CDOResource.class, + IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getCDOResource_TrackingModification(), ecorePackage.getEBoolean(), "trackingModification", null, 0, + 1, CDOResource.class, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, + !IS_DERIVED, IS_ORDERED); + initEAttribute(getCDOResource_Errors(), this.getDiagnostic(), "errors", null, 0, -1, CDOResource.class, + IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getCDOResource_Warnings(), this.getDiagnostic(), "warnings", null, 0, -1, CDOResource.class, + IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getCDOResource_Path(), ecorePackage.getEString(), "path", null, 0, 1, CDOResource.class, + !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + // Initialize data types + initEDataType(resourceSetEDataType, ResourceSet.class, "ResourceSet", !IS_SERIALIZABLE, + !IS_GENERATED_INSTANCE_CLASS); + initEDataType(uriEDataType, org.eclipse.emf.common.util.URI.class, "URI", IS_SERIALIZABLE, + !IS_GENERATED_INSTANCE_CLASS); + initEDataType(diagnosticEDataType, Diagnostic.class, "Diagnostic", !IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + + // Create resource + createResource(eNS_URI); + } + +} // EresourcePackageImpl diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/util/EresourceAdapterFactory.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/util/EresourceAdapterFactory.java new file mode 100644 index 0000000000..213034d06f --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/util/EresourceAdapterFactory.java @@ -0,0 +1,141 @@ +/** + * <copyright> + * </copyright> + * + * $Id$ + */ +package org.eclipse.emf.cdo.eresource.util; + +import org.eclipse.emf.cdo.eresource.CDOResource; +import org.eclipse.emf.cdo.eresource.EresourcePackage; + +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notifier; +import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl; +import org.eclipse.emf.ecore.EObject; + +/** + * <!-- begin-user-doc --> The <b>Adapter Factory</b> for the model. It + * provides an adapter <code>createXXX</code> method for each class of the + * model. <!-- end-user-doc --> + * + * @see org.eclipse.emf.cdo.eresource.EresourcePackage + * @generated + */ +public class EresourceAdapterFactory extends AdapterFactoryImpl +{ + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public static final String copyright = ""; + + /** + * The cached model package. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + protected static EresourcePackage modelPackage; + + /** + * Creates an instance of the adapter factory. <!-- begin-user-doc --> <!-- + * end-user-doc --> + * + * @generated + */ + public EresourceAdapterFactory() + { + if (modelPackage == null) + { + modelPackage = EresourcePackage.eINSTANCE; + } + } + + /** + * Returns whether this factory is applicable for the type of the object. <!-- + * begin-user-doc --> This implementation returns <code>true</code> if the + * object is either the model's package or is an instance object of the model. + * <!-- end-user-doc --> + * + * @return whether this factory is applicable for the type of the object. + * @generated + */ + @Override + public boolean isFactoryForType(Object object) + { + if (object == modelPackage) + { + return true; + } + if (object instanceof EObject) + { + return ((EObject)object).eClass().getEPackage() == modelPackage; + } + return false; + } + + /** + * The switch the delegates to the <code>createXXX</code> methods. <!-- + * begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + protected EresourceSwitch<Adapter> modelSwitch = new EresourceSwitch<Adapter>() + { + @Override + public Adapter caseCDOResource(CDOResource object) + { + return createCDOResourceAdapter(); + } + + @Override + public Adapter defaultCase(EObject object) + { + return createEObjectAdapter(); + } + }; + + /** + * Creates an adapter for the <code>target</code>. <!-- begin-user-doc --> + * <!-- end-user-doc --> + * + * @param target + * the object to adapt. + * @return the adapter for the <code>target</code>. + * @generated + */ + @Override + public Adapter createAdapter(Notifier target) + { + return modelSwitch.doSwitch((EObject)target); + } + + /** + * Creates a new adapter for an object of class '{@link org.eclipse.emf.cdo.eresource.CDOResource <em>CDO Resource</em>}'. + * <!-- begin-user-doc --> This default implementation returns null so that we + * can easily ignore cases; it's useful to ignore a case when inheritance will + * catch all the cases anyway. <!-- end-user-doc --> + * + * @return the new adapter. + * @see org.eclipse.emf.cdo.eresource.CDOResource + * @generated + */ + public Adapter createCDOResourceAdapter() + { + return null; + } + + /** + * Creates a new adapter for the default case. <!-- begin-user-doc --> This + * default implementation returns null. <!-- end-user-doc --> + * + * @return the new adapter. + * @generated + */ + public Adapter createEObjectAdapter() + { + return null; + } + +} // EresourceAdapterFactory diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/util/EresourceSwitch.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/util/EresourceSwitch.java new file mode 100644 index 0000000000..733aa260bf --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/util/EresourceSwitch.java @@ -0,0 +1,153 @@ +/** + * <copyright> + * </copyright> + * + * $Id$ + */ +package org.eclipse.emf.cdo.eresource.util; + +import org.eclipse.emf.cdo.eresource.CDOResource; +import org.eclipse.emf.cdo.eresource.EresourcePackage; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; + +import java.util.List; + +/** + * <!-- begin-user-doc --> The <b>Switch</b> for the model's inheritance + * hierarchy. It supports the call {@link #doSwitch(EObject) doSwitch(object)} + * to invoke the <code>caseXXX</code> method for each class of the model, + * starting with the actual class of the object and proceeding up the + * inheritance hierarchy until a non-null result is returned, which is the + * result of the switch. <!-- end-user-doc --> + * + * @see org.eclipse.emf.cdo.eresource.EresourcePackage + * @generated + */ +public class EresourceSwitch<T> +{ + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + public static final String copyright = ""; + + /** + * The cached model package <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + protected static EresourcePackage modelPackage; + + /** + * Creates an instance of the switch. <!-- begin-user-doc --> <!-- + * end-user-doc --> + * + * @generated + */ + public EresourceSwitch() + { + if (modelPackage == null) + { + modelPackage = EresourcePackage.eINSTANCE; + } + } + + /** + * Calls <code>caseXXX</code> for each class of the model until one returns + * a non null result; it yields that result. <!-- begin-user-doc --> <!-- + * end-user-doc --> + * + * @return the first non-null result returned by a <code>caseXXX</code> + * call. + * @generated + */ + public T doSwitch(EObject theEObject) + { + return doSwitch(theEObject.eClass(), theEObject); + } + + /** + * Calls <code>caseXXX</code> for each class of the model until one returns + * a non null result; it yields that result. <!-- begin-user-doc --> <!-- + * end-user-doc --> + * + * @return the first non-null result returned by a <code>caseXXX</code> + * call. + * @generated + */ + protected T doSwitch(EClass theEClass, EObject theEObject) + { + if (theEClass.eContainer() == modelPackage) + { + return doSwitch(theEClass.getClassifierID(), theEObject); + } + else + { + List<EClass> eSuperTypes = theEClass.getESuperTypes(); + return eSuperTypes.isEmpty() ? defaultCase(theEObject) : doSwitch(eSuperTypes.get(0), theEObject); + } + } + + /** + * Calls <code>caseXXX</code> for each class of the model until one returns + * a non null result; it yields that result. <!-- begin-user-doc --> <!-- + * end-user-doc --> + * + * @return the first non-null result returned by a <code>caseXXX</code> + * call. + * @generated + */ + protected T doSwitch(int classifierID, EObject theEObject) + { + switch (classifierID) + { + case EresourcePackage.CDO_RESOURCE: + { + CDOResource cdoResource = (CDOResource)theEObject; + T result = caseCDOResource(cdoResource); + if (result == null) + result = defaultCase(theEObject); + return result; + } + default: + return defaultCase(theEObject); + } + } + + /** + * Returns the result of interpretting the object as an instance of '<em>CDO Resource</em>'. + * <!-- begin-user-doc --> This implementation returns null; returning a + * non-null result will terminate the switch. <!-- end-user-doc --> + * + * @param object + * the target of the switch. + * @return the result of interpretting the object as an instance of '<em>CDO Resource</em>'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseCDOResource(CDOResource object) + { + return null; + } + + /** + * Returns the result of interpretting the object as an instance of '<em>EObject</em>'. + * <!-- begin-user-doc --> This implementation returns null; returning a + * non-null result will terminate the switch, but this is the last case + * anyway. <!-- end-user-doc --> + * + * @param object + * the target of the switch. + * @return the result of interpretting the object as an instance of '<em>EObject</em>'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) + * @generated + */ + public T defaultCase(EObject object) + { + return null; + } + +} // EresourceSwitch diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java new file mode 100644 index 0000000000..efe8ef485b --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java @@ -0,0 +1,147 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.cdo.util; + +import org.eclipse.emf.cdo.CDOAdapter; +import org.eclipse.emf.cdo.CDOObject; +import org.eclipse.emf.cdo.CDOSession; +import org.eclipse.emf.cdo.eresource.CDOResourceFactory; +import org.eclipse.emf.cdo.internal.protocol.CDOIDImpl; +import org.eclipse.emf.cdo.protocol.CDOID; +import org.eclipse.emf.cdo.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.protocol.model.CDOClass; + +import org.eclipse.net4j.ConnectorException; +import org.eclipse.net4j.IConnector; +import org.eclipse.net4j.util.lifecycle.LifecycleUtil; + +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.resource.Resource.Factory.Registry; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.internal.cdo.CDOSessionImpl; +import org.eclipse.emf.internal.cdo.util.EMFUtil; + +import java.util.Map; + +/** + * @author Eike Stepper + */ +public final class CDOUtil +{ + private CDOUtil() + { + } + + public static CDOSession openSession(IConnector connector, String repositoryName) throws ConnectorException + { + CDOSessionImpl session = new CDOSessionImpl(); + session.setConnector(connector); + session.setRepositoryName(repositoryName); + LifecycleUtil.activate(session); + return session; + } + + public static CDOAdapter getAdapter(ResourceSet resourceSet) + { + EList<Adapter> adapters = resourceSet.eAdapters(); + for (Adapter adapter : adapters) + { + if (adapter instanceof CDOAdapter) + { + return (CDOAdapter)adapter; + } + } + + return null; + } + + public static CDOResourceFactory addResourceFactory(ResourceSet resourceSet) + { + CDOResourceFactory factory = CDOResourceFactory.INSTANCE; + Registry registry = resourceSet.getResourceFactoryRegistry(); + Map<String, Object> map = registry.getProtocolToFactoryMap(); + map.put(CDOProtocolConstants.PROTOCOL_NAME, factory); + return factory; + } + + public static String extractPath(URI uri) + { + if (!CDOProtocolConstants.PROTOCOL_NAME.equals(uri.scheme())) + { + return null; + } + + if (uri.hasAuthority()) + { + return null; + } + + if (!uri.isHierarchical()) + { + return null; + } + + if (!uri.hasAbsolutePath()) + { + return null; + } + + return uri.path(); + } + + public static CDOID extractID(URI uri) + { + if (!CDOProtocolConstants.PROTOCOL_NAME.equals(uri.scheme())) + { + return null; + } + + if (uri.hasAuthority()) + { + return null; + } + + if (!uri.isHierarchical()) + { + return null; + } + + if (uri.hasAbsolutePath()) + { + return null; + } + + try + { + String path = uri.path(); + return CDOIDImpl.parse(path); + } + catch (RuntimeException ex) + { + return null; + } + } + + public static URI createURI(String path) + { + return URI.createURI(CDOProtocolConstants.PROTOCOL_NAME + ":" + path); + } + + public static CDOObject createObject(CDOClass cdoClass) + { + EClass eClass = EMFUtil.getEClass(cdoClass); + return (CDOObject)EcoreUtil.create(eClass); + } +} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/ServerException.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/ServerException.java new file mode 100644 index 0000000000..2ba7e84bdb --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/ServerException.java @@ -0,0 +1,38 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.cdo.util; + +/** + * @author Eike Stepper + */ +public class ServerException extends RuntimeException +{ + private static final long serialVersionUID = 1L; + + public ServerException() + { + } + + public ServerException(String message) + { + super(message); + } + + public ServerException(String message, Throwable cause) + { + super(message, cause); + } + + public ServerException(Throwable cause) + { + super(cause); + } +} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOAdapterImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOAdapterImpl.java new file mode 100644 index 0000000000..79567994a8 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOAdapterImpl.java @@ -0,0 +1,469 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.internal.cdo; + +import org.eclipse.emf.cdo.CDOAdapter; +import org.eclipse.emf.cdo.CDOObject; +import org.eclipse.emf.cdo.CDOState; +import org.eclipse.emf.cdo.CDOView; +import org.eclipse.emf.cdo.eresource.CDOResource; +import org.eclipse.emf.cdo.eresource.EresourceFactory; +import org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl; +import org.eclipse.emf.cdo.internal.protocol.event.CDOEventImpl; +import org.eclipse.emf.cdo.internal.protocol.event.CDOEventSourceImpl; +import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl; +import org.eclipse.emf.cdo.protocol.CDOID; +import org.eclipse.emf.cdo.protocol.event.CDOInvalidationEvent; +import org.eclipse.emf.cdo.protocol.model.CDOClass; +import org.eclipse.emf.cdo.protocol.util.ImplementationError; +import org.eclipse.emf.cdo.protocol.util.TransportException; +import org.eclipse.emf.cdo.util.CDOUtil; + +import org.eclipse.net4j.util.om.trace.ContextTracer; + +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.Notifier; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.internal.cdo.bundle.CDO; +import org.eclipse.emf.internal.cdo.protocol.ResourcePathRequest; + +import java.text.MessageFormat; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +/** + * @author Eike Stepper + */ +public class CDOAdapterImpl extends CDOEventSourceImpl implements CDOAdapter, Adapter.Internal +{ + private static final ContextTracer TRACER = new ContextTracer(CDO.DEBUG_ADAPTER, CDOAdapterImpl.class); + + private CDOSessionImpl session; + + private ResourceSet resourceSet; + + private CDOViewImpl view; + + private CDOTransactionImpl transaction; + + private Map<CDOID, CDOObjectImpl> objects = new HashMap(); + + public CDOAdapterImpl(CDOSessionImpl session, boolean readOnly) + { + this.session = session; + view = new CDOViewImpl(this, CDOView.UNSPECIFIED_DATE); + if (!readOnly) + { + transaction = new CDOTransactionImpl(this); + } + } + + public CDOAdapterImpl(CDOSessionImpl session, long timeStamp) + { + this.session = session; + view = new CDOViewImpl(this, timeStamp); + } + + public ResourceSet getResourceSet() + { + return resourceSet; + } + + public CDOSessionImpl getSession() + { + return session; + } + + public CDOViewImpl getView() + { + return view; + } + + public CDOTransactionImpl getTransaction() + { + return transaction; + } + + public boolean isActual() + { + return getView().isActual(); + } + + public boolean isHistorical() + { + return getView().isHistorical(); + } + + public boolean isReadOnly() + { + return transaction == null; + } + + public CDOResource createResource(String path) + { + return (CDOResource)getResourceSet().createResource(CDOUtil.createURI(path)); + } + + public CDOResource getResource(String path) + { + return (CDOResource)getResourceSet().getResource(CDOUtil.createURI(path), true); + } + + public CDOResourceImpl getResource(CDOID resourceID) + { + if (resourceID == null || resourceID == CDOID.NULL) + { + throw new ImplementationError("resourceID == null || resourceID == CDOID.NULL"); + } + + ResourceSet resourceSet = getResourceSet(); + EList<Resource> resources = resourceSet.getResources(); + for (Resource resource : resources) + { + if (resource instanceof CDOResourceImpl) + { + CDOResourceImpl cdoResource = (CDOResourceImpl)resource; + if (resourceID.equals(cdoResource.cdoID())) + { + return cdoResource; + } + } + } + + try + { + ResourcePathRequest signal = new ResourcePathRequest(getSession().getChannel(), resourceID); + String path = signal.send(); + + CDOResourceImpl resource = (CDOResourceImpl)EresourceFactory.eINSTANCE.createCDOResource(); + resource.setResourceSet(resourceSet); + resource.setPath(path); + + CDOObjectImpl resourceObject = resource; + resourceObject.setID(resourceID); + resourceObject.setAdapter(this); + resourceObject.setResource(resource); + resourceObject.setState(CDOState.PROXY); + + return resource; + } + catch (Exception ex) + { + throw new TransportException(ex); + } + } + + public CDOObject lookupObject(CDOID id) + { + if (TRACER.isEnabled()) + { + TRACER.format("Looking up object {0}", id); + } + + CDOObjectImpl object = objects.get(id); + if (object == null) + { + object = createObjectFromView(id); + registerObject(object); + } + + return object; + } + + public void registerObject(CDOObjectImpl object) + { + if (TRACER.isEnabled()) + { + TRACER.format("Registering object {0}", object); + } + + CDOObjectImpl old = objects.put(object.cdoID(), object); + if (old != null) + { + throw new IllegalStateException("Duplicate ID: " + object); + } + } + + public void deregisterObject(CDOObjectImpl object) + { + if (TRACER.isEnabled()) + { + TRACER.format("Deregistering object {0}", object); + } + + CDOObjectImpl old = objects.remove(object.cdoID()); + if (old == null) + { + throw new IllegalStateException("Unknown ID: " + object); + } + } + + public void remapObject(CDOID oldID) + { + CDOObjectImpl object = objects.remove(oldID); + CDOID newID = object.cdoID(); + objects.put(newID, object); + if (TRACER.isEnabled()) + { + TRACER.format("Remapping object: {0} --> {1}", oldID, newID); + } + } + + /** + * Turns registered objects into proxies and synchronously delivers + * invalidation events to registered event listeners. + * <p> + * <b>Implementation note:</b> This implementation guarantees that exceptions + * from listener code don't propagate up to the caller of this method. Runtime + * exceptions from the implementation of the {@link CDOStateMachine} are + * propagated to the caller of this method but this should not happen in the + * absence of implementation errors. + * + * @param timeStamp + * The point in time when the newly committed revision have been + * created. + * @param dirtyOIDs + * A set of the object IDs to be invalidated. <b>Implementation note:</b> + * This implementation expects the dirtyOIDs set to be unmodifiable. + * It does not wrap the set (again). + */ + public void notifyInvalidation(long timeStamp, Set<CDOID> dirtyOIDs) + { + for (CDOID dirtyOID : dirtyOIDs) + { + CDOObjectImpl object = objects.get(dirtyOID); + if (object != null) + { + CDOStateMachine.INSTANCE.invalidate(object, timeStamp); + } + } + + fireObjectEvent(new CDOInvalidationEventImpl(timeStamp, dirtyOIDs)); + } + + public void commit() + { + checkWritable(); + transaction.commit(); + } + + public void rollback() + { + checkWritable(); + transaction.rollback(); + } + + public void detach() + { + session.adapterDetached(this); + } + + @Override + public String toString() + { + return MessageFormat.format("CDOAdapter({0}, {1})", view.toString(), isReadOnly() ? "readOnly" : "readWrite"); + } + + public boolean isAdapterForType(Object type) + { + return type instanceof ResourceSet; + } + + public Notifier getTarget() + { + return resourceSet; + } + + public void setTarget(Notifier newTarget) + { + ResourceSet resourceSet = (ResourceSet)newTarget; + if (TRACER.isEnabled()) + { + TRACER.trace("Attaching CDO adapter to " + resourceSet); + } + + this.resourceSet = resourceSet; + for (Resource resource : resourceSet.getResources()) + { + if (resource instanceof CDOResourceImpl) + { + CDOResourceImpl cdoResource = (CDOResourceImpl)resource; + CDOStateMachine.INSTANCE.attach(cdoResource, cdoResource, this); + } + } + } + + public void unsetTarget(Notifier oldTarget) + { + ResourceSet resourceSet = (ResourceSet)oldTarget; + for (Resource resource : resourceSet.getResources()) + { + if (resource instanceof CDOResourceImpl) + { + CDOResourceImpl cdoResource = (CDOResourceImpl)resource; + CDOStateMachine.INSTANCE.detach(cdoResource, cdoResource, this); + } + } + + if (TRACER.isEnabled()) + { + TRACER.trace("Detaching CDO adapter from " + resourceSet); + } + + if (resourceSet == oldTarget) + { + setTarget(null); + } + } + + public void notifyChanged(Notification msg) + { + switch (msg.getEventType()) + { + case Notification.ADD: + notifyAdd(msg); + break; + + case Notification.ADD_MANY: + notifyAddMany(msg); + break; + + case Notification.REMOVE: + notifyRemove(msg); + break; + + case Notification.REMOVE_MANY: + notifyRemoveMany(msg); + break; + } + } + + private void notifyAdd(Notification msg) + { + if (msg.getNewValue() instanceof CDOResourceImpl) + { + CDOResourceImpl cdoResource = (CDOResourceImpl)msg.getNewValue(); + CDOStateMachine.INSTANCE.attach(cdoResource, cdoResource, this); + } + } + + private void notifyAddMany(Notification msg) + { + EList<Resource> newResources = (EList<Resource>)msg.getNewValue(); + EList<Resource> oldResources = (EList<Resource>)msg.getOldValue(); + for (Resource newResource : newResources) + { + if (newResource instanceof CDOResourceImpl) + { + if (!oldResources.contains(newResource)) + { + CDOResourceImpl cdoResource = (CDOResourceImpl)newResource; + CDOStateMachine.INSTANCE.attach(cdoResource, cdoResource, this); + } + } + } + } + + private void notifyRemove(Notification msg) + { + if (msg.getOldValue() instanceof CDOResourceImpl) + { + CDOResourceImpl cdoResource = (CDOResourceImpl)msg.getOldValue(); + CDOStateMachine.INSTANCE.detach(cdoResource, cdoResource, this); + } + } + + private void notifyRemoveMany(Notification msg) + { + EList<Resource> newResources = (EList<Resource>)msg.getNewValue(); + EList<Resource> oldResources = (EList<Resource>)msg.getOldValue(); + for (Resource oldResource : oldResources) + { + if (oldResource instanceof CDOResourceImpl) + { + if (!newResources.contains(oldResource)) + { + CDOResourceImpl cdoResource = (CDOResourceImpl)oldResource; + CDOStateMachine.INSTANCE.detach(cdoResource, cdoResource, this); + } + } + } + } + + private CDOObjectImpl createObjectFromView(CDOID id) + { + if (TRACER.isEnabled()) + { + TRACER.format("Creating object from view: ID={0}", id); + } + + CDORevisionImpl revision = view.resolve(id); + CDOClass cdoClass = revision.getCDOClass(); + CDOID resourceID = revision.getResourceID(); + + CDOObjectImpl object = (CDOObjectImpl)CDOUtil.createObject(cdoClass); + if (object instanceof CDOResourceImpl) + { + object.setResource((CDOResourceImpl)object); + } + else + { + CDOResourceImpl resource = getResource(resourceID); + object.setResource(resource); + } + + object.setRevision(revision); + object.setID(revision.getID()); + object.setState(CDOState.CLEAN); + return object; + } + + private void checkWritable() + { + if (isReadOnly()) + { + throw new IllegalStateException("CDO adapter is read only"); + } + } + + public static class CDOInvalidationEventImpl extends CDOEventImpl implements CDOInvalidationEvent + { + private long timeStamp; + + private Set<CDOID> dirtyOIDs; + + public CDOInvalidationEventImpl(long timeStamp, Set<CDOID> dirtyOIDs) + { + this.timeStamp = timeStamp; + this.dirtyOIDs = dirtyOIDs; + } + + public long getTimeStamp() + { + return timeStamp; + } + + public Set<CDOID> getDirtyOIDs() + { + return dirtyOIDs; + } + + @Override + public String toString() + { + return "CDOInvalidationEvent" + dirtyOIDs; + } + } +} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java new file mode 100644 index 0000000000..3912956b30 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java @@ -0,0 +1,416 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.internal.cdo; + +import org.eclipse.emf.cdo.CDOObject; +import org.eclipse.emf.cdo.CDOState; +import org.eclipse.emf.cdo.eresource.CDOResource; +import org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl; +import org.eclipse.emf.cdo.internal.protocol.model.CDOClassImpl; +import org.eclipse.emf.cdo.internal.protocol.model.CDOFeatureImpl; +import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl; +import org.eclipse.emf.cdo.protocol.CDOID; +import org.eclipse.emf.cdo.protocol.util.ImplementationError; + +import org.eclipse.net4j.util.om.trace.ContextTracer; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.InternalEObject; +import org.eclipse.emf.ecore.impl.EStoreEObjectImpl; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.Resource.Internal; +import org.eclipse.emf.internal.cdo.bundle.CDO; +import org.eclipse.emf.internal.cdo.util.EMFUtil; + +/** + * @author Eike Stepper + */ +public class CDOObjectImpl extends EStoreEObjectImpl implements CDOObject +{ + private static final ContextTracer TRACER = new ContextTracer(CDO.DEBUG_OBJECT, CDOObjectImpl.class); + + private CDOID id; + + private CDOState state; + + private CDOResourceImpl resource; + + private CDORevisionImpl revision; + + public CDOObjectImpl() + { + super(CDOStore.INSTANCE); + state = CDOState.TRANSIENT; + eContainer = null; + if (TRACER.isEnabled()) + { + TRACER.format("Creating object: {0}", cdoClass()); + } + } + + public CDOClassImpl cdoClass() + { + return EMFUtil.getCDOClass(eClass()); + } + + public CDOID cdoID() + { + return id; + } + + public CDOState cdoState() + { + return state; + } + + public CDOAdapterImpl cdoAdapter() + { + return resource != null ? resource.cdoAdapter() : null; + } + + public CDOResourceImpl cdoResource() + { + if (this instanceof CDOResourceImpl) + { + resource = (CDOResourceImpl)this; + } + + return resource; + } + + public CDORevisionImpl cdoRevision() + { + return revision; + } + + public boolean cdoTransient() + { + final CDOState cdoState = cdoState(); + return cdoState == CDOState.TRANSIENT || cdoState == CDOState.PREPARED_ATTACH; + } + + void setID(CDOID id) + { + if (id == null) + { + throw new IllegalArgumentException("id == null"); + } + + if (TRACER.isEnabled()) + { + TRACER.format("Setting ID: {0}", id); + } + + this.id = id; + } + + void setState(CDOState state) + { + if (this.state != state) + { + if (TRACER.isEnabled()) + { + TRACER.format("Setting state {0} for {1}", state, this); + } + + this.state = state; + } + } + + void setAdapter(CDOAdapterImpl adapter) + { + if (this instanceof CDOResourceImpl) + { + ((CDOResourceImpl)this).cdoSetAdapter(adapter); + } + } + + void setResource(CDOResourceImpl resource) + { + if (this instanceof CDOResourceImpl) + { + return; + } + + if (TRACER.isEnabled()) + { + TRACER.format("Setting resource: {0}", resource); + } + + this.resource = resource; + } + + void setRevision(CDORevisionImpl revision) + { + if (TRACER.isEnabled()) + { + TRACER.format("Setting revision: {0}", revision); + } + + this.revision = revision; + } + + void initializeContainer(InternalEObject container, EStructuralFeature eContainingFeature) + { + eContainer = container; + CDORevisionImpl revision = cdoRevision(); + if (eContainer != null) + { + if (revision != null) + { + if (eContainer instanceof CDOObject && !(eContainer instanceof CDOResource)) + { + revision.setContainerID(((CDOObject)eContainer).cdoID()); + } + else + { + revision.setContainerID(CDOID.NULL); + } + } + + if (eContainingFeature instanceof EReference) + { + EReference eContainingReference = (EReference)eContainingFeature; + EReference eOpposite = eContainingReference.getEOpposite(); + if (eOpposite != null) + { + eContainerFeatureID = eClass().getFeatureID(eOpposite); + return; + } + } + + eContainerFeatureID = EOPPOSITE_FEATURE_BASE - eContainer.eClass().getFeatureID(eContainingFeature); + } + else + { + if (revision != null) + { + revision.setContainerID(CDOID.NULL); + } + } + } + + void finalizeRevision() + { + if (TRACER.isEnabled()) + { + TRACER.format("Finalizing revision for {0}", this); + } + + CDOAdapterImpl adapter = cdoAdapter(); + revision.setVersion(1); + revision.setContainerID(eContainer == null ? CDOID.NULL : ((CDOObjectImpl)eContainer).cdoID()); + revision.setContainingFeature(eContainerFeatureID); + + for (int i = 0; i < eClass().getFeatureCount(); i++) + { + Object setting = eSettings[i]; + if (setting != null) + { + EStructuralFeature eFeature = eDynamicFeature(i); + if (!eFeature.isTransient()) + { + finalizeRevisionFeature(adapter, revision, i, setting, eFeature); + } + } + } + } + + private void finalizeRevisionFeature(CDOAdapterImpl adapter, CDORevisionImpl revision, int i, Object setting, + EStructuralFeature eFeature) + { + CDOFeatureImpl cdoFeature = EMFUtil.getCDOFeature(eFeature); + if (TRACER.isEnabled()) + { + TRACER.format("Finalizing feature {0}", cdoFeature); + } + + boolean isReference = cdoFeature.isReference(); + if (cdoFeature.isMany()) + { + int index = 0; + EList<Object> list = (EList<Object>)setting; + for (Object value : list) + { + if (isReference) + { + value = CDOStore.convertToID(adapter, value); + } + + revision.add(cdoFeature, index++, value); + } + } + else + { + if (isReference) + { + setting = CDOStore.convertToID(adapter, setting); + } + + revision.set(cdoFeature, 0, setting); + } + + eSettings[i] = null; + } + + public CDORevisionImpl copyRevision() + { + return revision = new CDORevisionImpl(revision); + } + + @Override + protected void eInitializeContainer() + { + throw new ImplementationError(); + } + + @Override + protected void eSetDirectResource(Internal resource) + { + super.eSetDirectResource(resource); + if (resource instanceof CDOResourceImpl) + { + this.resource = (CDOResourceImpl)resource; + } + } + + /** + * Don't cache non-transient features in this CDOObject's {@link #eSettings()}. + */ + @Override + protected boolean eIsCaching() + { + return false; + } + + @Override + public Object dynamicGet(int dynamicFeatureID) + { + if (cdoTransient()) + { + return eSettings[dynamicFeatureID]; + } + + return super.dynamicGet(dynamicFeatureID); + } + + @Override + public boolean eIsSet(EStructuralFeature feature) + { + if (cdoTransient()) + { + // TODO What about defaultValues != null? + return eSettings[eDynamicFeatureID(feature)] != null; + } + + return super.eIsSet(feature); + } + + @Override + public void dynamicSet(int dynamicFeatureID, Object value) + { + if (cdoTransient()) + { + eSettings[dynamicFeatureID] = value; + return; + } + + super.dynamicSet(dynamicFeatureID, value); + } + + @Override + public void dynamicUnset(int dynamicFeatureID) + { + if (cdoTransient()) + { + eSettings[dynamicFeatureID] = null; + return; + } + + super.dynamicUnset(dynamicFeatureID); + } + + @Override + public InternalEObject eInternalContainer() + { + InternalEObject container; + if (cdoTransient()) + { + container = eContainer; + } + else + { + container = CDOStore.INSTANCE.getContainer(this); + } + + if (container instanceof CDOResource) + { + return null; + } + + return container; + } + + @Override + public int eContainerFeatureID() + { + if (cdoTransient()) + { + return eContainerFeatureID; + } + + return CDOStore.INSTANCE.getContainingFeatureID(this); + } + + @Override + protected void eBasicSetContainer(InternalEObject newContainer, int newContainerFeatureID) + { + if (TRACER.isEnabled()) + { + TRACER.format("Setting container: {0}, featureID={1}", newContainer, newContainerFeatureID); + } + + if (cdoTransient()) + { + eContainer = newContainer; + eContainerFeatureID = newContainerFeatureID; + } + else + { + CDOStore.INSTANCE.setContainer(this, newContainer, newContainerFeatureID); + } + } + + @Override + public Resource eResource() + { + return cdoResource(); + } + + @Override + public boolean equals(Object obj) + { + return obj == this; + } + + @Override + public String toString() + { + if (id == null) + { + return eClass().getName() + "?"; + } + + return eClass().getName() + "@" + id; + } +} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDORevisionManagerImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDORevisionManagerImpl.java new file mode 100644 index 0000000000..7bb4d5c5fd --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDORevisionManagerImpl.java @@ -0,0 +1,51 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.internal.cdo; + +import org.eclipse.emf.cdo.CDORevisionManager; +import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl; +import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionResolverImpl; +import org.eclipse.emf.cdo.protocol.CDOID; +import org.eclipse.emf.cdo.protocol.util.TransportException; + +import org.eclipse.emf.internal.cdo.protocol.LoadObjectRequest; + +/** + * @author Eike Stepper + */ +public class CDORevisionManagerImpl extends CDORevisionResolverImpl implements CDORevisionManager +{ + private CDOSessionImpl session; + + public CDORevisionManagerImpl(CDOSessionImpl session) + { + this.session = session; + } + + public CDOSessionImpl getSession() + { + return session; + } + + @Override + protected CDORevisionImpl loadActual(CDOID id) + { + try + { + LoadObjectRequest signal = new LoadObjectRequest(session.getChannel(), id); + return signal.send(); + } + catch (Exception ex) + { + throw new TransportException(ex); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionFactory.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionFactory.java new file mode 100644 index 0000000000..993a1ed23d --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionFactory.java @@ -0,0 +1,49 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.internal.cdo; + +import org.eclipse.emf.cdo.CDOSession; +import org.eclipse.emf.cdo.protocol.CDOProtocolConstants; + +import org.eclipse.net4j.internal.util.factory.Factory; + +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.internal.cdo.bundle.CDO; + +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; + +/** + * @author Eike Stepper + */ +public class CDOSessionFactory extends Factory<CDOSession> +{ + public static final String SESSION_GROUP = CDO.BUNDLE_ID + ".sessions"; + + public CDOSessionFactory() + { + super(SESSION_GROUP, CDOProtocolConstants.PROTOCOL_NAME); + } + + public CDOSession create(String description) + { + CDOSessionImpl session = new CDOSessionImpl(); + session.setRepositoryName(getRepositoryName(description)); + return session; + } + + public static String getRepositoryName(String description) + { + URI uri = URI.createURI(description); + IPath path = new Path(uri.path()); + return path.segment(0); + } +} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java new file mode 100644 index 0000000000..e6f9417b17 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java @@ -0,0 +1,287 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.internal.cdo; + +import org.eclipse.emf.cdo.CDOAdapter; +import org.eclipse.emf.cdo.CDOSession; +import org.eclipse.emf.cdo.CDOSessionAdaptersEvent; +import org.eclipse.emf.cdo.protocol.CDOID; +import org.eclipse.emf.cdo.util.CDOUtil; + +import org.eclipse.net4j.ConnectorException; +import org.eclipse.net4j.IChannel; +import org.eclipse.net4j.IConnector; +import org.eclipse.net4j.internal.util.container.SingleDeltaContainerEvent; +import org.eclipse.net4j.internal.util.lifecycle.Lifecycle; +import org.eclipse.net4j.internal.util.lifecycle.LifecycleEventAdapter; +import org.eclipse.net4j.util.container.IContainerDelta; +import org.eclipse.net4j.util.container.IContainerDelta.Kind; +import org.eclipse.net4j.util.event.EventUtil; +import org.eclipse.net4j.util.event.IListener; +import org.eclipse.net4j.util.lifecycle.ILifecycle; +import org.eclipse.net4j.util.om.trace.ContextTracer; + +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.internal.cdo.bundle.CDO; +import org.eclipse.emf.internal.cdo.protocol.CDOClientProtocol; +import org.eclipse.emf.internal.cdo.protocol.OpenSessionRequest; +import org.eclipse.emf.internal.cdo.protocol.OpenSessionResult; + +import java.text.MessageFormat; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +/** + * @author Eike Stepper + */ +public class CDOSessionImpl extends Lifecycle implements CDOSession +{ + @SuppressWarnings("unused") + private static final ContextTracer TRACER = new ContextTracer(CDO.DEBUG_SESSION, CDOSessionImpl.class); + + private int sessionID; + + private IChannel channel; + + private String repositoryName; + + private String repositoryUUID; + + private CDORevisionManagerImpl revisionManager; + + private Map<ResourceSet, CDOAdapterImpl> adapters = new HashMap(); + + private IListener channelListener = new LifecycleEventAdapter() + { + @Override + protected void onDeactivated(ILifecycle lifecycle) + { + close(); + } + }; + + public CDOSessionImpl() + { + revisionManager = new CDORevisionManagerImpl(this); + } + + public int getSessionID() + { + return sessionID; + } + + public IConnector getConnector() + { + return channel.getConnector(); + } + + public void setConnector(IConnector connector) throws ConnectorException + { + CDOClientProtocol protocol = new CDOClientProtocol(); + protocol.setSession(this); + channel = connector.openChannel(protocol); + EventUtil.addListener(channel, channelListener); + } + + public IChannel getChannel() + { + return channel; + } + + public void setChannel(IChannel channel) + { + this.channel = channel; + } + + public String getRepositoryName() + { + return repositoryName; + } + + public void setRepositoryName(String repositoryName) + { + this.repositoryName = repositoryName; + } + + public String getRepositoryUUID() + { + return repositoryUUID; + } + + public boolean isOpen() + { + return channel != null; + } + + public void close() + { + deactivate(); + } + + public CDORevisionManagerImpl getRevisionManager() + { + return revisionManager; + } + + public CDOAdapterImpl attach(ResourceSet resourceSet) + { + return attach(resourceSet, false); + } + + public CDOAdapterImpl attach(ResourceSet resourceSet, boolean readOnly) + { + prepare(resourceSet); + return attach(resourceSet, new CDOAdapterImpl(this, readOnly)); + } + + public CDOAdapterImpl attach(ResourceSet resourceSet, long timeStamp) + { + prepare(resourceSet); + return attach(resourceSet, new CDOAdapterImpl(this, timeStamp)); + } + + public CDOAdapterImpl[] getAdapters() + { + Collection<CDOAdapterImpl> values; + synchronized (adapters) + { + values = adapters.values(); + } + return values.toArray(new CDOAdapterImpl[values.size()]); + } + + public CDOAdapter[] getElements() + { + return getAdapters(); + } + + public boolean isEmpty() + { + return adapters.isEmpty(); + } + + public void adapterDetached(CDOAdapterImpl adapter) + { + synchronized (adapters) + { + adapters.remove(adapter.getResourceSet()); + fireEvent(new CDOSessionAdaptersEventImpl(this, adapter, IContainerDelta.Kind.REMOVED)); + } + } + + public void notifyInvalidation(long timeStamp, Set<CDOID> dirtyOIDs, CDOAdapterImpl excludedAdapter) + { + CDOAdapterImpl[] values; + synchronized (adapters) + { + values = adapters.values().toArray(new CDOAdapterImpl[adapters.size()]); + } + + Set<CDOID> unmodifiableSet = Collections.unmodifiableSet(dirtyOIDs); + for (CDOAdapterImpl adapter : values) + { + if (adapter != excludedAdapter) + { + adapter.notifyInvalidation(timeStamp, unmodifiableSet); + } + } + } + + @Override + public String toString() + { + IConnector connector = channel == null ? null : channel.getConnector(); + return MessageFormat.format("CDOSession[{0}/{1}]", connector, repositoryName); + } + + @Override + protected void doBeforeActivate() throws Exception + { + super.doBeforeActivate(); + if (channel == null) + { + throw new IllegalStateException("channel == null"); + } + + if (repositoryName == null) + { + throw new IllegalStateException("repositoryName == null"); + } + } + + @Override + protected void doActivate() throws Exception + { + super.doActivate(); + OpenSessionRequest request = new OpenSessionRequest(channel, repositoryName); + OpenSessionResult result = request.send(); + sessionID = result.getSessionID(); + repositoryUUID = result.getRepositoryUUID(); + } + + @Override + protected void doDeactivate() throws Exception + { + EventUtil.removeListener(channel, channelListener); + channel.close(); + super.doDeactivate(); + } + + private void prepare(ResourceSet resourceSet) + { + CDOAdapter adapter = CDOUtil.getAdapter(resourceSet); + if (adapter != null) + { + throw new IllegalStateException("CDO adapter already present: " + adapter); + } + + CDOUtil.addResourceFactory(resourceSet); + } + + private CDOAdapterImpl attach(ResourceSet resourceSet, CDOAdapterImpl adapter) + { + synchronized (adapters) + { + resourceSet.eAdapters().add(adapter); + adapters.put(resourceSet, adapter); + fireEvent(new CDOSessionAdaptersEventImpl(this, adapter, IContainerDelta.Kind.ADDED)); + } + + return adapter; + } + + /** + * @author Eike Stepper + */ + private static class CDOSessionAdaptersEventImpl extends SingleDeltaContainerEvent<CDOAdapter> implements + CDOSessionAdaptersEvent + { + private static final long serialVersionUID = 1L; + + public CDOSessionAdaptersEventImpl(CDOSession session, CDOAdapter adapter, Kind kind) + { + super(session, adapter, kind); + } + + public CDOSession getSession() + { + return (CDOSession)getContainer(); + } + + public CDOAdapter getAdapter() + { + return getDeltaElement(); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java new file mode 100644 index 0000000000..7277f7618e --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java @@ -0,0 +1,501 @@ +package org.eclipse.emf.internal.cdo; + +import org.eclipse.emf.cdo.CDOState; +import org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl; +import org.eclipse.emf.cdo.internal.protocol.CDOIDImpl; +import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl; +import org.eclipse.emf.cdo.protocol.CDOID; +import org.eclipse.emf.cdo.protocol.util.TransportException; +import org.eclipse.emf.cdo.util.CDOUtil; +import org.eclipse.emf.cdo.util.ServerException; + +import org.eclipse.net4j.util.om.trace.ContextTracer; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.internal.cdo.bundle.CDO; +import org.eclipse.emf.internal.cdo.protocol.CommitTransactionResult; +import org.eclipse.emf.internal.cdo.protocol.ResourceIDRequest; + +import java.util.Map; + +/** + * @author Eike Stepper + */ +public final class CDOStateMachine +{ + // @Singleton + public static final CDOStateMachine INSTANCE = new CDOStateMachine(); + + private static final ContextTracer TRACER = new ContextTracer(CDO.DEBUG_OBJECT, CDOStateMachine.class); + + private static Transition IGNORE; + + private static Transition FAIL; + + private Transition[][] transitions; + + private CDOStateMachine() + { + IGNORE = new IgnoreTransition(); + FAIL = new FailTransition(); + + // Dimension the matrix + int states = CDOState.values().length; + int events = Event.values().length; + transitions = new Transition[states][events]; + + // Fill the matrix + initTransitions(); + + // Test the matrix for completeness + for (CDOState state : CDOState.values()) + { + for (Event event : Event.values()) + { + if (transitions[state.ordinal()][event.ordinal()] == null) + { + throw new IllegalStateException("transitions[" + state + "][" + event + "] == null"); + } + } + } + } + + public void attach(CDOObjectImpl object, CDOResourceImpl resource, CDOAdapterImpl adapter) + { + if (TRACER.isEnabled()) + { + TRACER.format("ATTACH: {0} --> {1}", object, adapter); + } + + // TRANSIENT --> PREPARED_ATTACH + INSTANCE.processEvent(object, Event.ATTACH, resource, adapter); + + if (TRACER.isEnabled()) + { + TRACER.format("FINALIZE_ATTACH: {0} --> {1}", object, adapter); + } + + // PREPARED_ATTACH --> NEW + INSTANCE.processEvent(object, Event.FINALIZE_ATTACH, resource, adapter); + } + + public void detach(CDOObjectImpl object, CDOResourceImpl resource, CDOAdapterImpl adapter) + { + // TODO Implement method CDOStateMachine.detach() + throw new UnsupportedOperationException("Not yet implemented"); + } + + public void read(CDOObjectImpl object) + { + if (TRACER.isEnabled()) + { + TRACER.format("READ: {0}", object); + } + + INSTANCE.processEvent(object, Event.READ, null, null); + } + + public void write(CDOObjectImpl object) + { + if (TRACER.isEnabled()) + { + TRACER.format("WRITE: {0}", object); + } + + INSTANCE.processEvent(object, Event.WRITE, null, null); + } + + public void invalidate(CDOObjectImpl object, long timeStamp) + { + if (TRACER.isEnabled()) + { + TRACER.format("INVALIDATE: {0}", object); + } + + INSTANCE.processEvent(object, Event.INVALIDATE, timeStamp, null); + } + + public void commit(CDOObjectImpl object, CommitTransactionResult result) + { + if (TRACER.isEnabled()) + { + TRACER.format("COMMIT: {0}", object); + } + + INSTANCE.processEvent(object, Event.COMMIT, result, null); + } + + public void rollback(CDOObjectImpl object) + { + if (TRACER.isEnabled()) + { + TRACER.format("ROLLBACK: {0}", object); + } + + INSTANCE.processEvent(object, Event.ROLLBACK, null, null); + } + + private void initTransitions() + { + setTransition(CDOState.TRANSIENT, Event.ATTACH, new AttachTransition()); + setTransition(CDOState.TRANSIENT, Event.DETACH, FAIL); + setTransition(CDOState.TRANSIENT, Event.READ, IGNORE); + setTransition(CDOState.TRANSIENT, Event.WRITE, IGNORE); + setTransition(CDOState.TRANSIENT, Event.COMMIT, FAIL); + setTransition(CDOState.TRANSIENT, Event.ROLLBACK, FAIL); + setTransition(CDOState.TRANSIENT, Event.INVALIDATE, FAIL); + setTransition(CDOState.TRANSIENT, Event.FINALIZE_ATTACH, FAIL); + + setTransition(CDOState.PREPARED_ATTACH, Event.ATTACH, FAIL); + setTransition(CDOState.PREPARED_ATTACH, Event.DETACH, FAIL); + setTransition(CDOState.PREPARED_ATTACH, Event.READ, FAIL); + setTransition(CDOState.PREPARED_ATTACH, Event.WRITE, FAIL); + setTransition(CDOState.PREPARED_ATTACH, Event.COMMIT, FAIL); + setTransition(CDOState.PREPARED_ATTACH, Event.ROLLBACK, FAIL); + setTransition(CDOState.PREPARED_ATTACH, Event.INVALIDATE, FAIL); + setTransition(CDOState.PREPARED_ATTACH, Event.FINALIZE_ATTACH, new FinalizeAttachTransition()); + + setTransition(CDOState.NEW, Event.ATTACH, FAIL); + setTransition(CDOState.NEW, Event.DETACH, FAIL); + setTransition(CDOState.NEW, Event.READ, IGNORE); + setTransition(CDOState.NEW, Event.WRITE, IGNORE); + setTransition(CDOState.NEW, Event.COMMIT, new CommitTransition()); + setTransition(CDOState.NEW, Event.ROLLBACK, FAIL); + setTransition(CDOState.NEW, Event.INVALIDATE, FAIL); + setTransition(CDOState.NEW, Event.FINALIZE_ATTACH, FAIL); + + setTransition(CDOState.CLEAN, Event.ATTACH, FAIL); + setTransition(CDOState.CLEAN, Event.DETACH, FAIL); + setTransition(CDOState.CLEAN, Event.READ, IGNORE); + setTransition(CDOState.CLEAN, Event.WRITE, new WriteTransition()); + setTransition(CDOState.CLEAN, Event.COMMIT, FAIL); + setTransition(CDOState.CLEAN, Event.ROLLBACK, FAIL); + setTransition(CDOState.CLEAN, Event.INVALIDATE, new InvalidateTransition()); + setTransition(CDOState.CLEAN, Event.FINALIZE_ATTACH, FAIL); + + setTransition(CDOState.DIRTY, Event.ATTACH, FAIL); + setTransition(CDOState.DIRTY, Event.DETACH, FAIL); + setTransition(CDOState.DIRTY, Event.READ, IGNORE); + setTransition(CDOState.DIRTY, Event.WRITE, IGNORE); + setTransition(CDOState.DIRTY, Event.COMMIT, new CommitTransition()); + setTransition(CDOState.DIRTY, Event.ROLLBACK, FAIL); + setTransition(CDOState.DIRTY, Event.INVALIDATE, FAIL); + setTransition(CDOState.DIRTY, Event.FINALIZE_ATTACH, FAIL); + + setTransition(CDOState.PROXY, Event.ATTACH, new LoadResourceTransition()); + setTransition(CDOState.PROXY, Event.DETACH, new DetachTransition()); + setTransition(CDOState.PROXY, Event.READ, new LoadTransition(false)); + setTransition(CDOState.PROXY, Event.WRITE, new LoadTransition(true)); + setTransition(CDOState.PROXY, Event.COMMIT, FAIL); + setTransition(CDOState.PROXY, Event.ROLLBACK, FAIL); + setTransition(CDOState.PROXY, Event.INVALIDATE, IGNORE); + setTransition(CDOState.PROXY, Event.FINALIZE_ATTACH, IGNORE); + + setTransition(CDOState.CONFLICT, Event.ATTACH, FAIL); + setTransition(CDOState.CONFLICT, Event.DETACH, FAIL); + setTransition(CDOState.CONFLICT, Event.READ, FAIL); + setTransition(CDOState.CONFLICT, Event.WRITE, FAIL); + setTransition(CDOState.CONFLICT, Event.COMMIT, FAIL); + setTransition(CDOState.CONFLICT, Event.ROLLBACK, FAIL); + setTransition(CDOState.CONFLICT, Event.INVALIDATE, FAIL); + setTransition(CDOState.CONFLICT, Event.FINALIZE_ATTACH, FAIL); + } + + private void setTransition(CDOState state, Event event, Transition transition) + { + if (transition == null) + { + throw new IllegalArgumentException("transition == null"); + } + + int stateIndex = state.ordinal(); + int eventIndex = event.ordinal(); + transitions[stateIndex][eventIndex] = transition; + } + + private void processEvent(CDOObjectImpl object, Event event, Object data1, Object data2) + { + CDOState state = object.cdoState(); + int stateIndex = state.ordinal(); + int eventIndex = event.ordinal(); + + Transition transition = transitions[stateIndex][eventIndex]; + transition.execute(object, event, data1, data2); + } + + private static CDOTransactionImpl getTransaction(CDOAdapterImpl adapter) + { + CDOTransactionImpl transaction = adapter.getTransaction(); + if (transaction == null) + { + throw new IllegalStateException("transaction == null"); + } + + return transaction; + } + + /** + * @author Eike Stepper + */ + private enum Event + { + ATTACH, DETACH, READ, WRITE, COMMIT, ROLLBACK, INVALIDATE, FINALIZE_ATTACH + } + + /** + * @author Eike Stepper + */ + private static abstract class Transition + { + public void execute(CDOObjectImpl object, Event event, Object data1, Object data2) + { + if (TRACER.isEnabled()) + { + TRACER.format(traceMessage(), event, object.cdoState(), object); + } + + doExecute(object, event, data1, data2); + } + + protected String traceMessage() + { + return "Processing event {0} in state {1} for {2}"; + } + + protected abstract void doExecute(CDOObjectImpl object, Event event, Object data1, Object data2); + } + + /** + * @author Eike Stepper + */ + private static final class IgnoreTransition extends Transition + { + @Override + protected String traceMessage() + { + return "Ignoring event {0} in state {1} for {2}"; + } + + protected void doExecute(CDOObjectImpl object, Event event, Object data1, Object data2) + { + } + } + + /** + * @author Eike Stepper + */ + private static final class FailTransition extends Transition + { + protected void doExecute(CDOObjectImpl object, Event event, Object data1, Object data2) + { + throw new IllegalStateException("Event " + event + " not allowed in state " + object.cdoState() + " for " + + object); + } + } + + /** + * @author Eike Stepper + */ + private static final class AttachTransition extends Transition + { + protected void doExecute(CDOObjectImpl object, Event event, Object data1, Object data2) + { + CDOResourceImpl resource = (CDOResourceImpl)data1; + CDOAdapterImpl adapter = (CDOAdapterImpl)data2; + CDOTransactionImpl transaction = getTransaction(adapter); + + // Create new revision + CDOID id = CDOIDImpl.create(transaction.getNextTemporaryID()); + CDORevisionImpl revision = new CDORevisionImpl(object.cdoClass(), id); + revision.setVersion(1); + + // Prepare object + object.setID(id); + object.setRevision(revision); + object.setResource(resource); + object.setAdapter(adapter); + object.setState(CDOState.PREPARED_ATTACH); + + // Adjust revision + revision.setResourceID(resource.cdoID()); + + // Register object + adapter.registerObject(object); + transaction.registerNew(object); + + // Prepare content tree + for (EObject content : object.eContents()) + { + if (content instanceof CDOObjectImpl) + { + INSTANCE.processEvent((CDOObjectImpl)content, Event.ATTACH, resource, adapter); + } + } + } + } + + /** + * @author Eike Stepper + */ + private static final class FinalizeAttachTransition extends Transition + { + protected void doExecute(CDOObjectImpl object, Event event, Object data1, Object data2) + { + object.finalizeRevision(); + object.setState(CDOState.NEW); + + // Prepare content tree + for (EObject content : object.eContents()) + { + if (content instanceof CDOObjectImpl) + { + INSTANCE.processEvent((CDOObjectImpl)content, Event.FINALIZE_ATTACH, null, null); + } + } + } + } + + /** + * @author Eike Stepper + */ + private static final class DetachTransition extends Transition + { + protected void doExecute(CDOObjectImpl object, Event event, Object data1, Object data2) + { + // TODO Implement method DetachTransition.execute() + throw new UnsupportedOperationException("Not yet implemented"); + } + } + + /** + * @author Eike Stepper + */ + private static final class CommitTransition extends Transition + { + protected void doExecute(CDOObjectImpl object, Event event, Object data1, Object data2) + { + CDOAdapterImpl adapter = object.cdoAdapter(); + CommitTransactionResult result = (CommitTransactionResult)data1; + Map<CDOID, CDOID> idMappings = result.getIdMappings(); + + // Adjust object + CDOID id = object.cdoID(); + CDOID newID = idMappings.get(id); + if (newID != null) + { + object.setID(newID); + adapter.remapObject(id); + id = newID; + } + + // Adjust revision + CDORevisionImpl revision = object.cdoRevision(); + revision.setID(id); + revision.setCreated(result.getTimeStamp()); + revision.adjustReferences(idMappings); + adapter.getSession().getRevisionManager().addRevision(revision); + + object.setState(CDOState.CLEAN); + } + } + + /** + * @author Eike Stepper + */ + private static final class WriteTransition extends Transition + { + protected void doExecute(CDOObjectImpl object, Event event, Object data1, Object data2) + { + CDORevisionImpl revision = object.copyRevision(); + revision.increaseVersion(); + + CDOAdapterImpl adapter = object.cdoAdapter(); + CDOTransactionImpl transaction = getTransaction(adapter); + transaction.registerDirty(object); + + object.setState(CDOState.DIRTY); + } + } + + /** + * @author Eike Stepper + */ + private static final class InvalidateTransition extends Transition + { + protected void doExecute(CDOObjectImpl object, Event event, Object data1, Object data2) + { + long timeStamp = (Long)data1; + object.cdoRevision().setRevised(timeStamp - 1); + object.setState(CDOState.PROXY); + } + } + + /** + * @author Eike Stepper + */ + private static final class LoadTransition extends Transition + { + private boolean forWrite; + + public LoadTransition(boolean forWrite) + { + this.forWrite = forWrite; + } + + protected void doExecute(CDOObjectImpl object, Event event, Object data1, Object data2) + { + CDOID id = object.cdoID(); + CDOAdapterImpl adapter = object.cdoAdapter(); + CDOViewImpl view = adapter.getView(); + CDORevisionImpl revision = view.resolve(id); + object.setRevision(revision); + object.setState(CDOState.CLEAN); + + if (forWrite) + { + INSTANCE.write(object); + } + } + } + + /** + * @author Eike Stepper + */ + private static final class LoadResourceTransition extends Transition + { + protected void doExecute(CDOObjectImpl object, Event event, Object data1, Object data2) + { + CDOResourceImpl resource = (CDOResourceImpl)data1; + CDOAdapterImpl adapter = (CDOAdapterImpl)data2; + CDOID id = requestID(resource, adapter); + if (id == CDOID.NULL) + { + throw new ServerException("Resource not available: " + resource.getPath()); + } + + // Prepare object + object.setID(id); + // object.setRevision(revision); + object.setResource(resource); + object.setAdapter(adapter); + + // Register object + adapter.registerObject(object); + } + + private CDOID requestID(CDOResourceImpl resource, CDOAdapterImpl adapter) + { + String path = CDOUtil.extractPath(resource.getURI()); + ResourceIDRequest signal = new ResourceIDRequest(adapter.getSession().getChannel(), path); + + try + { + return signal.send(); + } + catch (Exception ex) + { + throw new TransportException(ex); + } + } + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStore.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStore.java new file mode 100644 index 0000000000..45aeaf8186 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStore.java @@ -0,0 +1,452 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.internal.cdo; + +import org.eclipse.emf.cdo.CDOAdapter; +import org.eclipse.emf.cdo.CDOObject; +import org.eclipse.emf.cdo.internal.protocol.model.CDOFeatureImpl; +import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl; +import org.eclipse.emf.cdo.protocol.CDOID; +import org.eclipse.emf.cdo.protocol.util.ImplementationError; + +import org.eclipse.net4j.util.om.trace.ContextTracer; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.InternalEObject; +import org.eclipse.emf.ecore.InternalEObject.EStore; +import org.eclipse.emf.internal.cdo.bundle.CDO; +import org.eclipse.emf.internal.cdo.util.EMFUtil; + +/** + * @author Eike Stepper + */ +public final class CDOStore implements EStore +{ + // @Singleton + public static final CDOStore INSTANCE = new CDOStore(); + + private static final ContextTracer TRACER = new ContextTracer(CDO.DEBUG_OBJECT, CDOStore.class); + + private CDOStore() + { + } + + public InternalEObject getContainer(InternalEObject eObject) + { + CDOObjectImpl cdoObject = (CDOObjectImpl)eObject; + if (TRACER.isEnabled()) + { + TRACER.format("getContainer({0})", cdoObject); + } + + CDORevisionImpl revision = getRevisionForReading(cdoObject); + CDOID id = revision.getContainerID(); + return (InternalEObject)convertToObject(cdoObject.cdoAdapter(), id); + } + + public int getContainingFeatureID(InternalEObject eObject) + { + CDOObjectImpl cdoObject = (CDOObjectImpl)eObject; + if (TRACER.isEnabled()) + { + TRACER.format("getContainingFeatureID({0})", cdoObject); + } + + CDORevisionImpl revision = getRevisionForReading(cdoObject); + return revision.getContainingFeatureID(); + } + + public void setContainer(InternalEObject eObject, InternalEObject newContainer, int newContainerFeatureID) + { + CDOObjectImpl cdoObject = (CDOObjectImpl)eObject; + if (TRACER.isEnabled()) + { + TRACER.format("setContainer({0}, {1}, {2})", cdoObject, newContainer, newContainerFeatureID); + } + + CDOID containerID = (CDOID)convertToID(cdoObject.cdoAdapter(), newContainer); + + CDORevisionImpl revision = getRevisionForWriting(cdoObject); + revision.setContainerID(containerID); + revision.setContainingFeature(newContainerFeatureID); + } + + public EStructuralFeature getContainingFeature(InternalEObject eObject) + { + throw new UnsupportedOperationException("Use getContainingFeatureID() instead"); + } + + public Object get(InternalEObject eObject, EStructuralFeature eFeature, int index) + { + CDOObjectImpl cdoObject = (CDOObjectImpl)eObject; + CDOFeatureImpl cdoFeature = EMFUtil.getCDOFeature(eFeature); + if (TRACER.isEnabled()) + { + TRACER.format("get({0}, {1}, {2})", cdoObject, cdoFeature, index); + } + + CDORevisionImpl revision = getRevisionForReading(cdoObject); + Object result = revision.get(cdoFeature, index); + if (cdoFeature.isReference()) + { + result = convertToObject(cdoObject.cdoAdapter(), result); + } + + return result; + } + + public boolean isSet(InternalEObject eObject, EStructuralFeature eFeature) + { + CDOObjectImpl cdoObject = (CDOObjectImpl)eObject; + CDOFeatureImpl cdoFeature = EMFUtil.getCDOFeature(eFeature); + if (TRACER.isEnabled()) + { + TRACER.format("isSet({0}, {1})", cdoObject, cdoFeature); + } + + CDORevisionImpl revision = getRevisionForReading(cdoObject); + return revision.isSet(cdoFeature); + } + + public int size(InternalEObject eObject, EStructuralFeature eFeature) + { + CDOObjectImpl cdoObject = (CDOObjectImpl)eObject; + CDOFeatureImpl cdoFeature = EMFUtil.getCDOFeature(eFeature); + if (TRACER.isEnabled()) + { + TRACER.format("size({0}, {1})", cdoObject, cdoFeature); + } + + CDORevisionImpl revision = getRevisionForReading(cdoObject); + return revision.size(cdoFeature); + } + + public boolean isEmpty(InternalEObject eObject, EStructuralFeature eFeature) + { + CDOObjectImpl cdoObject = (CDOObjectImpl)eObject; + CDOFeatureImpl cdoFeature = EMFUtil.getCDOFeature(eFeature); + if (TRACER.isEnabled()) + { + TRACER.format("isEmpty({0}, {1})", cdoObject, cdoFeature); + } + + CDORevisionImpl revision = getRevisionForReading(cdoObject); + return revision.isEmpty(cdoFeature); + } + + public boolean contains(InternalEObject eObject, EStructuralFeature eFeature, Object value) + { + CDOObjectImpl cdoObject = (CDOObjectImpl)eObject; + CDOFeatureImpl cdoFeature = EMFUtil.getCDOFeature(eFeature); + if (TRACER.isEnabled()) + { + TRACER.format("contains({0}, {1}, {2})", cdoObject, cdoFeature, value); + } + + if (cdoFeature.isReference()) + { + value = convertToID(cdoObject.cdoAdapter(), value); + } + + CDORevisionImpl revision = getRevisionForReading(cdoObject); + return revision.contains(cdoFeature, value); + } + + public int indexOf(InternalEObject eObject, EStructuralFeature eFeature, Object value) + { + CDOObjectImpl cdoObject = (CDOObjectImpl)eObject; + CDOFeatureImpl cdoFeature = EMFUtil.getCDOFeature(eFeature); + if (TRACER.isEnabled()) + { + TRACER.format("indexOf({0}, {1}, {2})", cdoObject, cdoFeature, value); + } + + if (cdoFeature.isReference()) + { + value = convertToID(cdoObject.cdoAdapter(), value); + } + + CDORevisionImpl revision = getRevisionForReading(cdoObject); + return revision.indexOf(cdoFeature, value); + } + + public int lastIndexOf(InternalEObject eObject, EStructuralFeature eFeature, Object value) + { + CDOObjectImpl cdoObject = (CDOObjectImpl)eObject; + CDOFeatureImpl cdoFeature = EMFUtil.getCDOFeature(eFeature); + if (TRACER.isEnabled()) + { + TRACER.format("lastIndexOf({0}, {1}, {2})", cdoObject, cdoFeature, value); + } + + if (cdoFeature.isReference()) + { + value = convertToID(cdoObject.cdoAdapter(), value); + } + + CDORevisionImpl revision = getRevisionForReading(cdoObject); + return revision.lastIndexOf(cdoFeature, value); + } + + public int hashCode(InternalEObject eObject, EStructuralFeature eFeature) + { + CDOObjectImpl cdoObject = (CDOObjectImpl)eObject; + CDOFeatureImpl cdoFeature = EMFUtil.getCDOFeature(eFeature); + if (TRACER.isEnabled()) + { + TRACER.format("hashCode({0}, {1})", cdoObject, cdoFeature); + } + + CDORevisionImpl revision = getRevisionForReading(cdoObject); + return revision.hashCode(cdoFeature); + } + + public Object[] toArray(InternalEObject eObject, EStructuralFeature eFeature) + { + CDOObjectImpl cdoObject = (CDOObjectImpl)eObject; + CDOFeatureImpl cdoFeature = EMFUtil.getCDOFeature(eFeature); + if (TRACER.isEnabled()) + { + TRACER.format("toArray({0}, {1})", cdoObject, cdoFeature); + } + + CDORevisionImpl revision = getRevisionForReading(cdoObject); + Object[] result = revision.toArray(cdoFeature); + if (cdoFeature.isReference()) + { + for (int i = 0; i < result.length; i++) + { + result[i] = convertToObject(cdoObject.cdoAdapter(), result[i]); + } + } + + return result; + } + + public <T> T[] toArray(InternalEObject eObject, EStructuralFeature eFeature, T[] array) + { + // TODO Implement method CDOStore.toArray() + throw new UnsupportedOperationException("Not yet implemented"); + } + + public Object set(InternalEObject eObject, EStructuralFeature eFeature, int index, Object value) + { + CDOObjectImpl cdoObject = (CDOObjectImpl)eObject; + CDOFeatureImpl cdoFeature = EMFUtil.getCDOFeature(eFeature); + if (TRACER.isEnabled()) + { + TRACER.format("set({0}, {1}, {2}, {3})", cdoObject, cdoFeature, index, value); + } + + if (cdoFeature.isReference()) + { + if (cdoFeature.isContainment()) + { + handleContainmentAdd(cdoObject, cdoFeature, value); + } + + value = convertToID(cdoObject.cdoAdapter(), value); + } + + CDORevisionImpl revision = getRevisionForWriting(cdoObject); + Object result = revision.set(cdoFeature, index, value); + if (cdoFeature.isReference()) + { + result = convertToObject(cdoObject.cdoAdapter(), result); + } + + return result; + } + + public void unset(InternalEObject eObject, EStructuralFeature eFeature) + { + CDOObjectImpl cdoObject = (CDOObjectImpl)eObject; + CDOFeatureImpl cdoFeature = EMFUtil.getCDOFeature(eFeature); + if (TRACER.isEnabled()) + { + TRACER.format("unset({0}, {1})", cdoObject, cdoFeature); + } + + CDORevisionImpl revision = getRevisionForWriting(cdoObject); + revision.unset(cdoFeature); + } + + public void add(InternalEObject eObject, EStructuralFeature eFeature, int index, Object value) + { + CDOObjectImpl cdoObject = (CDOObjectImpl)eObject; + CDOFeatureImpl cdoFeature = EMFUtil.getCDOFeature(eFeature); + if (TRACER.isEnabled()) + { + TRACER.format("add({0}, {1}, {2}, {3})", cdoObject, cdoFeature, index, value); + } + + if (cdoFeature.isReference()) + { + if (cdoFeature.isContainment()) + { + handleContainmentAdd(cdoObject, cdoFeature, value); + } + + value = convertToID(cdoObject.cdoAdapter(), value); + } + + CDORevisionImpl revision = getRevisionForWriting(cdoObject); + revision.add(cdoFeature, index, value); + } + + public Object remove(InternalEObject eObject, EStructuralFeature eFeature, int index) + { + CDOObjectImpl cdoObject = (CDOObjectImpl)eObject; + CDOFeatureImpl cdoFeature = EMFUtil.getCDOFeature(eFeature); + if (TRACER.isEnabled()) + { + TRACER.format("remove({0}, {1}, {2})", cdoObject, cdoFeature, index); + } + + CDORevisionImpl revision = getRevisionForWriting(cdoObject); + Object result = revision.remove(cdoFeature, index); + if (cdoFeature.isReference()) + { + result = convertToObject(cdoObject.cdoAdapter(), result); + } + + return result; + } + + public void clear(InternalEObject eObject, EStructuralFeature eFeature) + { + CDOObjectImpl cdoObject = (CDOObjectImpl)eObject; + CDOFeatureImpl cdoFeature = EMFUtil.getCDOFeature(eFeature); + if (TRACER.isEnabled()) + { + TRACER.format("clear({0}, {1})", cdoObject, cdoFeature); + } + + CDORevisionImpl revision = getRevisionForWriting(cdoObject); + revision.clear(cdoFeature); + } + + public Object move(InternalEObject eObject, EStructuralFeature eFeature, int target, int source) + { + CDOObjectImpl cdoObject = (CDOObjectImpl)eObject; + CDOFeatureImpl cdoFeature = EMFUtil.getCDOFeature(eFeature); + if (TRACER.isEnabled()) + { + TRACER.format("move({0}, {1}, {2}, {3})", cdoObject, cdoFeature, target, source); + } + + CDORevisionImpl revision = getRevisionForWriting(cdoObject); + Object result = revision.move(cdoFeature, target, source); + if (cdoFeature.isReference()) + { + result = convertToObject(cdoObject.cdoAdapter(), result); + } + + return result; + } + + public EObject create(EClass eClass) + { + throw new UnsupportedOperationException("Use the generated factory to create objects"); + } + + @Override + public String toString() + { + return "PersistentStore"; + } + + public static Object convertToID(CDOAdapter adapter, Object potentialObject) + { + if (potentialObject instanceof CDOObject) + { + CDOObject object = (CDOObject)potentialObject; + if (object.cdoAdapter() == adapter) + { + return object.cdoID(); + } + } + + if (TRACER.isEnabled()) + { + TRACER.format("Dangling reference: {0}", potentialObject); + } + + return potentialObject; + } + + /** + * TODO Move to adapter + */ + public static Object convertToObject(CDOAdapter adapter, Object potentialID) + { + if (potentialID instanceof CDOID) + { + if (potentialID == CDOID.NULL) + { + return null; + } + + CDOID id = (CDOID)potentialID; + CDOObject result = ((CDOAdapterImpl)adapter).lookupObject(id); + if (result == null) + { + throw new ImplementationError("ID not registered: " + id); + } + + return result; + } + + return potentialID; + } + + private static CDORevisionImpl getRevisionForReading(CDOObjectImpl cdoObject) + { + CDOStateMachine.INSTANCE.read(cdoObject); + return getRevision(cdoObject); + } + + private static CDORevisionImpl getRevisionForWriting(CDOObjectImpl cdoObject) + { + CDOStateMachine.INSTANCE.write(cdoObject); + return getRevision(cdoObject); + } + + private static CDORevisionImpl getRevision(CDOObjectImpl cdoObject) + { + CDORevisionImpl revision = cdoObject.cdoRevision(); + if (revision == null) + { + throw new IllegalStateException("revision == null"); + } + + return revision; + } + + private static void handleContainmentAdd(CDOObjectImpl cdoObject, CDOFeatureImpl cdoFeature, Object value) + { + CDOObjectImpl container = cdoObject; + CDOObjectImpl contained = (CDOObjectImpl)value; + CDOAdapterImpl containerAdapter = cdoObject.cdoAdapter(); + CDOAdapterImpl containedAdapter = contained.cdoAdapter(); + if (containedAdapter != containerAdapter) + { + if (containedAdapter != null) + { + CDOStateMachine.INSTANCE.detach(contained, contained.cdoResource(), containedAdapter); + } + + CDOStateMachine.INSTANCE.attach(contained, container.cdoResource(), containerAdapter); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java new file mode 100644 index 0000000000..962c4c20a8 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java @@ -0,0 +1,168 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.internal.cdo; + +import org.eclipse.emf.cdo.CDOTransaction; +import org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl; +import org.eclipse.emf.cdo.protocol.CDOID; +import org.eclipse.emf.cdo.protocol.util.ImplementationError; + +import org.eclipse.net4j.util.om.trace.ContextTracer; + +import org.eclipse.emf.internal.cdo.bundle.CDO; +import org.eclipse.emf.internal.cdo.protocol.CommitTransactionRequest; +import org.eclipse.emf.internal.cdo.protocol.CommitTransactionResult; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author Eike Stepper + */ +public class CDOTransactionImpl implements CDOTransaction +{ + private static final ContextTracer TRACER = new ContextTracer(CDO.DEBUG_TRANSCTION, CDOTransactionImpl.class); + + private static final long INITIAL_TEMPORARY_ID = -1L; + + private long nextTemporaryID = INITIAL_TEMPORARY_ID; + + private CDOAdapterImpl adapter; + + private Map<CDOID, CDOResourceImpl> newResources = new HashMap(); + + private Map<CDOID, CDOObjectImpl> newObjects = new HashMap(); + + private Map<CDOID, CDOObjectImpl> dirtyObjects = new HashMap(); + + public CDOTransactionImpl(CDOAdapterImpl adapter) + { + this.adapter = adapter; + } + + public CDOAdapterImpl getAdapter() + { + return adapter; + } + + public Map<CDOID, CDOResourceImpl> getNewResources() + { + return newResources; + } + + public Map<CDOID, CDOObjectImpl> getNewObjects() + { + return newObjects; + } + + public Map<CDOID, CDOObjectImpl> getDirtyObjects() + { + return dirtyObjects; + } + + public long getNextTemporaryID() + { + return nextTemporaryID--; + } + + public void resetTemporaryCDOID() + { + nextTemporaryID = INITIAL_TEMPORARY_ID; + } + + public void commit() + { + if (TRACER.isEnabled()) + { + TRACER.trace("commit()"); + } + + try + { + CDOSessionImpl session = adapter.getSession(); + CommitTransactionRequest signal = new CommitTransactionRequest(session.getChannel(), this); + CommitTransactionResult result = signal.send(); + + postCommit(newResources, result); + postCommit(newObjects, result); + postCommit(dirtyObjects, result); + session.notifyInvalidation(result.getTimeStamp(), dirtyObjects.keySet(), adapter); + + newResources.clear(); + newObjects.clear(); + dirtyObjects.clear(); + nextTemporaryID = INITIAL_TEMPORARY_ID; + } + catch (RuntimeException ex) + { + throw ex; + } + catch (Exception ex) + { + throw new RuntimeException(ex); + } + } + + public void rollback() + { + // TODO Implement method CDOTransactionImpl.rollback() + throw new UnsupportedOperationException("Not yet implemented"); + } + + public void registerNew(CDOObjectImpl object) + { + if (object instanceof CDOResourceImpl) + { + if (TRACER.isEnabled()) + { + TRACER.format("Registering new resource {0}", object); + } + + register(newResources, object); + } + else + { + if (TRACER.isEnabled()) + { + TRACER.format("Registering new object {0}", object); + } + + register(newObjects, object); + } + } + + public void registerDirty(CDOObjectImpl object) + { + if (TRACER.isEnabled()) + { + TRACER.format("Registering dirty object {0}", object); + } + + register(dirtyObjects, object); + } + + private void register(Map map, CDOObjectImpl object) + { + Object old = map.put(object.cdoID(), object); + if (old != null) + { + throw new ImplementationError("Duplicate ID: " + object); + } + } + + private void postCommit(Map objects, CommitTransactionResult result) + { + for (Object object : objects.values()) + { + CDOStateMachine.INSTANCE.commit((CDOObjectImpl)object, result); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java new file mode 100644 index 0000000000..58cfa07d89 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java @@ -0,0 +1,77 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.internal.cdo; + +import org.eclipse.emf.cdo.CDOView; +import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl; +import org.eclipse.emf.cdo.protocol.CDOID; +import org.eclipse.emf.cdo.protocol.revision.CDORevisionResolver; + +import java.text.MessageFormat; +import java.util.Date; + +/** + * @author Eike Stepper + */ +public class CDOViewImpl implements CDOView +{ + private CDOAdapterImpl adapter; + + private long timeStamp; + + public CDOViewImpl(CDOAdapterImpl adapter, long timeStamp) + { + this.adapter = adapter; + this.timeStamp = timeStamp; + } + + public CDOAdapterImpl getAdapter() + { + return adapter; + } + + public long getTimeStamp() + { + return timeStamp; + } + + public boolean isActual() + { + return timeStamp == UNSPECIFIED_DATE; + } + + public boolean isHistorical() + { + return !isActual(); + } + + public CDORevisionImpl resolve(CDOID id) + { + CDORevisionResolver revisionManager = adapter.getSession().getRevisionManager(); + if (isActual()) + { + return (CDORevisionImpl)revisionManager.getActualRevision(id); + } + + return (CDORevisionImpl)revisionManager.getHistoricalRevision(id, timeStamp); + } + + @Override + public String toString() + { + if (isActual()) + { + return "ActualView"; + } + + return MessageFormat.format("HistoricalView({0})", new Date(timeStamp)); + } +} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/ChannelInjector.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/ChannelInjector.java new file mode 100644 index 0000000000..9a09d98d87 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/ChannelInjector.java @@ -0,0 +1,53 @@ +/*************************************************************************** + * Copyright (c) 2004 - 2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.internal.cdo; + +import org.eclipse.net4j.IConnector; +import org.eclipse.net4j.util.container.IElementProcessor; +import org.eclipse.net4j.util.container.IManagedContainer; + +import org.eclipse.emf.common.util.URI; + +import org.eclipse.internal.net4j.ConnectorFactory; + +/** + * @author Eike Stepper + */ +public class ChannelInjector implements IElementProcessor +{ + public ChannelInjector() + { + } + + public Object process(IManagedContainer container, String productGroup, String factoryType, String description, + Object element) + { + if (element instanceof CDOSessionImpl) + { + CDOSessionImpl session = (CDOSessionImpl)element; + if (session.getConnector() == null) + { + session.setConnector(getConnector(container, description)); + } + } + + return element; + } + + protected IConnector getConnector(IManagedContainer container, String description) + { + URI uri = URI.createURI(description); + String factoryType = uri.scheme(); + + String connectorDescription = uri.authority(); + return (IConnector)container.getElement(ConnectorFactory.CONNECTOR_GROUP, factoryType, connectorDescription); + } +} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/bundle/Activator.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/bundle/Activator.java new file mode 100644 index 0000000000..71193a30f7 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/bundle/Activator.java @@ -0,0 +1,55 @@ +package org.eclipse.emf.internal.cdo.bundle; + +import org.eclipse.emf.common.EMFPlugin; +import org.eclipse.emf.common.util.ResourceLocator; +import org.eclipse.emf.internal.cdo.util.EMFUtil; + +import org.osgi.framework.BundleContext; + +public final class Activator extends EMFPlugin +{ + // @Singleton + public static final Activator INSTANCE = new Activator(); + + private static Implementation plugin; + + public Activator() + { + super(new ResourceLocator[] {}); + } + + public ResourceLocator getPluginResourceLocator() + { + return plugin; + } + + public static Implementation getPlugin() + { + return plugin; + } + + public static class Implementation extends EclipsePlugin + { + public Implementation() + { + plugin = this; + } + + @Override + public void start(BundleContext context) throws Exception + { + super.start(context); + CDO.BUNDLE.setBundleContext(context); + EMFUtil.addModelInfos(); + } + + @Override + public void stop(BundleContext context) throws Exception + { + EMFUtil.removeModelInfos(); + plugin = null; + CDO.BUNDLE.setBundleContext(null); + super.stop(context); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/bundle/CDO.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/bundle/CDO.java new file mode 100644 index 0000000000..a2f2f9d16c --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/bundle/CDO.java @@ -0,0 +1,52 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.internal.cdo.bundle; + +import org.eclipse.net4j.util.om.OMBundle; +import org.eclipse.net4j.util.om.OMLogger; +import org.eclipse.net4j.util.om.OMPlatform; +import org.eclipse.net4j.util.om.OMTracer; + +/** + * @author Eike Stepper + */ +public final class CDO +{ + public static final String BUNDLE_ID = "org.eclipse.emf.cdo"; //$NON-NLS-1$ + + public static final OMBundle BUNDLE = OMPlatform.INSTANCE.bundle(BUNDLE_ID, CDO.class); + + public static final OMTracer DEBUG = BUNDLE.tracer("debug"); //$NON-NLS-1$ + + public static final OMTracer DEBUG_UTIL = DEBUG.tracer("util"); //$NON-NLS-1$ + + public static final OMTracer DEBUG_REPOSITORY = DEBUG.tracer("repository"); //$NON-NLS-1$ + + public static final OMTracer DEBUG_SESSION = DEBUG.tracer("session"); //$NON-NLS-1$ + + public static final OMTracer DEBUG_ADAPTER = DEBUG.tracer("adapter"); //$NON-NLS-1$ + + public static final OMTracer DEBUG_VIEW = DEBUG.tracer("view"); //$NON-NLS-1$ + + public static final OMTracer DEBUG_TRANSCTION = DEBUG.tracer("transaction"); //$NON-NLS-1$ + + public static final OMTracer DEBUG_OBJECT = DEBUG.tracer("object"); //$NON-NLS-1$ + + public static final OMTracer DEBUG_RESOURCE = DEBUG.tracer("resource"); //$NON-NLS-1$ + + public static final OMTracer DEBUG_REVISION = DEBUG.tracer("revision"); //$NON-NLS-1$ + + public static final OMLogger LOG = BUNDLE.logger(); + + private CDO() + { + } +} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CDOClientProtocol.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CDOClientProtocol.java new file mode 100644 index 0000000000..f7e026aec4 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CDOClientProtocol.java @@ -0,0 +1,67 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.internal.cdo.protocol; + +import org.eclipse.emf.cdo.protocol.CDOProtocolConstants; + +import org.eclipse.net4j.signal.SignalProtocol; +import org.eclipse.net4j.signal.SignalReactor; + +import org.eclipse.emf.internal.cdo.CDOSessionImpl; + +/** + * @author Eike Stepper + */ +public class CDOClientProtocol extends SignalProtocol +{ + private CDOSessionImpl session; + + public CDOClientProtocol() + { + } + + public String getType() + { + return CDOProtocolConstants.PROTOCOL_NAME; + } + + public CDOSessionImpl getSession() + { + return session; + } + + public void setSession(CDOSessionImpl session) + { + this.session = session; + } + + @Override + protected SignalReactor doCreateSignalReactor(short signalID) + { + switch (signalID) + { + case CDOProtocolConstants.INVALIDATION_SIGNAL: + return new InvalidationIndication(); + } + + return null; + } + + @Override + protected void doBeforeActivate() throws Exception + { + super.doBeforeActivate(); + if (session == null) + { + throw new IllegalStateException("session == null"); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CDOClientProtocolFactory.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CDOClientProtocolFactory.java new file mode 100644 index 0000000000..131b97ec13 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CDOClientProtocolFactory.java @@ -0,0 +1,21 @@ +package org.eclipse.emf.internal.cdo.protocol; + +import org.eclipse.emf.cdo.protocol.CDOProtocolConstants; + +import org.eclipse.internal.net4j.ClientProtocolFactory; + +/** + * @author Eike Stepper + */ +public final class CDOClientProtocolFactory extends ClientProtocolFactory +{ + public CDOClientProtocolFactory() + { + super(CDOProtocolConstants.PROTOCOL_NAME); + } + + public Object create(String description) + { + return new CDOClientProtocol(); + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CDOClientRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CDOClientRequest.java new file mode 100644 index 0000000000..6859a8bcbd --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CDOClientRequest.java @@ -0,0 +1,53 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.internal.cdo.protocol; + +import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionResolverImpl; + +import org.eclipse.net4j.IChannel; +import org.eclipse.net4j.signal.RequestWithConfirmation; + +import org.eclipse.emf.internal.cdo.CDOSessionImpl; + +/** + * @author Eike Stepper + */ +public abstract class CDOClientRequest<RESULT> extends RequestWithConfirmation<RESULT> +{ + private short signalID; + + public CDOClientRequest(IChannel channel, short signalID) + { + super(channel); + this.signalID = signalID; + } + + @Override + protected short getSignalID() + { + return signalID; + } + + protected CDORevisionResolverImpl getRevisionManager() + { + return getSession().getRevisionManager(); + } + + protected CDOSessionImpl getSession() + { + return getProtocol().getSession(); + } + + protected CDOClientProtocol getProtocol() + { + return (CDOClientProtocol)super.getProtocol(); + } +} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java new file mode 100644 index 0000000000..f6d91a5507 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java @@ -0,0 +1,138 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.internal.cdo.protocol; + +import org.eclipse.emf.cdo.internal.protocol.CDOIDImpl; +import org.eclipse.emf.cdo.internal.protocol.bundle.CDOProtocol; +import org.eclipse.emf.cdo.internal.protocol.revision.CDODanglingReferenceConverter; +import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl; +import org.eclipse.emf.cdo.protocol.CDOID; +import org.eclipse.emf.cdo.protocol.CDOProtocolConstants; + +import org.eclipse.net4j.IChannel; +import org.eclipse.net4j.util.om.trace.ContextTracer; +import org.eclipse.net4j.util.stream.ExtendedDataInputStream; +import org.eclipse.net4j.util.stream.ExtendedDataOutputStream; + +import org.eclipse.emf.internal.cdo.CDOObjectImpl; +import org.eclipse.emf.internal.cdo.CDOStore; +import org.eclipse.emf.internal.cdo.CDOTransactionImpl; + +import java.io.IOException; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +/** + * @author Eike Stepper + */ +public class CommitTransactionRequest extends CDOClientRequest<CommitTransactionResult> +{ + private static final ContextTracer PROTOCOL = new ContextTracer(CDOProtocol.DEBUG_PROTOCOL, + CommitTransactionRequest.class); + + private CDOTransactionImpl transaction; + + private CDODanglingReferenceConverter converter; + + public CommitTransactionRequest(IChannel channel, final CDOTransactionImpl transaction) + { + super(channel, CDOProtocolConstants.COMMIT_TRANSACTION_SIGNAL); + this.transaction = transaction; + converter = new CDODanglingReferenceConverter() + { + public CDOID convertToID(Object object) + { + try + { + CDOID id = (CDOID)CDOStore.convertToID(transaction.getAdapter(), object); + if (PROTOCOL.isEnabled()) + { + PROTOCOL.format("Converted dangling reference: {0} --> {1}", object, id); + } + + return id; + } + catch (ClassCastException ex) + { + throw new IllegalStateException("Encountered unconvertable dangling reference during commit: " + object); + } + } + }; + } + + @Override + protected void requesting(ExtendedDataOutputStream out) throws IOException + { + writeNewResources(out); + writeNewObjects(out); + writeDirtyObjects(out); + } + + private void writeNewResources(ExtendedDataOutputStream out) throws IOException + { + if (PROTOCOL.isEnabled()) + { + PROTOCOL.format("Writing {0} new resources", transaction.getNewResources().size()); + } + + writeRevisions(out, transaction.getNewResources().values()); + } + + private void writeNewObjects(ExtendedDataOutputStream out) throws IOException + { + if (PROTOCOL.isEnabled()) + { + PROTOCOL.format("Writing {0} new objects", transaction.getNewObjects().size()); + } + + writeRevisions(out, transaction.getNewObjects().values()); + } + + private void writeDirtyObjects(ExtendedDataOutputStream out) throws IOException + { + if (PROTOCOL.isEnabled()) + { + PROTOCOL.format("Writing {0} dirty objects", transaction.getDirtyObjects().size()); + } + + writeRevisions(out, transaction.getDirtyObjects().values()); + } + + private void writeRevisions(ExtendedDataOutputStream out, Collection objects) throws IOException + { + out.writeInt(objects.size()); + for (Iterator it = objects.iterator(); it.hasNext();) + { + CDOObjectImpl object = (CDOObjectImpl)it.next(); + CDORevisionImpl revision = object.cdoRevision(); + revision.write(out, converter); + } + } + + @Override + protected CommitTransactionResult confirming(ExtendedDataInputStream in) throws IOException + { + long timeStamp = in.readLong(); + + Map<CDOID, CDOID> idMappings = new HashMap(); + int size = in.readInt(); + for (int i = 0; i < size; i++) + { + CDOID oldID = CDOIDImpl.read(in); + CDOID newID = CDOIDImpl.read(in); + idMappings.put(oldID, newID); + } + + return new CommitTransactionResult(timeStamp, idMappings); + } +} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionResult.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionResult.java new file mode 100644 index 0000000000..e6f851343d --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionResult.java @@ -0,0 +1,41 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.internal.cdo.protocol; + +import org.eclipse.emf.cdo.protocol.CDOID; + +import java.util.Map; + +/** + * @author Eike Stepper + */ +public final class CommitTransactionResult +{ + private long timeStamp; + + private Map<CDOID, CDOID> idMappings; + + public CommitTransactionResult(long timeStamp, Map<CDOID, CDOID> idMappings) + { + this.timeStamp = timeStamp; + this.idMappings = idMappings; + } + + public long getTimeStamp() + { + return timeStamp; + } + + public Map<CDOID, CDOID> getIdMappings() + { + return idMappings; + } +} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/InvalidationIndication.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/InvalidationIndication.java new file mode 100644 index 0000000000..d586bb5f53 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/InvalidationIndication.java @@ -0,0 +1,75 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.internal.cdo.protocol; + +import org.eclipse.emf.cdo.internal.protocol.CDOIDImpl; +import org.eclipse.emf.cdo.internal.protocol.bundle.CDOProtocol; +import org.eclipse.emf.cdo.protocol.CDOID; +import org.eclipse.emf.cdo.protocol.CDOProtocolConstants; + +import org.eclipse.net4j.signal.Indication; +import org.eclipse.net4j.util.om.trace.ContextTracer; +import org.eclipse.net4j.util.stream.ExtendedDataInputStream; + +import org.eclipse.emf.internal.cdo.CDOSessionImpl; + +import java.io.IOException; +import java.util.HashSet; +import java.util.Set; + +/** + * @author Eike Stepper + */ +public class InvalidationIndication extends Indication +{ + private static final ContextTracer PROTOCOL = new ContextTracer(CDOProtocol.DEBUG_PROTOCOL, + InvalidationIndication.class); + + public InvalidationIndication() + { + } + + @Override + protected short getSignalID() + { + return CDOProtocolConstants.INVALIDATION_SIGNAL; + } + + @Override + protected void indicating(ExtendedDataInputStream in) throws IOException + { + long timeStamp = in.readLong(); + if (PROTOCOL.isEnabled()) + { + PROTOCOL.format("Read timeStamp: {0,date} {0,time}", timeStamp); + } + + int size = in.readInt(); + if (PROTOCOL.isEnabled()) + { + PROTOCOL.format("Reading {0} IDs", size); + } + + Set<CDOID> dirtyOIDs = new HashSet(); + for (int i = 0; i < size; i++) + { + CDOID dirtyOID = CDOIDImpl.read(in); + dirtyOIDs.add(dirtyOID); + } + + getSession().notifyInvalidation(timeStamp, dirtyOIDs, null); + } + + private CDOSessionImpl getSession() + { + return ((CDOClientProtocol)getProtocol()).getSession(); + } +} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadObjectRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadObjectRequest.java new file mode 100644 index 0000000000..2292cd514b --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadObjectRequest.java @@ -0,0 +1,78 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.internal.cdo.protocol; + +import org.eclipse.emf.cdo.internal.protocol.CDOIDImpl; +import org.eclipse.emf.cdo.internal.protocol.bundle.CDOProtocol; +import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl; +import org.eclipse.emf.cdo.protocol.CDOID; +import org.eclipse.emf.cdo.protocol.CDOProtocolConstants; + +import org.eclipse.net4j.IChannel; +import org.eclipse.net4j.util.om.trace.ContextTracer; +import org.eclipse.net4j.util.stream.ExtendedDataInputStream; +import org.eclipse.net4j.util.stream.ExtendedDataOutputStream; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class LoadObjectRequest extends CDOClientRequest<CDORevisionImpl> +{ + private static final ContextTracer PROTOCOL = new ContextTracer(CDOProtocol.DEBUG_PROTOCOL, LoadObjectRequest.class); + + private CDOID id; + + private boolean historical; + + private long timeStamp; + + public LoadObjectRequest(IChannel channel, CDOID id) + { + super(channel, CDOProtocolConstants.LOAD_OBJECT_SIGNAL); + this.id = id; + } + + public LoadObjectRequest(IChannel channel, CDOID id, long timeStamp) + { + this(channel, id); + this.timeStamp = timeStamp; + historical = true; + } + + @Override + protected void requesting(ExtendedDataOutputStream out) throws IOException + { + if (PROTOCOL.isEnabled()) + { + PROTOCOL.format("Writing ID: {0}", id); + } + + CDOIDImpl.write(out, id); + out.writeBoolean(historical); + if (historical) + { + if (PROTOCOL.isEnabled()) + { + PROTOCOL.format("Writing timeStamp: {0}", timeStamp); + } + + out.writeLong(timeStamp); + } + } + + @Override + protected CDORevisionImpl confirming(ExtendedDataInputStream in) throws IOException + { + return new CDORevisionImpl(in); + } +} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/OpenSessionRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/OpenSessionRequest.java new file mode 100644 index 0000000000..893c2c772a --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/OpenSessionRequest.java @@ -0,0 +1,87 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.internal.cdo.protocol; + +import org.eclipse.emf.cdo.internal.protocol.bundle.CDOProtocol; +import org.eclipse.emf.cdo.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.util.ServerException; + +import org.eclipse.net4j.IChannel; +import org.eclipse.net4j.signal.RequestWithConfirmation; +import org.eclipse.net4j.util.om.trace.ContextTracer; +import org.eclipse.net4j.util.stream.ExtendedDataInputStream; +import org.eclipse.net4j.util.stream.ExtendedDataOutputStream; + +import java.io.IOException; +import java.text.MessageFormat; + +/** + * @author Eike Stepper + */ +public class OpenSessionRequest extends RequestWithConfirmation<OpenSessionResult> +{ + private static final ContextTracer PROTOCOL = new ContextTracer(CDOProtocol.DEBUG_PROTOCOL, OpenSessionRequest.class); + + private String repositoryName; + + public OpenSessionRequest(IChannel channel, String repositoryName) + { + super(channel); + this.repositoryName = repositoryName; + } + + @Override + protected short getSignalID() + { + return CDOProtocolConstants.OPEN_SESSION_SIGNAL; + } + + @Override + protected void requesting(ExtendedDataOutputStream out) throws IOException + { + if (PROTOCOL.isEnabled()) + { + PROTOCOL.format("Writing repositoryName: {0}", repositoryName); + } + + out.writeString(repositoryName); + } + + @Override + protected OpenSessionResult confirming(ExtendedDataInputStream in) throws IOException + { + int sessionID = in.readInt(); + if (sessionID == CDOProtocolConstants.ERROR_REPOSITORY_NOT_FOUND) + { + String msg = MessageFormat.format("Repository {0} not found", repositoryName); + throw new ServerException(msg); + } + + if (sessionID == CDOProtocolConstants.ERROR_NO_SESSION) + { + String msg = MessageFormat.format("Failed to open session for repository {0}", repositoryName); + throw new ServerException(msg); + } + + if (PROTOCOL.isEnabled()) + { + PROTOCOL.format("Read sessionID: {0}", sessionID); + } + + String repositoryUUID = in.readString(); + if (PROTOCOL.isEnabled()) + { + PROTOCOL.format("Read repositoryUUID: {0}", repositoryUUID); + } + + return new OpenSessionResult(sessionID, repositoryUUID); + } +} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/OpenSessionResult.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/OpenSessionResult.java new file mode 100644 index 0000000000..b5d90c4fe8 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/OpenSessionResult.java @@ -0,0 +1,37 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.internal.cdo.protocol; + +/** + * @author Eike Stepper + */ +public final class OpenSessionResult +{ + private int sessionID; + + private String repositoryUUID; + + public OpenSessionResult(int sessionID, String repositoryUUID) + { + this.sessionID = sessionID; + this.repositoryUUID = repositoryUUID; + } + + public int getSessionID() + { + return sessionID; + } + + public String getRepositoryUUID() + { + return repositoryUUID; + } +} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/ResourceIDRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/ResourceIDRequest.java new file mode 100644 index 0000000000..0177389a89 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/ResourceIDRequest.java @@ -0,0 +1,63 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.internal.cdo.protocol; + +import org.eclipse.emf.cdo.internal.protocol.CDOIDImpl; +import org.eclipse.emf.cdo.internal.protocol.bundle.CDOProtocol; +import org.eclipse.emf.cdo.protocol.CDOID; +import org.eclipse.emf.cdo.protocol.CDOProtocolConstants; + +import org.eclipse.net4j.IChannel; +import org.eclipse.net4j.util.om.trace.ContextTracer; +import org.eclipse.net4j.util.stream.ExtendedDataInputStream; +import org.eclipse.net4j.util.stream.ExtendedDataOutputStream; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class ResourceIDRequest extends CDOClientRequest<CDOID> +{ + private static final ContextTracer PROTOCOL = new ContextTracer(CDOProtocol.DEBUG_PROTOCOL, ResourceIDRequest.class); + + private String path; + + public ResourceIDRequest(IChannel channel, String path) + { + super(channel, CDOProtocolConstants.RESOURCE_ID_SIGNAL); + this.path = path; + } + + @Override + protected void requesting(ExtendedDataOutputStream out) throws IOException + { + if (PROTOCOL.isEnabled()) + { + PROTOCOL.format("Writing path: {0}", path); + } + + // TODO Optimize transfer of URIs/paths + out.writeString(path); + } + + @Override + protected CDOID confirming(ExtendedDataInputStream in) throws IOException + { + CDOID id = CDOIDImpl.read(in); + if (PROTOCOL.isEnabled()) + { + PROTOCOL.format("Read ID: {0}", id); + } + + return id; + } +} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/ResourcePathRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/ResourcePathRequest.java new file mode 100644 index 0000000000..9793fe92bf --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/ResourcePathRequest.java @@ -0,0 +1,63 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.internal.cdo.protocol; + +import org.eclipse.emf.cdo.internal.protocol.CDOIDImpl; +import org.eclipse.emf.cdo.internal.protocol.bundle.CDOProtocol; +import org.eclipse.emf.cdo.protocol.CDOID; +import org.eclipse.emf.cdo.protocol.CDOProtocolConstants; + +import org.eclipse.net4j.IChannel; +import org.eclipse.net4j.util.om.trace.ContextTracer; +import org.eclipse.net4j.util.stream.ExtendedDataInputStream; +import org.eclipse.net4j.util.stream.ExtendedDataOutputStream; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class ResourcePathRequest extends CDOClientRequest<String> +{ + private static final ContextTracer PROTOCOL = new ContextTracer(CDOProtocol.DEBUG_PROTOCOL, ResourcePathRequest.class); + + private CDOID id; + + public ResourcePathRequest(IChannel channel, CDOID id) + { + super(channel, CDOProtocolConstants.RESOURCE_PATH_SIGNAL); + this.id = id; + } + + @Override + protected void requesting(ExtendedDataOutputStream out) throws IOException + { + if (PROTOCOL.isEnabled()) + { + PROTOCOL.format("Writing ID: {0}", id); + } + + CDOIDImpl.write(out, id); + } + + @Override + protected String confirming(ExtendedDataInputStream in) throws IOException + { + // TODO Optimize transfer of URIs/paths + String path = in.readString(); + if (PROTOCOL.isEnabled()) + { + PROTOCOL.format("Read path: {0}", path); + } + + return path; + } +} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/EMFUtil.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/EMFUtil.java new file mode 100644 index 0000000000..86652e5b69 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/EMFUtil.java @@ -0,0 +1,340 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.internal.cdo.util; + +import org.eclipse.emf.cdo.eresource.EresourcePackage; +import org.eclipse.emf.cdo.internal.protocol.bundle.CDOProtocol; +import org.eclipse.emf.cdo.internal.protocol.model.CDOClassImpl; +import org.eclipse.emf.cdo.internal.protocol.model.CDOClassRefImpl; +import org.eclipse.emf.cdo.internal.protocol.model.CDOFeatureImpl; +import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl; +import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageManagerImpl; +import org.eclipse.emf.cdo.internal.protocol.model.CDOTypeImpl; +import org.eclipse.emf.cdo.internal.protocol.model.core.CDOCorePackageImpl; +import org.eclipse.emf.cdo.internal.protocol.model.core.CDOObjectClassImpl; +import org.eclipse.emf.cdo.internal.protocol.model.resource.CDOContentsFeatureImpl; +import org.eclipse.emf.cdo.internal.protocol.model.resource.CDOPathFeatureImpl; +import org.eclipse.emf.cdo.internal.protocol.model.resource.CDOResourceClassImpl; +import org.eclipse.emf.cdo.internal.protocol.model.resource.CDOResourcePackageImpl; +import org.eclipse.emf.cdo.protocol.model.CDOClass; +import org.eclipse.emf.cdo.protocol.model.CDOFeature; +import org.eclipse.emf.cdo.protocol.model.CDOPackage; + +import org.eclipse.net4j.util.om.trace.ContextTracer; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EClassifier; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.EcorePackage; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author Eike Stepper + */ +public final class EMFUtil +{ + private static final CDOPackageManagerImpl PACKAGE_MANAGER = CDOPackageManagerImpl.INSTANCE; + + @SuppressWarnings("unused") + private static final ContextTracer TRACER = new ContextTracer(CDOProtocol.DEBUG_MODEL, EMFUtil.class); + + private EMFUtil() + { + } + + public static CDOClassRefImpl createClassRef(EClassifier classifier) + { + if (classifier instanceof EClass) + { + String packageURI = classifier.getEPackage().getNsURI(); + int classifierID = classifier.getClassifierID(); + return new CDOClassRefImpl(packageURI, classifierID); + } + + return null; + } + + public static List<EClass> getPersistentClasses(EPackage ePackage) + { + List<EClass> result = new ArrayList(); + for (EClassifier classifier : ePackage.getEClassifiers()) + { + if (classifier instanceof EClass) + { + result.add((EClass)classifier); + } + } + + return result; + } + + public static List<EStructuralFeature> getPersistentFeatures(EClass eClass) + { + List<EStructuralFeature> result = new ArrayList(); + for (EStructuralFeature feature : eClass.getEStructuralFeatures()) + { + if (!feature.isTransient()) + { + result.add(feature); + } + } + + return result; + } + + public static boolean isMany(EStructuralFeature eFeature) + { + return eFeature.isMany(); + } + + public static boolean isReference(EStructuralFeature eFeature) + { + return eFeature instanceof EReference; + } + + public static boolean isContainment(EStructuralFeature eFeature) + { + if (isReference(eFeature)) + { + EReference ref = (EReference)eFeature; + return ref.isContainment(); + } + + return false; + } + + public static CDOTypeImpl getCDOType(EStructuralFeature eFeature) + { + if (eFeature instanceof EReference) + { + return CDOTypeImpl.OBJECT; + } + + EClassifier classifier = eFeature.getEType(); + if (classifier.getEPackage() == EcorePackage.eINSTANCE) + { + int classifierID = classifier.getClassifierID(); + switch (classifierID) + { + case EcorePackage.EBOOLEAN: + case EcorePackage.EBOOLEAN_OBJECT: + case EcorePackage.EBYTE: + case EcorePackage.EBYTE_OBJECT: + case EcorePackage.ECHAR: + case EcorePackage.ECHARACTER_OBJECT: + case EcorePackage.EDATE: + case EcorePackage.EDOUBLE: + case EcorePackage.EDOUBLE_OBJECT: + case EcorePackage.EFLOAT: + case EcorePackage.EFLOAT_OBJECT: + case EcorePackage.EINT: + case EcorePackage.EINTEGER_OBJECT: + case EcorePackage.ELONG: + case EcorePackage.ELONG_OBJECT: + case EcorePackage.ESHORT: + case EcorePackage.ESHORT_OBJECT: + return CDOTypeImpl.getType(classifierID); + } + } + + return CDOTypeImpl.STRING; + } + + public static CDOPackageImpl getCDOPackage(EPackage ePackage) + { + String packageURI = ePackage.getNsURI(); + CDOPackageImpl cdoPackage = PACKAGE_MANAGER.lookupPackage(packageURI); + if (cdoPackage == null) + { + cdoPackage = convertPackage(ePackage); + PACKAGE_MANAGER.addPackage(cdoPackage); + } + + return cdoPackage; + } + + public static CDOClassImpl getCDOClass(EClass eClass) + { + CDOPackageImpl cdoPackage = getCDOPackage(eClass.getEPackage()); + return cdoPackage.lookupClass(eClass.getClassifierID()); + } + + public static CDOFeatureImpl getCDOFeature(EStructuralFeature eFeature) + { + CDOClassImpl cdoClass = getCDOClass(eFeature.getEContainingClass()); + return cdoClass.lookupFeature(eFeature.getFeatureID()); + } + + public static EPackage getEPackage(CDOPackage cdoPackage) + { + return (EPackage)cdoPackage.getClientInfo(); + } + + public static EClass getEClass(CDOClass cdoClass) + { + return (EClass)cdoClass.getClientInfo(); + } + + public static EStructuralFeature getEFeature(CDOFeature cdoFeature) + { + return (EStructuralFeature)cdoFeature.getClientInfo(); + } + + public static void addModelInfos() + { + // Ecore + CDOCorePackageImpl.INSTANCE.setClientInfo(EcorePackage.eINSTANCE); + CDOObjectClassImpl.INSTANCE.setClientInfo(EcorePackage.eINSTANCE.getEObject()); + + // Eresource + CDOResourcePackageImpl.INSTANCE.setClientInfo(EresourcePackage.eINSTANCE); + CDOResourceClassImpl.INSTANCE.setClientInfo(EresourcePackage.eINSTANCE.getCDOResource()); + CDOContentsFeatureImpl.INSTANCE.setClientInfo(EresourcePackage.eINSTANCE.getCDOResource_Contents()); + CDOPathFeatureImpl.INSTANCE.setClientInfo(EresourcePackage.eINSTANCE.getCDOResource_Path()); + } + + public static void removeModelInfos() + { + // Ecore + CDOCorePackageImpl.INSTANCE.setClientInfo(null); + CDOObjectClassImpl.INSTANCE.setClientInfo(null); + + // Eresource + CDOResourcePackageImpl.INSTANCE.setClientInfo(null); + CDOResourceClassImpl.INSTANCE.setClientInfo(null); + CDOContentsFeatureImpl.INSTANCE.setClientInfo(null); + CDOPathFeatureImpl.INSTANCE.setClientInfo(null); + } + + private static CDOPackageImpl convertPackage(EPackage ePackage) + { + CDOPackageImpl cdoPackage = new CDOPackageImpl(ePackage.getNsURI(), ePackage.getName()); + cdoPackage.setClientInfo(ePackage); + for (EClass eClass : getPersistentClasses(ePackage)) + { + CDOClassImpl cdoClass = convertClass(eClass); + cdoPackage.addClass(cdoClass); + } + + return cdoPackage; + } + + private static CDOClassImpl convertClass(EClass eClass) + { + CDOClassImpl cdoClass = new CDOClassImpl(eClass.getClassifierID(), eClass.getName(), eClass.isAbstract()); + cdoClass.setClientInfo(eClass); + for (EStructuralFeature eFeature : getPersistentFeatures(eClass)) + { + CDOFeatureImpl cdoFeature = convertFeature(eFeature); + cdoClass.addFeature(cdoFeature); + } + + return cdoClass; + } + + private static CDOFeatureImpl convertFeature(EStructuralFeature eFeature) + { + CDOFeatureImpl cdoFeature = // + isReference(eFeature) ? convertReference(eFeature) : convertAttribute(eFeature); + cdoFeature.setClientInfo(eFeature); + return cdoFeature; + } + + private static CDOFeatureImpl convertReference(EStructuralFeature eFeature) + { + int featureID = eFeature.getFeatureID(); + String name = eFeature.getName(); + CDOClassRefImpl classRef = createClassRef(eFeature.getEType()); + boolean many = eFeature.isMany(); + boolean containment = isContainment(eFeature); + return new CDOFeatureImpl(featureID, name, classRef, many, containment); + } + + private static CDOFeatureImpl convertAttribute(EStructuralFeature eFeature) + { + int featureID = eFeature.getFeatureID(); + String name = eFeature.getName(); + CDOTypeImpl type = getCDOType(eFeature); + boolean many = isMany(eFeature); + return new CDOFeatureImpl(featureID, name, type, many); + } + + // public static List<Change> analyzeListDifferences(CDORevisionImpl + // oldRevision, + // CDORevisionImpl newRevision, CDOFeatureImpl feature) + // { + // if (!feature.isMany()) + // { + // throw new IllegalArgumentException("Feature is not many: " + feature); + // } + // + // final List<Object> oldList = (List)oldRevision.getValue(feature); + // final List newList = (List)newRevision.getValue(feature); + // final List<Change> changes = new ArrayList(0); + // + // new ECollections.ListDifferenceAnalyzer() + // { + // @Override + // protected void add(List<Object> oldList, Object newObject, int index) + // { + // changes.add(new AddChange(newObject, index)); + // } + // + // @Override + // protected void remove(List<?> oldList, int index) + // { + // changes.add(new RemoveChange(index)); + // } + // + // @Override + // protected void move(List<?> oldList, int index, int toIndex) + // { + // changes.add(new MoveChange(index, toIndex)); + // } + // }.createListChanges(oldList, newList); + // + // return changes; + // } + // + // /** + // * @author Eike Stepper + // */ + // public static class MoveChange implements FeatureChange + // { + // public MoveChange(int index, int toIndex) + // { + // } + // } + // + // /** + // * @author Eike Stepper + // */ + // public static class RemoveChange implements FeatureChange + // { + // public RemoveChange(int index) + // { + // } + // } + // + // /** + // * @author Eike Stepper + // */ + // public static class AddChange implements FeatureChange + // { + // public AddChange(Object newObject, int index) + // { + // } + // } +} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/LinearPackageHull.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/LinearPackageHull.java new file mode 100644 index 0000000000..1477406267 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/LinearPackageHull.java @@ -0,0 +1,174 @@ +/*************************************************************************** + * Copyright (c) 2004-2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.internal.cdo.util; + +import org.eclipse.emf.cdo.internal.protocol.bundle.CDOProtocol; + +import org.eclipse.net4j.util.om.trace.ContextTracer; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EClassifier; +import org.eclipse.emf.ecore.EOperation; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EParameter; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.internal.cdo.bundle.CDO; + +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +/** + * @author Eike Stepper + */ +public final class LinearPackageHull +{ + private static final ContextTracer TRACER = new ContextTracer(CDOProtocol.DEBUG_MODEL, LinearPackageHull.class); + + private LinearPackageHull() + { + } + + public static Set<EPackage> calculate(Collection<EPackage> ePackages) + { + // Optimize no packages + if (ePackages.isEmpty()) + { + return Collections.EMPTY_SET; + } + + // Optimize 1 package + if (ePackages.size() == 1) + { + return LinearPackageHull.calculate(ePackages.iterator().next()); + } + + // Handle >1 packages + Set<EPackage> result = new HashSet(); + for (EPackage ePackage : ePackages) + { + Set<EPackage> packages = LinearPackageHull.calculate(ePackage); + result.addAll(packages); + } + + return result; + } + + /** + * TODO Handle Ecore generics + */ + public static Set<EPackage> calculate(EPackage ePackage) + { + if (TRACER.isEnabled()) + { + TRACER.trace("Linear package hull for " + ePackage.getNsURI()); + } + + Set<EClass> visited = new HashSet(); + + List<EClassifier> classifiers = ePackage.getEClassifiers(); + for (EClassifier classifier : classifiers) + { + handleEClassifier(classifier, visited); + } + + Set<EPackage> result = new HashSet(); + for (EClass eClass : visited) + { + final EPackage p = eClass.getEPackage(); + if (p != null) + { + if (result.add(p)) + { + if (TRACER.isEnabled()) + { + TRACER.trace("Found package " + p.getNsURI()); + } + } + } + else + { + String msg = "Package == null for " + eClass.getName(); + CDO.LOG.warn(msg); + if (TRACER.isEnabled()) + { + TRACER.trace(msg); + } + } + } + + return result; + } + + private static void handleEClassifier(EClassifier classifier, Set<EClass> visited) + { + if (classifier instanceof EClass) + { + EClass eClass = (EClass)classifier; + if (visited.add(eClass)) + { + if (TRACER.isEnabled()) + { + TRACER.trace("Found class " + eClass.getName()); + } + + handleEStructuralFeatures(eClass.getEStructuralFeatures(), visited); + handleEOperations(eClass.getEOperations(), visited); + handleESuperTypes(eClass.getESuperTypes(), visited); + } + } + } + + private static void handleEStructuralFeatures(List<EStructuralFeature> structuralFeatures, Set<EClass> visited) + { + for (EStructuralFeature structuralFeature : structuralFeatures) + { + handleEClassifier(structuralFeature.getEType(), visited); + } + } + + private static void handleEOperations(List<EOperation> operations, Set<EClass> visited) + { + for (EOperation operation : operations) + { + handleEClassifier(operation.getEType(), visited); + handleEParameters(operation.getEParameters(), visited); + handleEExceptions(operation.getEExceptions(), visited); + } + } + + private static void handleEParameters(List<EParameter> parameters, Set<EClass> visited) + { + for (EParameter parameter : parameters) + { + handleEClassifier(parameter.getEType(), visited); + } + } + + private static void handleEExceptions(List<EClassifier> exceptions, Set<EClass> visited) + { + for (EClassifier exception : exceptions) + { + handleEClassifier(exception, visited); + } + } + + private static void handleESuperTypes(List<EClass> superTypes, Set<EClass> visited) + { + for (EClass superType : superTypes) + { + handleEClassifier(superType, visited); + } + } + +} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/TreeTraversal.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/TreeTraversal.java new file mode 100644 index 0000000000..506d97ecfc --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/TreeTraversal.java @@ -0,0 +1,72 @@ +package org.eclipse.emf.internal.cdo.util; + +import org.eclipse.emf.common.util.TreeIterator; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.internal.cdo.CDOObjectImpl; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author Eike Stepper + */ +@Deprecated +public class TreeTraversal +{ + private CDOObjectImpl root; + + private List<CDOObjectImpl> objects = new ArrayList(); + + public TreeTraversal(CDOObjectImpl root) + { + this.root = root; + collectContents(); + } + + public CDOObjectImpl getRoot() + { + return root; + } + + public List<CDOObjectImpl> getObjects() + { + return objects; + } + + public void traverseTopDown(final ObjectHandler handler) + { + for (int i = 0; i < objects.size(); i++) + { + handler.handleObject(objects.get(i)); + } + } + + public void traverseBottomUp(final ObjectHandler handler) + { + for (int i = objects.size() - 1; i >= 0; i--) + { + handler.handleObject(objects.get(i)); + } + } + + private void collectContents() + { + objects.add(root); + for (TreeIterator<EObject> it = root.eAllContents(); it.hasNext();) + { + Object content = it.next(); + if (content instanceof CDOObjectImpl) + { + objects.add(((CDOObjectImpl)content)); + } + } + } + + /** + * @author Eike Stepper + */ + public interface ObjectHandler + { + public void handleObject(final CDOObjectImpl object); + } +}
\ No newline at end of file |