pax_global_header 0000666 0000000 0000000 00000000064 12203204422 0014501 g ustar 00root root 0000000 0000000 52 comment=96885e26448b8c550603d9a8d72c07e023e246ef
plexus-classworlds-plexus-classworlds-2.5.1/ 0000775 0000000 0000000 00000000000 12203204422 0021240 5 ustar 00root root 0000000 0000000 plexus-classworlds-plexus-classworlds-2.5.1/.gitignore 0000664 0000000 0000000 00000000105 12203204422 0023224 0 ustar 00root root 0000000 0000000 target/
.project
.classpath
.settings/
bin
.idea
*.iml
.java-version
plexus-classworlds-plexus-classworlds-2.5.1/LICENSE-2.0.txt 0000664 0000000 0000000 00000026136 12203204422 0023370 0 ustar 00root root 0000000 0000000
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) 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. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
plexus-classworlds-plexus-classworlds-2.5.1/LICENSE.txt 0000664 0000000 0000000 00000003622 12203204422 0023066 0 ustar 00root root 0000000 0000000
/*
$Id$
Copyright 2002 (C) The Codehaus. All Rights Reserved.
Redistribution and use of this software and associated documentation
("Software"), with or without modification, are permitted provided
that the following conditions are met:
1. Redistributions of source code must retain copyright
statements and notices. Redistributions must also contain a
copy of this document.
2. Redistributions in binary form must reproduce the
above copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
3. The name "classworlds" must not be used to endorse or promote
products derived from this Software without prior written
permission of The Codehaus. For written permission, please
contact bob@codehaus.org.
4. Products derived from this Software may not be called "classworlds"
nor may "classworlds" appear in their names without prior written
permission of The Codehaus. "classworlds" is a registered
trademark of The Codehaus.
5. Due credit should be given to The Codehaus.
(http://classworlds.codehaus.org/).
THIS SOFTWARE IS PROVIDED BY THE CODEHAUS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
THE CODEHAUS OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
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 OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE.
*/
plexus-classworlds-plexus-classworlds-2.5.1/pom.xml 0000664 0000000 0000000 00000011621 12203204422 0022556 0 ustar 00root root 0000000 0000000
ClassWorld
.
*
*
* This class most closed maps to the ClassLoader
* role from Java and in facts can provide a ClassLoader
* view of itself using {@link #getClassLoader}.
*
*
* @author bob mcwhirter
* @author Jason van Zyl
*/
public interface ClassRealm
{
String getId();
ClassWorld getWorld();
void importFrom( String realmId, String pkgName )
throws NoSuchRealmException;
void addConstituent( URL constituent );
ClassRealm locateSourceRealm( String className );
void setParent( ClassRealm classRealm );
ClassRealm createChildRealm( String id )
throws DuplicateRealmException;
ClassLoader getClassLoader();
ClassRealm getParent();
URL[] getConstituents();
// ----------------------------------------------------------------------
// Classloading
// ----------------------------------------------------------------------
Class loadClass( String name )
throws ClassNotFoundException;
// ----------------------------------------------------------------------
// Resource handling
// ----------------------------------------------------------------------
URL getResource( String name );
Enumeration findResources( String name )
throws IOException;
InputStream getResourceAsStream( String name );
void display();
}
ClassRealmAdapter.java 0000664 0000000 0000000 00000010741 12203204422 0034734 0 ustar 00root root 0000000 0000000 plexus-classworlds-plexus-classworlds-2.5.1/src/main/java/org/codehaus/classworlds package org.codehaus.classworlds;
/*
* Copyright 2001-2010 Codehaus Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.net.URL;
import java.util.Enumeration;
import java.io.IOException;
import java.io.InputStream;
/**
* An adapter for ClassRealms
*
* @author Andrew Williams
*/
public class ClassRealmAdapter
implements ClassRealm
{
public static ClassRealmAdapter getInstance( org.codehaus.plexus.classworlds.realm.ClassRealm newRealm )
{
ClassRealmAdapter adapter = new ClassRealmAdapter( newRealm );
return adapter;
}
private org.codehaus.plexus.classworlds.realm.ClassRealm realm;
private ClassRealmAdapter( org.codehaus.plexus.classworlds.realm.ClassRealm newRealm )
{
this.realm = newRealm;
}
public String getId()
{
return realm.getId();
}
public ClassWorld getWorld()
{
return ClassWorldAdapter.getInstance( realm.getWorld() );
}
public void importFrom( String realmId,
String pkgName )
throws NoSuchRealmException
{
try
{
realm.importFrom( realmId, pkgName );
}
catch ( org.codehaus.plexus.classworlds.realm.NoSuchRealmException e )
{
throw new NoSuchRealmException( getWorld(), e.getId() );
}
}
public void addConstituent( URL constituent )
{
realm.addURL( constituent );
}
public ClassRealm locateSourceRealm( String className )
{
ClassLoader importLoader = realm.getImportClassLoader( className );
if ( importLoader instanceof org.codehaus.plexus.classworlds.realm.ClassRealm )
{
return ClassRealmAdapter.getInstance( (org.codehaus.plexus.classworlds.realm.ClassRealm) importLoader );
}
else
{
return null;
}
}
public void setParent( ClassRealm classRealm )
{
if ( classRealm != null )
{
realm.setParentRealm( ClassRealmReverseAdapter.getInstance( classRealm ) );
}
}
public ClassRealm createChildRealm( String id )
throws DuplicateRealmException
{
try
{
return ClassRealmAdapter.getInstance( realm.createChildRealm( id ) );
}
catch ( org.codehaus.plexus.classworlds.realm.DuplicateRealmException e )
{
throw new DuplicateRealmException( getWorld(), e.getId() );
}
}
public ClassLoader getClassLoader()
{
return realm;
}
public ClassRealm getParent()
{
return ClassRealmAdapter.getInstance( realm.getParentRealm() );
}
public ClassRealm getParentRealm()
{
return ClassRealmAdapter.getInstance( realm.getParentRealm() );
}
public URL[] getConstituents()
{
return realm.getURLs();
}
public Class loadClass( String name )
throws ClassNotFoundException
{
return realm.loadClass( name );
}
public URL getResource( String name )
{
return realm.getResource( trimLeadingSlash( name ) );
}
public Enumeration findResources( String name )
throws IOException
{
return realm.findResources( trimLeadingSlash( name ) );
}
public InputStream getResourceAsStream( String name )
{
return realm.getResourceAsStream( trimLeadingSlash( name ) );
}
public void display()
{
realm.display();
}
public boolean equals(Object o)
{
if ( !( o instanceof ClassRealm ) )
return false;
return getId().equals( ( (ClassRealm) o ).getId() );
}
/**
* Provides backward-compat with the old classworlds which accepted resource names with leading slashes.
*/
private String trimLeadingSlash( String resource )
{
if ( resource != null && resource.startsWith( "/" ) )
{
return resource.substring( 1 );
}
else
{
return resource;
}
}
}
ClassRealmReverseAdapter.java 0000664 0000000 0000000 00000007657 12203204422 0036304 0 ustar 00root root 0000000 0000000 plexus-classworlds-plexus-classworlds-2.5.1/src/main/java/org/codehaus/classworlds package org.codehaus.classworlds;
/*
* Copyright 2001-2010 Codehaus Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.util.Enumeration;
import java.net.URL;
import java.io.IOException;
import java.io.InputStream;
/**
* A reverse adapter for ClassRealms
*
* @author Andrew Williams
*/
public class ClassRealmReverseAdapter
extends org.codehaus.plexus.classworlds.realm.ClassRealm
{
public static ClassRealmReverseAdapter getInstance( ClassRealm oldRealm )
{
ClassRealmReverseAdapter adapter = new ClassRealmReverseAdapter( oldRealm );
return adapter;
}
private ClassRealm realm;
private ClassRealmReverseAdapter( ClassRealm oldRealm )
{
super( ClassWorldReverseAdapter.getInstance( oldRealm.getWorld() ),
oldRealm.getId(), oldRealm.getClassLoader() );
this.realm = oldRealm;
}
public String getId()
{
return realm.getId();
}
public org.codehaus.plexus.classworlds.ClassWorld getWorld()
{
return ClassWorldReverseAdapter.getInstance( realm.getWorld() );
}
public void importFrom( String realmId,
String pkgName )
throws org.codehaus.plexus.classworlds.realm.NoSuchRealmException
{
try
{
realm.importFrom( realmId, pkgName );
}
catch ( NoSuchRealmException e )
{
throw new org.codehaus.plexus.classworlds.realm.NoSuchRealmException( getWorld(), e.getId() );
}
}
public void addURL( URL constituent )
{
realm.addConstituent( constituent );
}
public org.codehaus.plexus.classworlds.realm.ClassRealm locateSourceRealm( String className )
{
return getInstance( realm.locateSourceRealm(
className ) );
}
public void setParentRealm( org.codehaus.plexus.classworlds.realm.ClassRealm classRealm )
{
realm.setParent( ClassRealmAdapter.getInstance( classRealm ) );
}
public org.codehaus.plexus.classworlds.realm.ClassRealm createChildRealm( String id )
throws org.codehaus.plexus.classworlds.realm.DuplicateRealmException
{
try
{
return getInstance( realm.createChildRealm( id ) );
}
catch ( DuplicateRealmException e )
{
throw new org.codehaus.plexus.classworlds.realm.DuplicateRealmException( getWorld(), e.getId() );
}
}
public ClassLoader getClassLoader()
{
return realm.getClassLoader();
}
public org.codehaus.plexus.classworlds.realm.ClassRealm getParentRealm()
{
return getInstance( realm.getParent() );
}
public URL[] getURLs()
{
return realm.getConstituents();
}
public Class loadClass( String name )
throws ClassNotFoundException
{
return realm.loadClass( name );
}
public URL getResource( String name )
{
return realm.getResource( name );
}
public Enumeration findResources( String name )
throws IOException
{
return realm.findResources( name );
}
public InputStream getResourceAsStream( String name )
{
return realm.getResourceAsStream( name );
}
public void display()
{
realm.display();
}
public boolean equals(Object o)
{
if ( !( o instanceof ClassRealm ) )
return false;
return getId().equals( ( (ClassRealm) o ).getId() );
}
}
plexus-classworlds-plexus-classworlds-2.5.1/src/main/java/org/codehaus/classworlds/ClassWorld.java 0000664 0000000 0000000 00000003750 12203204422 0033543 0 ustar 00root root 0000000 0000000 package org.codehaus.classworlds;
/*
* Copyright 2001-2010 Codehaus Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.util.Collection;
/**
* A compatibility wrapper for org.codehaus.plexus.classworlds.ClassWorld
* provided for legacy code
*
* @author Andrew Williams
*/
public class ClassWorld
{
private ClassWorldAdapter adapter;
public ClassWorld( String realmId,
ClassLoader classLoader )
{
adapter = ClassWorldAdapter.getInstance(
new org.codehaus.plexus.classworlds.ClassWorld( realmId, classLoader ) );
}
public ClassWorld()
{
adapter = ClassWorldAdapter.getInstance(
new org.codehaus.plexus.classworlds.ClassWorld( ) );
}
public ClassWorld( boolean ignore )
{
/* fake */
}
public ClassRealm newRealm( String id )
throws DuplicateRealmException
{
return adapter.newRealm( id );
}
public ClassRealm newRealm( String id,
ClassLoader classLoader )
throws DuplicateRealmException
{
return adapter.newRealm( id, classLoader );
}
public void disposeRealm( String id )
throws NoSuchRealmException
{
adapter.disposeRealm( id );
}
public ClassRealm getRealm( String id )
throws NoSuchRealmException
{
return adapter.getRealm( id );
}
public Collection getRealms()
{
return adapter.getRealms();
}
}
ClassWorldAdapter.java 0000664 0000000 0000000 00000006353 12203204422 0034767 0 ustar 00root root 0000000 0000000 plexus-classworlds-plexus-classworlds-2.5.1/src/main/java/org/codehaus/classworlds package org.codehaus.classworlds;
/*
* Copyright 2001-2010 Codehaus Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.util.Collection;
import java.util.Vector;
import java.util.Iterator;
/**
* An adapter for ClassWorlds
*
* @author Andrew Williams
*/
public class ClassWorldAdapter
extends ClassWorld
{
public static ClassWorldAdapter getInstance( org.codehaus.plexus.classworlds.ClassWorld newWorld )
{
ClassWorldAdapter adapter = new ClassWorldAdapter( newWorld );
return adapter;
}
private org.codehaus.plexus.classworlds.ClassWorld world;
private ClassWorldAdapter( org.codehaus.plexus.classworlds.ClassWorld newWorld )
{
super( false );
this.world = newWorld;
}
public ClassRealm newRealm( String id )
throws DuplicateRealmException
{
try
{
return ClassRealmAdapter.getInstance( world.newRealm( id ) );
}
catch ( org.codehaus.plexus.classworlds.realm.DuplicateRealmException e )
{
throw new DuplicateRealmException( this, e.getId() );
}
}
public ClassRealm newRealm( String id,
ClassLoader classLoader )
throws DuplicateRealmException
{
try
{
return ClassRealmAdapter.getInstance( world.newRealm( id,
classLoader ) );
}
catch ( org.codehaus.plexus.classworlds.realm.DuplicateRealmException e )
{
throw new DuplicateRealmException( this, e.getId() );
}
}
public void disposeRealm( String id )
throws NoSuchRealmException
{
try
{
world.disposeRealm( id );
}
catch ( org.codehaus.plexus.classworlds.realm.NoSuchRealmException e )
{
throw new NoSuchRealmException( this, e.getId() );
}
}
public ClassRealm getRealm( String id )
throws NoSuchRealmException
{
try
{
return ClassRealmAdapter.getInstance( world.getRealm( id ) );
}
catch ( org.codehaus.plexus.classworlds.realm.NoSuchRealmException e )
{
throw new NoSuchRealmException( this, e.getId() );
}
}
public Collection getRealms()
{
Collection realms = world.getRealms();
Vector ret = new Vector();
Iterator it = realms.iterator();
while ( it.hasNext() )
{
org.codehaus.plexus.classworlds.realm.ClassRealm realm =
(org.codehaus.plexus.classworlds.realm.ClassRealm) it.next();
ret.add( ClassRealmAdapter.getInstance( realm ) );
}
return ret;
}
}
ClassWorldException.java 0000664 0000000 0000000 00000006351 12203204422 0035343 0 ustar 00root root 0000000 0000000 plexus-classworlds-plexus-classworlds-2.5.1/src/main/java/org/codehaus/classworlds package org.codehaus.classworlds;
/*
Copyright 2002 (C) The Werken Company. All Rights Reserved.
Redistribution and use of this software and associated documentation
("Software"), with or without modification, are permitted provided
that the following conditions are met:
1. Redistributions of source code must retain copyright
statements and notices. Redistributions must also contain a
copy of this document.
2. Redistributions in binary form must reproduce the
above copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
3. The name "classworlds" must not be used to endorse or promote
products derived from this Software without prior written
permission of The Werken Company. For written permission,
please contact bob@werken.com.
4. Products derived from this Software may not be called "classworlds"
nor may "classworlds" appear in their names without prior written
permission of The Werken Company. "classworlds" is a registered
trademark of The Werken Company.
5. Due credit should be given to The Werken Company.
(http://classworlds.werken.com/).
THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
THE WERKEN COMPANY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
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 OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* Base exception for ClassWorld
errors.
*
* @author bob mcwhirter
*/
public class ClassWorldException extends Exception
{
// ------------------------------------------------------------
// Instance members
// ------------------------------------------------------------
/**
* The world.
*/
private ClassWorld world;
// ------------------------------------------------------------
// Constructors
// ------------------------------------------------------------
/**
* Construct.
*
* @param world The world.
*/
public ClassWorldException( final ClassWorld world )
{
this.world = world;
}
/**
* Construct.
*
* @param world The world.
* @param msg The detail message.
*/
public ClassWorldException( final ClassWorld world, final String msg )
{
super( msg );
this.world = world;
}
// ------------------------------------------------------------
// Instance methods
// ------------------------------------------------------------
/**
* Retrieve the world.
*
* @return The world.
*/
public ClassWorld getWorld()
{
return this.world;
}
}
ClassWorldReverseAdapter.java 0000664 0000000 0000000 00000007203 12203204422 0036316 0 ustar 00root root 0000000 0000000 plexus-classworlds-plexus-classworlds-2.5.1/src/main/java/org/codehaus/classworlds package org.codehaus.classworlds;
/*
* Copyright 2001-2010 Codehaus Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.util.HashMap;
import java.util.Collection;
import java.util.Vector;
import java.util.Iterator;
/**
* A reverse adapter for ClassWorlds
*
* @author Andrew Williams
*/
public class ClassWorldReverseAdapter
extends org.codehaus.plexus.classworlds.ClassWorld
{
private static HashMap instances = new HashMap();
public static ClassWorldReverseAdapter getInstance( ClassWorld oldWorld )
{
if ( instances.containsKey( oldWorld ) )
return (ClassWorldReverseAdapter) instances.get( oldWorld );
ClassWorldReverseAdapter adapter = new ClassWorldReverseAdapter( oldWorld );
instances.put( oldWorld, adapter );
return adapter;
}
private ClassWorld world;
private ClassWorldReverseAdapter( ClassWorld newWorld )
{
super();
this.world = newWorld;
}
public org.codehaus.plexus.classworlds.realm.ClassRealm newRealm( String id )
throws org.codehaus.plexus.classworlds.realm.DuplicateRealmException
{
try
{
return ClassRealmReverseAdapter.getInstance( world.newRealm( id ) );
}
catch ( DuplicateRealmException e )
{
throw new org.codehaus.plexus.classworlds.realm.DuplicateRealmException( this, e.getId() );
}
}
public org.codehaus.plexus.classworlds.realm.ClassRealm newRealm( String id,
ClassLoader classLoader )
throws org.codehaus.plexus.classworlds.realm.DuplicateRealmException
{
try
{
return ClassRealmReverseAdapter.getInstance( world.newRealm( id,
classLoader ) );
}
catch ( DuplicateRealmException e )
{
throw new org.codehaus.plexus.classworlds.realm.DuplicateRealmException( this, e.getId() );
}
}
public void disposeRealm( String id )
throws org.codehaus.plexus.classworlds.realm.NoSuchRealmException
{
try
{
world.disposeRealm( id );
}
catch ( NoSuchRealmException e )
{
throw new org.codehaus.plexus.classworlds.realm.NoSuchRealmException( this, e.getId() );
}
}
public org.codehaus.plexus.classworlds.realm.ClassRealm getRealm( String id )
throws org.codehaus.plexus.classworlds.realm.NoSuchRealmException
{
try
{
return ClassRealmReverseAdapter.getInstance( world.getRealm( id ) );
}
catch ( NoSuchRealmException e )
{
throw new org.codehaus.plexus.classworlds.realm.NoSuchRealmException( this, e.getId() );
}
}
public Collection getRealms()
{
Collection realms = world.getRealms();
Vector ret = new Vector();
Iterator it = realms.iterator();
while ( it.hasNext() )
{
ClassRealm realm = (ClassRealm) it.next();
ret.add( ClassRealmReverseAdapter.getInstance( realm ) );
}
return ret;
}
}
ConfigurationException.java 0000664 0000000 0000000 00000005233 12203204422 0036073 0 ustar 00root root 0000000 0000000 plexus-classworlds-plexus-classworlds-2.5.1/src/main/java/org/codehaus/classworlds package org.codehaus.classworlds;
/*
Copyright 2002 (C) The Werken Company. All Rights Reserved.
Redistribution and use of this software and associated documentation
("Software"), with or without modification, are permitted provided
that the following conditions are met:
1. Redistributions of source code must retain copyright
statements and notices. Redistributions must also contain a
copy of this document.
2. Redistributions in binary form must reproduce the
above copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
3. The name "classworlds" must not be used to endorse or promote
products derived from this Software without prior written
permission of The Werken Company. For written permission,
please contact bob@werken.com.
4. Products derived from this Software may not be called "classworlds"
nor may "classworlds" appear in their names without prior written
permission of The Werken Company. "classworlds" is a registered
trademark of The Werken Company.
5. Due credit should be given to The Werken Company.
(http://classworlds.werken.com/).
THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
THE WERKEN COMPANY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
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 OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* Indicates an error during Launcher
configuration.
*
* @author bob mcwhirter
*/
public class ConfigurationException extends Exception
{
/**
* Construct.
*
* @param msg The message.
*/
public ConfigurationException( String msg )
{
super( msg );
}
/**
* Construct.
*
* @param msg The message.
* @param lineNo The number of configuraton line where the problem occured.
* @param line The configuration line where the problem occured.
*/
public ConfigurationException( String msg, int lineNo, String line )
{
super( msg + " (" + lineNo + "): " + line );
}
}
plexus-classworlds-plexus-classworlds-2.5.1/src/main/java/org/codehaus/classworlds/Configurator.java0000664 0000000 0000000 00000010751 12203204422 0034127 0 ustar 00root root 0000000 0000000 package org.codehaus.classworlds;
/*
* Copyright 2001-2010 Codehaus Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
/**
* A compatibility wrapper for org.codehaus.plexus.classworlds.launcher.Configurator
* provided for legacy code
*
* @author Andrew Williams
*/
public class Configurator
{
private ConfiguratorAdapter config;
/** Construct.
*
* @param launcher The launcher to configure.
*/
public Configurator( Launcher launcher )
{
config = ConfiguratorAdapter.getInstance(
new org.codehaus.plexus.classworlds.launcher.Configurator( launcher ), launcher );
}
/** Construct.
*
* @param world The classWorld to configure.
*/
public Configurator( ClassWorld world )
{
config = ConfiguratorAdapter.getInstance(
new org.codehaus.plexus.classworlds.launcher.Configurator(
ClassWorldReverseAdapter.getInstance( world ) ), world );
}
/** set world.
* this setter is provided so you can use the same configurator to configure several "worlds"
*
* @param world The classWorld to configure.
*/
public void setClassWorld( ClassWorld world )
{
config.setClassWorld( world );
}
/**
* Configure from a file.
*
* @param is The config input stream
* @throws IOException If an error occurs reading the config file.
* @throws MalformedURLException If the config file contains invalid URLs.
* @throws ConfigurationException If the config file is corrupt.
* @throws DuplicateRealmException If the config file defines two realms with the same id.
* @throws NoSuchRealmException If the config file defines a main entry point in
* a non-existent realm.
*/
public void configure( InputStream is )
throws IOException, MalformedURLException, ConfigurationException, DuplicateRealmException, NoSuchRealmException
{
config.configureAdapter( is );
}
/**
* Associate parent realms with their children.
*/
protected void associateRealms()
{
config.associateRealms();
}
/**
* Load a glob into the specified classloader.
*
* @param line The path configuration line.
* @param realm The realm to populate
* @throws MalformedURLException If the line does not represent
* a valid path element.
* @throws FileNotFoundException If the line does not represent
* a valid path element in the filesystem.
*/
protected void loadGlob( String line, ClassRealm realm )
throws MalformedURLException, FileNotFoundException
{
loadGlob( line, realm, false );
}
/**
* Load a glob into the specified classloader.
*
* @param line The path configuration line.
* @param realm The realm to populate
* @param optionally Whether the path is optional or required
* @throws MalformedURLException If the line does not represent
* a valid path element.
* @throws FileNotFoundException If the line does not represent
* a valid path element in the filesystem.
*/
protected void loadGlob( String line, ClassRealm realm, boolean optionally )
throws MalformedURLException, FileNotFoundException
{
config.loadGlob( line, realm, optionally );
}
/**
* Filter a string for system properties.
*
* @param text The text to filter.
* @return The filtered text.
* @throws ConfigurationException If the property does not
* exist or if there is a syntax error.
*/
protected String filter( String text )
throws ConfigurationException
{
return config.filter( text );
}
}
ConfiguratorAdapter.java 0000664 0000000 0000000 00000005465 12203204422 0035357 0 ustar 00root root 0000000 0000000 plexus-classworlds-plexus-classworlds-2.5.1/src/main/java/org/codehaus/classworlds package org.codehaus.classworlds;
/*
* Copyright 2001-2010 Codehaus Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.io.InputStream;
import java.io.IOException;
import java.net.MalformedURLException;
/**
* Created by IntelliJ IDEA.
*
* @uthor: Andrew Williams
* @since: Nov 25, 2006
*/
public class ConfiguratorAdapter
extends Configurator
{
public static ConfiguratorAdapter getInstance( org.codehaus.plexus.classworlds.launcher.Configurator newConfig,
Launcher launcher )
{
ConfiguratorAdapter adapter = new ConfiguratorAdapter( newConfig, launcher );
return adapter;
}
public static ConfiguratorAdapter getInstance( org.codehaus.plexus.classworlds.launcher.Configurator newConfig,
ClassWorld world )
{
ConfiguratorAdapter adapter = new ConfiguratorAdapter( newConfig, world );
return adapter;
}
private org.codehaus.plexus.classworlds.launcher.Configurator config;
private ConfiguratorAdapter( org.codehaus.plexus.classworlds.launcher.Configurator config, Launcher launcher )
{
super( launcher );
this.config = config;
}
private ConfiguratorAdapter( org.codehaus.plexus.classworlds.launcher.Configurator config, ClassWorld world )
{
super( world );
this.config = config;
}
public void associateRealms()
{
config.associateRealms();
}
public void configureAdapter( InputStream is )
throws IOException, MalformedURLException, ConfigurationException, DuplicateRealmException, NoSuchRealmException
{
try
{
config.configure( is );
}
catch ( org.codehaus.plexus.classworlds.launcher.ConfigurationException e )
{
throw new ConfigurationException( e.getMessage() );
}
catch ( org.codehaus.plexus.classworlds.realm.DuplicateRealmException e )
{
throw new DuplicateRealmException( ClassWorldAdapter.getInstance( e.getWorld() ), e.getId() );
}
catch ( org.codehaus.plexus.classworlds.realm.NoSuchRealmException e )
{
throw new NoSuchRealmException( ClassWorldAdapter.getInstance( e.getWorld() ), e.getId() );
}
}
}
DefaultClassRealm.java 0000664 0000000 0000000 00000011167 12203204422 0034743 0 ustar 00root root 0000000 0000000 plexus-classworlds-plexus-classworlds-2.5.1/src/main/java/org/codehaus/classworlds package org.codehaus.classworlds;
/*
* Copyright 2001-2010 Codehaus Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* A compatibility wrapper for org.codehaus.plexus.classworlds.realm.ClassRealm
* provided for legacy code
*
* @author Andrew Williams
* @version $Id$
*/
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Enumeration;
public class DefaultClassRealm
implements ClassRealm
{
private ClassRealmAdapter adapter;
public DefaultClassRealm( ClassWorld world, String id )
{
this( world, id, null );
}
public DefaultClassRealm( ClassWorld world, String id, ClassLoader foreignClassLoader )
{
this.adapter = ClassRealmAdapter.getInstance(
new org.codehaus.plexus.classworlds.realm.ClassRealm(
ClassWorldReverseAdapter.getInstance( world ), id, foreignClassLoader ) );
}
public URL[] getConstituents()
{
return adapter.getConstituents();
}
public ClassRealm getParent()
{
return adapter.getParentRealm();
}
public void setParent( ClassRealm parent )
{
adapter.setParent( parent );
}
public String getId()
{
return adapter.getId();
}
public ClassWorld getWorld()
{
return adapter.getWorld();
}
public void importFrom( String realmId, String packageName )
throws NoSuchRealmException
{
adapter.importFrom( realmId, packageName );
}
public void addConstituent( URL constituent )
{
adapter.addConstituent( constituent );
}
/**
* Adds a byte[] class definition as a constituent for locating classes.
* Currently uses BytesURLStreamHandler to hold a reference of the byte[] in memory.
* This ensures we have a unifed URL resource model for all constituents.
* The code to cache to disk is commented out - maybe a property to choose which method?
*
* @param constituent class name
* @param b the class definition as a byte[]
*/
public void addConstituent(String constituent,
byte[] b) throws ClassNotFoundException
{
try
{
File path, file;
if (constituent.lastIndexOf('.') != -1)
{
path = new File("byteclass/" + constituent.substring(0, constituent.lastIndexOf('.') + 1).replace('.', File.separatorChar));
file = new File(path, constituent.substring(constituent.lastIndexOf('.') + 1) + ".class");
}
else
{
path = new File("byteclass/");
file = new File(path, constituent + ".class");
}
addConstituent( new URL( null,
file.toURI().toURL().toExternalForm(),
new BytesURLStreamHandler(b) ) );
}
catch (java.io.IOException e)
{
throw new ClassNotFoundException( "Couldn't load byte stream.", e );
}
}
public ClassRealm locateSourceRealm( String classname )
{
return adapter.locateSourceRealm( classname );
}
public ClassLoader getClassLoader()
{
return adapter.getClassLoader();
}
public ClassRealm createChildRealm( String id )
throws DuplicateRealmException
{
return adapter.createChildRealm( id );
}
// ----------------------------------------------------------------------
// ClassLoader API
// ----------------------------------------------------------------------
public Class loadClass( String name )
throws ClassNotFoundException
{
return adapter.loadClass( name );
}
public URL getResource( String name )
{
return adapter.getResource( name );
}
public InputStream getResourceAsStream( String name )
{
return adapter.getResourceAsStream( name );
}
public Enumeration findResources(String name)
throws IOException
{
return adapter.findResources( name );
}
public void display()
{
adapter.display();
}
}
DuplicateRealmException.java 0000664 0000000 0000000 00000006226 12203204422 0036162 0 ustar 00root root 0000000 0000000 plexus-classworlds-plexus-classworlds-2.5.1/src/main/java/org/codehaus/classworlds package org.codehaus.classworlds;
/*
Copyright 2002 (C) The Werken Company. All Rights Reserved.
Redistribution and use of this software and associated documentation
("Software"), with or without modification, are permitted provided
that the following conditions are met:
1. Redistributions of source code must retain copyright
statements and notices. Redistributions must also contain a
copy of this document.
2. Redistributions in binary form must reproduce the
above copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
3. The name "classworlds" must not be used to endorse or promote
products derived from this Software without prior written
permission of The Werken Company. For written permission,
please contact bob@werken.com.
4. Products derived from this Software may not be called "classworlds"
nor may "classworlds" appear in their names without prior written
permission of The Werken Company. "classworlds" is a registered
trademark of The Werken Company.
5. Due credit should be given to The Werken Company.
(http://classworlds.werken.com/).
THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
THE WERKEN COMPANY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
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 OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* Indicates an attempt to add a ClassRealm
to a
* ClassWorld
with a duplicate id.
*
* @author bob mcwhirter
*/
public class DuplicateRealmException extends ClassWorldException
{
// ------------------------------------------------------------
// Instance members
// ------------------------------------------------------------
/**
* The realm id.
*/
private String id;
// ------------------------------------------------------------
// Constructors
// ------------------------------------------------------------
/**
* Construct.
*
* @param world The world.
* @param id The realm id.
*/
public DuplicateRealmException( ClassWorld world,
String id )
{
super( world, id );
this.id = id;
}
// ------------------------------------------------------------
// Instance methods
// ------------------------------------------------------------
/**
* Retrieve the duplicate realm id.
*
* @return The id.
*/
public String getId()
{
return this.id;
}
}
plexus-classworlds-plexus-classworlds-2.5.1/src/main/java/org/codehaus/classworlds/Launcher.java 0000664 0000000 0000000 00000003526 12203204422 0033230 0 ustar 00root root 0000000 0000000 package org.codehaus.classworlds;
/*
* Copyright 2001-2010 Codehaus Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* A compatibility wrapper for org.codehaus.plexus.classworlds.launcher.Launcher
* provided for legacy code
*
* @author Andrew Williams
*/
public class Launcher
extends org.codehaus.plexus.classworlds.launcher.Launcher
{
public Launcher()
{
}
// ------------------------------------------------------------
// Class methods
// ------------------------------------------------------------
/**
* Launch the launcher from the command line.
* Will exit using System.exit with an exit code of 0 for success, 100 if there was an unknown exception,
* or some other code for an application error.
*
* @param args The application command-line arguments.
*/
public static void main( String[] args )
{
org.codehaus.plexus.classworlds.launcher.Launcher.main( args );
}
/**
* Launch the launcher.
*
* @param args The application command-line arguments.
* @return an integer exit code
* @throws Exception If an error occurs.
*/
public static int mainWithExitCode( String[] args )
throws Exception
{
return org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode( args );
}
}
NoSuchRealmException.java 0000664 0000000 0000000 00000006221 12203204422 0035442 0 ustar 00root root 0000000 0000000 plexus-classworlds-plexus-classworlds-2.5.1/src/main/java/org/codehaus/classworlds package org.codehaus.classworlds;
/*
Copyright 2002 (C) The Werken Company. All Rights Reserved.
Redistribution and use of this software and associated documentation
("Software"), with or without modification, are permitted provided
that the following conditions are met:
1. Redistributions of source code must retain copyright
statements and notices. Redistributions must also contain a
copy of this document.
2. Redistributions in binary form must reproduce the
above copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
3. The name "classworlds" must not be used to endorse or promote
products derived from this Software without prior written
permission of The Werken Company. For written permission,
please contact bob@werken.com.
4. Products derived from this Software may not be called "classworlds"
nor may "classworlds" appear in their names without prior written
permission of The Werken Company. "classworlds" is a registered
trademark of The Werken Company.
5. Due credit should be given to The Werken Company.
(http://classworlds.werken.com/).
THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
THE WERKEN COMPANY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
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 OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* Indicates an attempt to retrieve a ClassRealm
from a
* ClassWorld
with an invalid id.
*
* @author bob mcwhirter
*/
public class NoSuchRealmException extends ClassWorldException
{
// ------------------------------------------------------------
// Instance members
// ------------------------------------------------------------
/**
* The realm id.
*/
private String id;
// ------------------------------------------------------------
// Constructors
// ------------------------------------------------------------
/**
* Construct.
*
* @param world The world.
* @param id The realm id.
*/
public NoSuchRealmException( ClassWorld world,
String id )
{
super( world, id );
this.id = id;
}
// ------------------------------------------------------------
// Instance methods
// ------------------------------------------------------------
/**
* Retrieve the invalid realm id.
*
* @return The id.
*/
public String getId()
{
return this.id;
}
}
plexus-classworlds-plexus-classworlds-2.5.1/src/main/java/org/codehaus/plexus/ 0000775 0000000 0000000 00000000000 12203204422 0027576 5 ustar 00root root 0000000 0000000 plexus-classworlds-plexus-classworlds-2.5.1/src/main/java/org/codehaus/plexus/classworlds/ 0000775 0000000 0000000 00000000000 12203204422 0032136 5 ustar 00root root 0000000 0000000 ClassWorld.java 0000664 0000000 0000000 00000010201 12203204422 0034771 0 ustar 00root root 0000000 0000000 plexus-classworlds-plexus-classworlds-2.5.1/src/main/java/org/codehaus/plexus/classworlds package org.codehaus.plexus.classworlds;
/*
* Copyright 2001-2006 Codehaus Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.io.Closeable;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.codehaus.plexus.classworlds.realm.ClassRealm;
import org.codehaus.plexus.classworlds.realm.DuplicateRealmException;
import org.codehaus.plexus.classworlds.realm.NoSuchRealmException;
/**
* A collection of ClassRealm
s, indexed by id.
*
* @author bob mcwhirter
*/
public class ClassWorld
{
private MapClassWorld
errors.
*
* @author bob mcwhirter
*/
public class ClassWorldException
extends Exception
{
// ------------------------------------------------------------
// Instance members
// ------------------------------------------------------------
/**
* The world.
*/
private ClassWorld world;
// ------------------------------------------------------------
// Constructors
// ------------------------------------------------------------
/**
* Construct.
*
* @param world The world.
*/
public ClassWorldException( final ClassWorld world )
{
this.world = world;
}
/**
* Construct.
*
* @param world The world.
* @param msg The detail message.
*/
public ClassWorldException( final ClassWorld world, final String msg )
{
super( msg );
this.world = world;
}
// ------------------------------------------------------------
// Instance methods
// ------------------------------------------------------------
/**
* Retrieve the world.
*
* @return The world.
*/
public ClassWorld getWorld()
{
return this.world;
}
}
ClassWorldListener.java 0000664 0000000 0000000 00000001525 12203204422 0036510 0 ustar 00root root 0000000 0000000 plexus-classworlds-plexus-classworlds-2.5.1/src/main/java/org/codehaus/plexus/classworlds package org.codehaus.plexus.classworlds;
/*
* Copyright 2001-2006 Codehaus Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.codehaus.plexus.classworlds.realm.ClassRealm;
public interface ClassWorldListener
{
public void realmCreated( ClassRealm realm );
public void realmDisposed( ClassRealm realm );
}
UrlUtils.java 0000664 0000000 0000000 00000003522 12203204422 0034507 0 ustar 00root root 0000000 0000000 plexus-classworlds-plexus-classworlds-2.5.1/src/main/java/org/codehaus/plexus/classworlds package org.codehaus.plexus.classworlds;
/*
* Copyright 2001-2006 Codehaus Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.net.URL;
import java.net.URLClassLoader;
import java.util.HashSet;
import java.util.Set;
/**
* @author Jason van Zyl
*/
public class UrlUtils
{
public static String normalizeUrlPath( String name )
{
if ( name.startsWith( "/" ) )
{
name = name.substring( 1 );
}
// Looking for org/codehaus/werkflow/personality/basic/../common/core-idioms.xml
// | i |
// +-------+ remove
//
int i = name.indexOf( "/.." );
// Can't be at the beginning because we have no root to refer to so
// we start at 1.
if ( i > 0 )
{
int j = name.lastIndexOf( "/", i - 1 );
if ( j >= 0 )
{
name = name.substring( 0, j ) + name.substring( i + 3 );
}
}
return name;
}
public static SetLauncher
configuration.
*
* @author bob mcwhirter
*/
public class ConfigurationException
extends Exception
{
/**
* Construct.
*
* @param msg The message.
*/
public ConfigurationException( String msg )
{
super( msg );
}
/**
* Construct.
*
* @param msg The message.
* @param lineNo The number of configuraton line where the problem occured.
* @param line The configuration line where the problem occured.
*/
public ConfigurationException( String msg, int lineNo, String line )
{
super( msg + " (" + lineNo + "): " + line );
}
protected ConfigurationException( Exception cause )
{
super( cause );
}
}
ConfigurationHandler.java 0000664 0000000 0000000 00000003745 12203204422 0040641 0 ustar 00root root 0000000 0000000 plexus-classworlds-plexus-classworlds-2.5.1/src/main/java/org/codehaus/plexus/classworlds/launcher package org.codehaus.plexus.classworlds.launcher;
/*
* Copyright 2001-2006 Codehaus Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.io.File;
import java.net.URL;
import org.codehaus.plexus.classworlds.realm.DuplicateRealmException;
import org.codehaus.plexus.classworlds.realm.NoSuchRealmException;
/**
* Receive notification of the logical content of launcher configuration, independently from parsing.
*
* @author Igor Fedorenko
*/
public interface ConfigurationHandler
{
/**
* Define the main class name
* @param mainClassName the main class name
* @param mainRealmName the main realm from which the main class is loaded
*/
void setAppMain( String mainClassName, String mainRealmName );
/**
* Define a new realm
* @param realmName the new realm name
* @throws DuplicateRealmException
*/
void addRealm( String realmName )
throws DuplicateRealmException;
/**
* Add an import specification from a realm
* @param relamName the realm name
* @param importSpec the import specification
* @throws NoSuchRealmException
*/
void addImportFrom( String relamName, String importSpec )
throws NoSuchRealmException;
/**
* Add a file to the realm
* @param file the file to load content from
*/
void addLoadFile( File file );
/**
* Add an URL to the realm
* @param url the url to load content from
*/
void addLoadURL( URL url );
}
ConfigurationParser.java 0000664 0000000 0000000 00000032152 12203204422 0040512 0 ustar 00root root 0000000 0000000 plexus-classworlds-plexus-classworlds-2.5.1/src/main/java/org/codehaus/plexus/classworlds/launcher package org.codehaus.plexus.classworlds.launcher;
/*
* Copyright 2001-2006 Codehaus Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FilenameFilter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Properties;
import org.codehaus.plexus.classworlds.realm.DuplicateRealmException;
import org.codehaus.plexus.classworlds.realm.NoSuchRealmException;
/**
* Event based launcher configuration parser, delegating effective configuration handling to ConfigurationHandler.
*
* @author bob mcwhirter
* @author Jason van Zyl
* @author Igor Fedorenko
* @see ConfigurationHandler
*/
public class ConfigurationParser
{
public static final String MAIN_PREFIX = "main is";
public static final String SET_PREFIX = "set";
public static final String IMPORT_PREFIX = "import";
public static final String LOAD_PREFIX = "load";
/**
* Optionally spec prefix.
*/
public static final String OPTIONALLY_PREFIX = "optionally";
private ConfigurationHandler handler;
private Properties systemProperties;
public ConfigurationParser( ConfigurationHandler handler, Properties systemProperties )
{
this.handler = handler;
this.systemProperties = systemProperties;
}
/**
* Parse launcher configuration file and send events to the handler.
*/
public void parse( InputStream is )
throws IOException, ConfigurationException, DuplicateRealmException, NoSuchRealmException
{
BufferedReader reader = new BufferedReader( new InputStreamReader( is, "UTF-8" ) );
String line = null;
int lineNo = 0;
boolean mainSet = false;
String curRealm = null;
while ( true )
{
line = reader.readLine();
if ( line == null )
{
break;
}
++lineNo;
line = line.trim();
if ( canIgnore( line ) )
{
continue;
}
if ( line.startsWith( MAIN_PREFIX ) )
{
if ( mainSet )
{
throw new ConfigurationException( "Duplicate main configuration", lineNo, line );
}
String conf = line.substring( MAIN_PREFIX.length() ).trim();
int fromLoc = conf.indexOf( "from" );
if ( fromLoc < 0 )
{
throw new ConfigurationException( "Missing from clause", lineNo, line );
}
String mainClassName = filter( conf.substring( 0, fromLoc ).trim() );
String mainRealmName = filter( conf.substring( fromLoc + 4 ).trim() );
this.handler.setAppMain( mainClassName, mainRealmName );
mainSet = true;
}
else if ( line.startsWith( SET_PREFIX ) )
{
String conf = line.substring( SET_PREFIX.length() ).trim();
int usingLoc = conf.indexOf( " using" ) + 1;
String property = null;
String propertiesFileName = null;
if ( usingLoc > 0 )
{
property = conf.substring( 0, usingLoc ).trim();
propertiesFileName = filter( conf.substring( usingLoc + 5 ).trim() );
conf = propertiesFileName;
}
String defaultValue = null;
int defaultLoc = conf.indexOf( " default" ) + 1;
if ( defaultLoc > 0 )
{
defaultValue = filter( conf.substring( defaultLoc + 7 ).trim() );
if ( property == null )
{
property = conf.substring( 0, defaultLoc ).trim();
}
else
{
propertiesFileName = conf.substring( 0, defaultLoc ).trim();
}
}
String value = systemProperties.getProperty( property );
if ( value != null )
{
continue;
}
if ( propertiesFileName != null )
{
File propertiesFile = new File( propertiesFileName );
if ( propertiesFile.exists() )
{
Properties properties = new Properties();
try
{
properties.load( new FileInputStream( propertiesFileName ) );
value = properties.getProperty( property );
}
catch ( Exception e )
{
// do nothing
}
}
}
if ( value == null && defaultValue != null )
{
value = defaultValue;
}
if ( value != null )
{
value = filter( value );
systemProperties.setProperty( property, value );
}
}
else if ( line.startsWith( "[" ) )
{
int rbrack = line.indexOf( "]" );
if ( rbrack < 0 )
{
throw new ConfigurationException( "Invalid realm specifier", lineNo, line );
}
String realmName = line.substring( 1, rbrack );
handler.addRealm( realmName );
curRealm = realmName;
}
else if ( line.startsWith( IMPORT_PREFIX ) )
{
if ( curRealm == null )
{
throw new ConfigurationException( "Unhandled import", lineNo, line );
}
String conf = line.substring( IMPORT_PREFIX.length() ).trim();
int fromLoc = conf.indexOf( "from" );
if ( fromLoc < 0 )
{
throw new ConfigurationException( "Missing from clause", lineNo, line );
}
String importSpec = conf.substring( 0, fromLoc ).trim();
String relamName = conf.substring( fromLoc + 4 ).trim();
handler.addImportFrom( relamName, importSpec );
}
else if ( line.startsWith( LOAD_PREFIX ) )
{
String constituent = line.substring( LOAD_PREFIX.length() ).trim();
constituent = filter( constituent );
if ( constituent.indexOf( "*" ) >= 0 )
{
loadGlob( constituent, false /*not optionally*/ );
}
else
{
File file = new File( constituent );
if ( file.exists() )
{
handler.addLoadFile( file );
}
else
{
try
{
handler.addLoadURL( new URL( constituent ) );
}
catch ( MalformedURLException e )
{
throw new FileNotFoundException( constituent );
}
}
}
}
else if ( line.startsWith( OPTIONALLY_PREFIX ) )
{
String constituent = line.substring( OPTIONALLY_PREFIX.length() ).trim();
constituent = filter( constituent );
if ( constituent.indexOf( "*" ) >= 0 )
{
loadGlob( constituent, true /*optionally*/ );
}
else
{
File file = new File( constituent );
if ( file.exists() )
{
handler.addLoadFile( file );
}
else
{
try
{
handler.addLoadURL( new URL( constituent ) );
}
catch ( MalformedURLException e )
{
// swallow
}
}
}
}
else
{
throw new ConfigurationException( "Unhandled configuration", lineNo, line );
}
}
reader.close();
}
/**
* Load a glob into the specified classloader.
*
* @param line The path configuration line.
* @param optionally Whether the path is optional or required
* @throws MalformedURLException If the line does not represent
* a valid path element.
* @throws FileNotFoundException If the line does not represent
* a valid path element in the filesystem.
* @throws ConfigurationException
*/
protected void loadGlob( String line,
boolean optionally )
throws MalformedURLException, FileNotFoundException, ConfigurationException
{
File globFile = new File( line );
File dir = globFile.getParentFile();
if ( !dir.exists() )
{
if ( optionally )
{
return;
}
else
{
throw new FileNotFoundException( dir.toString() );
}
}
String localName = globFile.getName();
int starLoc = localName.indexOf( "*" );
final String prefix = localName.substring( 0, starLoc );
final String suffix = localName.substring( starLoc + 1 );
File[] matches = dir.listFiles( new FilenameFilter()
{
public boolean accept( File dir,
String name )
{
if ( !name.startsWith( prefix ) )
{
return false;
}
if ( !name.endsWith( suffix ) )
{
return false;
}
return true;
}
} );
for ( File match : matches )
{
handler.addLoadFile( match );
}
}
/**
* Filter a string for system properties.
*
* @param text The text to filter.
* @return The filtered text.
* @throws ConfigurationException If the property does not
* exist or if there is a syntax error.
*/
protected String filter( String text )
throws ConfigurationException
{
String result = "";
int cur = 0;
int textLen = text.length();
int propStart = -1;
int propStop = -1;
String propName = null;
String propValue = null;
while ( cur < textLen )
{
propStart = text.indexOf( "${", cur );
if ( propStart < 0 )
{
break;
}
result += text.substring( cur, propStart );
propStop = text.indexOf( "}", propStart );
if ( propStop < 0 )
{
throw new ConfigurationException( "Unterminated property: " + text.substring( propStart ) );
}
propName = text.substring( propStart + 2, propStop );
propValue = systemProperties.getProperty( propName );
/* do our best if we are not running from surefire */
if ( propName.equals( "basedir" ) && ( propValue == null || propValue.equals( "" ) ) )
{
propValue = ( new File( "" ) ).getAbsolutePath();
}
if ( propValue == null )
{
throw new ConfigurationException( "No such property: " + propName );
}
result += propValue;
cur = propStop + 1;
}
result += text.substring( cur );
return result;
}
/**
* Determine if a line can be ignored because it is
* a comment or simply blank.
*
* @param line The line to test.
* @return true
if the line is ignorable,
* otherwise false
.
*/
private boolean canIgnore( String line )
{
return ( line.length() == 0 || line.startsWith( "#" ) );
}
}
Configurator.java 0000664 0000000 0000000 00000014534 12203204422 0037174 0 ustar 00root root 0000000 0000000 plexus-classworlds-plexus-classworlds-2.5.1/src/main/java/org/codehaus/plexus/classworlds/launcher package org.codehaus.plexus.classworlds.launcher;
/*
* Copyright 2001-2006 Codehaus Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.codehaus.plexus.classworlds.ClassWorld;
import org.codehaus.plexus.classworlds.realm.ClassRealm;
import org.codehaus.plexus.classworlds.realm.DuplicateRealmException;
import org.codehaus.plexus.classworlds.realm.NoSuchRealmException;
/**
* Launcher
configurator.
*
* @author bob mcwhirter
* @author Jason van Zyl
*/
public class Configurator implements ConfigurationHandler
{
/**
* The launcher to configure.
*/
private Launcher launcher;
private ClassWorld world;
/**
* Processed Realms.
*/
private MapClassRealm
s
* from a configuration file and the launching of the application's main
* method from the correct class loaded through the correct classloader.
*
*
*
* The path to the configuration file is specified using the classworlds.conf
* system property, typically specified using the -D
switch to
* java
.
*
*
* @author bob mcwhirter
*/
public class Launcher
{
protected static final String CLASSWORLDS_CONF = "classworlds.conf";
protected static final String UBERJAR_CONF_DIR = "WORLDS-INF/conf/";
protected ClassLoader systemClassLoader;
protected String mainClassName;
protected String mainRealmName;
protected ClassWorld world;
private int exitCode = 0;
public Launcher()
{
this.systemClassLoader = Thread.currentThread().getContextClassLoader();
}
public void setSystemClassLoader( ClassLoader loader )
{
this.systemClassLoader = loader;
}
public ClassLoader getSystemClassLoader()
{
return this.systemClassLoader;
}
public int getExitCode()
{
return exitCode;
}
public void setAppMain( String mainClassName,
String mainRealmName )
{
this.mainClassName = mainClassName;
this.mainRealmName = mainRealmName;
}
public String getMainRealmName()
{
return this.mainRealmName;
}
public String getMainClassName()
{
return this.mainClassName;
}
public void setWorld( ClassWorld world )
{
this.world = world;
}
public ClassWorld getWorld()
{
return this.world;
}
/**
* Configure from a file.
*
* @param is The config input stream.
* @throws IOException If an error occurs reading the config file.
* @throws MalformedURLException If the config file contains invalid URLs.
* @throws ConfigurationException If the config file is corrupt.
* @throws org.codehaus.plexus.classworlds.realm.DuplicateRealmException If the config file defines two realms
* with the same id.
* @throws org.codehaus.plexus.classworlds.realm.NoSuchRealmException If the config file defines a main entry
* point in a non-existent realm.
*/
public void configure( InputStream is )
throws IOException, ConfigurationException, DuplicateRealmException, NoSuchRealmException
{
Configurator configurator = new Configurator( this );
configurator.configure( is );
}
/**
* Retrieve the main entry class.
*
* @return The main entry class.
* @throws ClassNotFoundException If the class cannot be found.
* @throws NoSuchRealmException If the specified main entry realm does not exist.
*/
public Class> getMainClass()
throws ClassNotFoundException, NoSuchRealmException
{
return getMainRealm().loadClass( getMainClassName() );
}
/**
* Retrieve the main entry realm.
*
* @return The main entry realm.
* @throws NoSuchRealmException If the specified main entry realm does not exist.
*/
public ClassRealm getMainRealm()
throws NoSuchRealmException
{
return getWorld().getRealm( getMainRealmName() );
}
/**
* Retrieve the enhanced main entry method.
*
* @return The enhanced main entry method.
* @throws ClassNotFoundException If the main entry class cannot be found.
* @throws NoSuchMethodException If the main entry method cannot be found.
* @throws NoSuchRealmException If the main entry realm cannot be found.
*/
protected Method getEnhancedMainMethod()
throws ClassNotFoundException, NoSuchMethodException, NoSuchRealmException
{
Class> cwClass = getMainRealm().loadClass( ClassWorld.class.getName() );
Method m = getMainClass().getMethod( "main", new Class[]{String[].class, cwClass} );
int modifiers = m.getModifiers();
if ( Modifier.isStatic( modifiers ) && Modifier.isPublic( modifiers ) )
{
if ( m.getReturnType() == Integer.TYPE || m.getReturnType() == Void.TYPE )
{
return m;
}
}
throw new NoSuchMethodException( "public static void main(String[] args, ClassWorld world)" );
}
/**
* Retrieve the main entry method.
*
* @return The main entry method.
* @throws ClassNotFoundException If the main entry class cannot be found.
* @throws NoSuchMethodException If the main entry method cannot be found.
* @throws NoSuchRealmException If the main entry realm cannot be found.
*/
protected Method getMainMethod()
throws ClassNotFoundException, NoSuchMethodException, NoSuchRealmException
{
Method m = getMainClass().getMethod( "main", new Class[]{String[].class} );
int modifiers = m.getModifiers();
if ( Modifier.isStatic( modifiers ) && Modifier.isPublic( modifiers ) )
{
if ( m.getReturnType() == Integer.TYPE || m.getReturnType() == Void.TYPE )
{
return m;
}
}
throw new NoSuchMethodException( "public static void main(String[] args) in " + getMainClass() );
}
/**
* Launch the application.
*
* @param args The application args.
* @throws ClassNotFoundException If the main entry class cannot be found.
* @throws IllegalAccessException If the method cannot be accessed.
* @throws InvocationTargetException If the target of the invokation is invalid.
* @throws NoSuchMethodException If the main entry method cannot be found.
* @throws NoSuchRealmException If the main entry realm cannot be found.
*/
public void launch( String[] args )
throws ClassNotFoundException, IllegalAccessException, InvocationTargetException, NoSuchMethodException,
NoSuchRealmException
{
try
{
launchEnhanced( args );
return;
}
catch ( NoSuchMethodException e )
{
// ignore
}
launchStandard( args );
}
/**
* Attempt to launch the application through the enhanced main method.
*
*
* This will seek a method with the exact signature of:
*
*
* * public static void main(String[] args, ClassWorld world) ** * @param args The application args. * @throws ClassNotFoundException If the main entry class cannot be found. * @throws IllegalAccessException If the method cannot be accessed. * @throws InvocationTargetException If the target of the invokation is * invalid. * @throws NoSuchMethodException If the main entry method cannot be found. * @throws NoSuchRealmException If the main entry realm cannot be found. */ protected void launchEnhanced( String[] args ) throws ClassNotFoundException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, NoSuchRealmException { ClassRealm mainRealm = getMainRealm(); Class> mainClass = getMainClass(); Method mainMethod = getEnhancedMainMethod(); ClassLoader cl = mainRealm; // ---------------------------------------------------------------------- // This is what the classloader for the main realm looks like when we // boot from the command line: // ---------------------------------------------------------------------- // [ AppLauncher$AppClassLoader ] : $CLASSPATH envar // ^ // | // | // [ AppLauncher$ExtClassLoader ] : ${java.home}/jre/lib/ext/*.jar // ^ // | // | // [ Strategy ] // ---------------------------------------------------------------------- Thread.currentThread().setContextClassLoader( cl ); Object ret = mainMethod.invoke( mainClass, new Object[]{args, getWorld()} ); if ( ret instanceof Integer ) { exitCode = ( (Integer) ret ).intValue(); } Thread.currentThread().setContextClassLoader( systemClassLoader ); } /** * Attempt to launch the application through the standard main method. * * * This will seek a method with the exact signature of: * * *
* public static void main(String[] args) ** * @param args The application args. * @throws ClassNotFoundException If the main entry class cannot be found. * @throws IllegalAccessException If the method cannot be accessed. * @throws InvocationTargetException If the target of the invokation is * invalid. * @throws NoSuchMethodException If the main entry method cannot be found. * @throws NoSuchRealmException If the main entry realm cannot be found. */ protected void launchStandard( String[] args ) throws ClassNotFoundException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, NoSuchRealmException { ClassRealm mainRealm = getMainRealm(); Class> mainClass = getMainClass(); Method mainMethod = getMainMethod(); Thread.currentThread().setContextClassLoader( mainRealm ); Object ret = mainMethod.invoke( mainClass, new Object[]{args} ); if ( ret instanceof Integer ) { exitCode = ( (Integer) ret ).intValue(); } Thread.currentThread().setContextClassLoader( systemClassLoader ); } // ------------------------------------------------------------ // Class methods // ------------------------------------------------------------ /** * Launch the launcher from the command line. * Will exit using System.exit with an exit code of 0 for success, 100 if there was an unknown exception, * or some other code for an application error. * * @param args The application command-line arguments. */ public static void main( String[] args ) { try { int exitCode = mainWithExitCode( args ); System.exit( exitCode ); } catch ( Exception e ) { e.printStackTrace(); System.exit( 100 ); } } /** * Launch the launcher. * * @param args The application command-line arguments. * @return an integer exit code * @throws Exception If an error occurs. */ public static int mainWithExitCode( String[] args ) throws Exception { String classworldsConf = System.getProperty( CLASSWORLDS_CONF ); InputStream is; Launcher launcher = new Launcher(); ClassLoader cl = Thread.currentThread().getContextClassLoader(); launcher.setSystemClassLoader( cl ); if ( classworldsConf != null ) { is = new FileInputStream( classworldsConf ); } else { if ( "true".equals( System.getProperty( "classworlds.bootstrapped" ) ) ) { is = cl.getResourceAsStream( UBERJAR_CONF_DIR + CLASSWORLDS_CONF ); } else { is = cl.getResourceAsStream( CLASSWORLDS_CONF ); } } if ( is == null ) { throw new Exception( "classworlds configuration not specified nor found in the classpath" ); } launcher.configure( is ); is.close(); try { launcher.launch( args ); } catch ( InvocationTargetException e ) { ClassRealm realm = launcher.getWorld().getRealm( launcher.getMainRealmName() ); URL[] constituents = realm.getURLs(); System.out.println( "---------------------------------------------------" ); for ( int i = 0; i < constituents.length; i++ ) { System.out.println( "constituent[" + i + "]: " + constituents[i] ); } System.out.println( "---------------------------------------------------" ); // Decode ITE (if we can) Throwable t = e.getTargetException(); if ( t instanceof Exception ) { throw (Exception) t; } if ( t instanceof Error ) { throw (Error) t; } // Else just toss the ITE throw e; } return launcher.getExitCode(); } } plexus-classworlds-plexus-classworlds-2.5.1/src/main/java/org/codehaus/plexus/classworlds/realm/ 0000775 0000000 0000000 00000000000 12203204422 0033236 5 ustar 00root root 0000000 0000000 ClassRealm.java 0000664 0000000 0000000 00000034204 12203204422 0036053 0 ustar 00root root 0000000 0000000 plexus-classworlds-plexus-classworlds-2.5.1/src/main/java/org/codehaus/plexus/classworlds/realm package org.codehaus.plexus.classworlds.realm; /* * Copyright 2001-2006 Codehaus Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import org.codehaus.plexus.classworlds.ClassWorld; import org.codehaus.plexus.classworlds.strategy.Strategy; import org.codehaus.plexus.classworlds.strategy.StrategyFactory; import java.io.Closeable; import java.io.IOException; import java.io.PrintStream; import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; import java.util.Collection; import java.util.Collections; import java.util.Enumeration; import java.util.HashSet; import java.util.LinkedHashSet; import java.util.SortedSet; import java.util.TreeSet; /** * The class loading gateway. Each class realm has access to a base class loader, imports form zero or more other class * loaders, an optional parent class loader and of course its own class path. When queried for a class/resource, a class * realm will always query its base class loader first before it delegates to a pluggable strategy. The strategy in turn * controls the order in which imported class loaders, the parent class loader and the realm itself are searched. The * base class loader is assumed to be capable of loading of the bootstrap classes. * * @author bob mcwhirter * @author Jason van Zyl */ public class ClassRealm extends URLClassLoader { private ClassWorld world; private String id; private SortedSet
null
.
* @param id The identifier for this realm, must not be null
.
* @param baseClassLoader The base class loader for this realm, may be null
to use the bootstrap class
* loader.
*/
public ClassRealm( ClassWorld world, String id, ClassLoader baseClassLoader )
{
super( new URL[0], baseClassLoader );
this.world = world;
this.id = id;
foreignImports = new TreeSetClassRealm
to a
* ClassWorld
with a duplicate id.
*
* @author bob mcwhirter
*/
public class DuplicateRealmException
extends ClassWorldException
{
// ------------------------------------------------------------
// Instance members
// ------------------------------------------------------------
/**
* The realm id.
*/
private String id;
// ------------------------------------------------------------
// Constructors
// ------------------------------------------------------------
/**
* Construct.
*
* @param world The world.
* @param id The realm id.
*/
public DuplicateRealmException( ClassWorld world, String id )
{
super( world, id );
this.id = id;
}
// ------------------------------------------------------------
// Instance methods
// ------------------------------------------------------------
/**
* Retrieve the duplicate realm id.
*
* @return The id.
*/
public String getId()
{
return this.id;
}
}
Entry.java 0000664 0000000 0000000 00000014766 12203204422 0035141 0 ustar 00root root 0000000 0000000 plexus-classworlds-plexus-classworlds-2.5.1/src/main/java/org/codehaus/plexus/classworlds/realm package org.codehaus.plexus.classworlds.realm;
/*
* Copyright 2001-2006 Codehaus Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Import description entry.
*
* @author bob mcwhirter
*/
class Entry
implements Comparablenull
.
* @return true
if this entry matches the
* classname, otherwise false
.
*/
boolean matches( String name )
{
String pkg = getPackageName();
if ( pkg.endsWith( ".*" ) )
{
String pkgName;
if ( name.indexOf( '/' ) < 0 )
{
// a binary class name, e.g. java.lang.Object
int index = name.lastIndexOf( '.' );
pkgName = ( index < 0 ) ? "" : name.substring( 0, index );
}
else
{
// a resource name, e.g. java/lang/Object.class
int index = name.lastIndexOf( '/' );
pkgName = ( index < 0 ) ? "" : name.substring( 0, index ).replace( '/', '.' );
}
return pkgName.length() == pkg.length() - 2 && pkg.regionMatches( 0, pkgName, 0, pkgName.length() );
}
else if ( pkg.length() > 0 )
{
if ( name.indexOf( '/' ) < 0 )
{
// a binary class name, e.g. java.lang.Object
if ( name.startsWith( pkg ) )
{
if ( name.length() == pkg.length() )
{
// exact match of class name
return true;
}
else if ( name.charAt( pkg.length() ) == '.' )
{
// prefix match of package name
return true;
}
else if ( name.charAt( pkg.length() ) == '$' )
{
// prefix match of enclosing type
return true;
}
}
}
else
{
// a resource name, e.g. java/lang/Object.class
if ( name.equals( pkg ) )
{
// exact match of resource name
return true;
}
pkg = pkg.replace( '.', '/' );
if ( name.startsWith( pkg ) && name.length() > pkg.length() )
{
if ( name.charAt( pkg.length() ) == '/' )
{
// prefix match of package directory
return true;
}
else if ( name.charAt( pkg.length() ) == '$' )
{
// prefix match of nested class file
return true;
}
else if ( name.length() == pkg.length() + 6 && name.endsWith( ".class" ) )
{
// exact match of class file
return true;
}
}
}
return false;
}
else
{
return true;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// java.lang.Comparable
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/**
* Compare this entry to another for relative ordering.
*
*
* The natural ordering of Entry objects is reverse-alphabetical
* based upon package name.
*
*
* @param thatObj The object to compare.
* @return -1 if this object sorts before that object, 0
* if they are equal, or 1 if this object sorts
* after that object.
*/
public int compareTo( Entry that )
{
// We are reverse sorting this list, so that
// we get longer matches first:
//
// com.werken.foo.bar
// com.werken.foo
// com.werken
return - ( getPackageName().compareTo( that.getPackageName() ) );
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// java.lang.Object
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/**
* Test this entry for equality to another.
*
*
* Consistent with {@link #compareTo}, this method tests
* for equality purely on the package name.
*
*
* @param thatObj The object to compare
* @return true
if the two objects are
* semantically equivalent, otherwise false
.
*/
public boolean equals( Object thatObj )
{
Entry that = (Entry) thatObj;
return getPackageName().equals( that.getPackageName() );
}
/**
*
* Consistent with {@link #equals}, this method creates a hashCode
* based on the packagename.
*
*/
public int hashCode()
{
return getPackageName().hashCode();
}
public String toString()
{
return "Entry[import " + getPackageName() + " from realm " + getClassLoader() + "]";
}
}
NoSuchRealmException.java 0000664 0000000 0000000 00000003653 12203204422 0040070 0 ustar 00root root 0000000 0000000 plexus-classworlds-plexus-classworlds-2.5.1/src/main/java/org/codehaus/plexus/classworlds/realm package org.codehaus.plexus.classworlds.realm;
import org.codehaus.plexus.classworlds.ClassWorld;
import org.codehaus.plexus.classworlds.ClassWorldException;
/*
* Copyright 2001-2006 Codehaus Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Indicates an attempt to retrieve a ClassRealm
from a
* ClassWorld
with an invalid id.
*
* @author bob mcwhirter
*/
public class NoSuchRealmException
extends ClassWorldException
{
// ------------------------------------------------------------
// Instance members
// ------------------------------------------------------------
/**
* The realm id.
*/
private String id;
// ------------------------------------------------------------
// Constructors
// ------------------------------------------------------------
/**
* Construct.
*
* @param world The world.
* @param id The realm id.
*/
public NoSuchRealmException( ClassWorld world, String id )
{
super( world, id );
this.id = id;
}
// ------------------------------------------------------------
// Instance methods
// ------------------------------------------------------------
/**
* Retrieve the invalid realm id.
*
* @return The id.
*/
public String getId()
{
return this.id;
}
}
plexus-classworlds-plexus-classworlds-2.5.1/src/main/java/org/codehaus/plexus/classworlds/strategy/ 0000775 0000000 0000000 00000000000 12203204422 0034000 5 ustar 00root root 0000000 0000000 AbstractStrategy.java 0000664 0000000 0000000 00000003554 12203204422 0040061 0 ustar 00root root 0000000 0000000 plexus-classworlds-plexus-classworlds-2.5.1/src/main/java/org/codehaus/plexus/classworlds/strategy package org.codehaus.plexus.classworlds.strategy;
import java.net.URL;
import java.util.Collection;
import java.util.Collections;
import java.util.Enumeration;
import java.util.LinkedHashSet;
import org.codehaus.plexus.classworlds.UrlUtils;
import org.codehaus.plexus.classworlds.realm.ClassRealm;
/*
* Copyright 2001-2006 Codehaus Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @author Jason van Zyl
*/
public abstract class AbstractStrategy
implements Strategy
{
protected ClassRealm realm;
public AbstractStrategy( ClassRealm realm )
{
this.realm = realm;
}
protected String getNormalizedResource( String name )
{
return UrlUtils.normalizeUrlPath( name );
}
protected Enumeration