http://wiki3.caucho.com/index.php?title=Pomegranate&feed=atom&action=historyPomegranate - Revision history2024-03-28T21:27:26ZRevision history for this page on the wikiMediaWiki 1.18.0http://wiki3.caucho.com/index.php?title=Pomegranate&diff=3476&oldid=prevReza: New page: <document> <header> <title>Project Jar Repository</title> <type>contents</type> <description> <p>Library, project, and third-party jars can be stored in <var>project-...2009-12-17T08:24:56Z<p>New page: <document> <header> <title>Project Jar Repository</title> <type>contents</type> <description> <p>Library, project, and third-party jars can be stored in <var>project-...</p>
<p><b>New page</b></p><div><document><br />
<header><br />
<title>Project Jar Repository</title><br />
<type>contents</type><br />
<description><br />
<p>Library, project, and third-party jars can be stored<br />
in <var>project-jars</var> and resolved using a Maven WEB-INF/pom.xml.<br />
Resin will match the correct versions from <var>project-jars</var><br />
and create classloaders for the web-app's libraries.</p><br />
</description><br />
</header><br />
<br />
<body><br />
<br />
<localtoc/><br />
<br />
<s1 title="Overview" version="Resin 4.0.0"><br />
<br />
<p>Because projects use many library jars such as Hibernate, Wicket,<br />
and Apache Commons, Resin provides a repository for the jars, letting<br />
you add all your jars in one directory and select the ones you need<br />
either in the resin-web.xml or in a Maven-standard<br />
WEB-INF/pom.xml file. This repository gives several benefits:<br />
simplifying jar management, resolving versions, reusing jar files, and<br />
reducing .war deployment sizes.</p><br />
<br />
<p>Resin will create internal classloaders for each of your libraries,<br />
and resolve the dependencies of those libraries. So if you use "foo"<br />
and "bar" libraries, and both depend on a "log" library, Resin will<br />
hook up the classes correstly.</p><br />
<br />
<p>At startup, Resin scans all the jars in<br />
<var>${resin.root}/project-jars</var> directory for pom.xml files<br />
and create an internal database of the artifact<br />
names and versions. A WEB-INF/pom.xml will select the jars for use in<br />
the web-app.</p><br />
<br />
<p>For example, your project might use two main libraries: framework-1.0.1.jar<br />
and persistence-2.0.2.jar, and those libraries might<br />
depend on parser-1.1.1.jar, log-3.3.3.jar and parser-2.2.2.jar. Using the<br />
jars is a two step process:</p><br />
<br />
<ol><br />
<li>Add jars to ${resin.root}/project-jars/</li><br />
<li>Add WEB-INF/pom.xml or WEB-INF/resin-web-pre.xml to declare dependencies</li><br />
</ol><br />
<br />
<p>To install, you would add all the jar files<br />
into ${resin.root}/project-jars and then<br />
add a WEB-INF/pom.xml telling Resin that you need the "framework"<br />
artifact with version 1.0.1 and the "persistence" artifact<br />
with version 2.2.2.</p><br />
<br />
<br />
<figure src="project-jars.jpg"/><br />
<br />
<p>Your web-app can declare its dependencies in two ways: a Maven-standard WEB-INF/pom.xml jar, or using a &lt;dependency> tag in the resin-web-pre.xml.<br />
The following example shows that the pom.xml might look like:</p><br />
<br />
<example title="Example: WEB-INF/pom.xml"><br />
&lt;project xmlns="http://maven.apache.org/POM/4.0.0"><br />
&lt;groupId>com.myfoo&lt;/groupId><br />
&lt;artifactId>my-webapp&lt;/artifactId><br />
&lt;version>1.0.0&lt;/version><br />
<br />
&lt;dependencies><br />
&lt;dependency><br />
&lt;groupId>com.foo&lt;/groupId><br />
&lt;artifactId>framework&lt;/artifactId><br />
&lt;version>1.0.1&lt;/version><br />
&lt;/dependency><br />
<br />
&lt;dependency><br />
&lt;groupId>com.bar&lt;/groupId><br />
&lt;artifactId>persistence&lt;/artifactId><br />
&lt;version>2.0.2&lt;/version><br />
&lt;/dependency><br />
&lt;/dependencies><br />
&lt;/project><br />
</example><br />
<br />
<p>You can also declare your dependencies directly in a<br />
WEB-INF/resin-web-pre.xml. The "resin-web-pre" means Resin evaluates<br />
the file before the web.xml and resin-web.xml, so the classes will be<br />
loaded before any servlets need them.</p><br />
<br />
<example title="Example: WEB-INF/resin-web-pre.xml"><br />
&lt;web-app xmlns="http://caucho.com/ns/resin"><br />
<br />
&lt;class-loader><br />
<br />
&lt;dependency org="com.foo" name="framework" version="1.0.1"/><br />
&lt;dependency org="com.bar" name="persistence" version="2.0.2"/><br />
<br />
&lt;/class-loader><br />
<br />
&lt;/web-app><br />
</example><br />
<br />
</s1><br />
<br />
</body><br />
</document></div>Reza