Skip to content

Commit

Permalink
Implement Daniel suggestions, add missing new lines to test files
Browse files Browse the repository at this point in the history
  • Loading branch information
AlekseiEfimov committed Nov 19, 2024
1 parent 6784ea1 commit 7b3edb8
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,8 @@ public static Object getDirObjectInstance(Object refInfo, Name name, Context nam
static ObjectFactory getObjectFactoryFromReference(
Reference ref, String factoryName, Predicate<Class<?>> filter)
throws IllegalAccessException,
InstantiationException,
MalformedURLException {
Class<?> clas = null;
InstantiationException {
Class<?> clas;

// Try to use current class loader
try {
Expand All @@ -193,20 +192,11 @@ static ObjectFactory getObjectFactoryFromReference(
return null;
}
} catch (ClassNotFoundException e) {
// ignore and continue
// e.printStackTrace();
}
// All other exceptions are passed up.

// Not in class path; loading of a factory from remote
// codebase is not supported
if (clas == null &&
ref.getFactoryClassLocation() != null) {
return null;
}

assert clas != null;
@SuppressWarnings("deprecation") // Class.newInstance
ObjectFactory result = (clas != null) ? (ObjectFactory) clas.newInstance() : null;
ObjectFactory result = (ObjectFactory) clas.newInstance();
return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ static ObjectFactoryBuilder getObjectFactoryBuilder() {
* or {@code Referenceable} containing a factory class name,
* use the named factory to create the object.
* Return {@code refInfo} if the factory cannot be created.
* The factory class downloading from a location specified in the reference
* is not supported, unless a custom {@link ObjectFactoryBuilder}
* {@linkplain #setObjectFactoryBuilder(ObjectFactoryBuilder) is set}
* to determine object factories load policy.
* Downloading a factory class from a location specified in the reference
* is not supported out of the box. A custom {@link ObjectFactoryBuilder}
* {@linkplain #setObjectFactoryBuilder(ObjectFactoryBuilder) may be used}
* if a different policy is desired.
* If an exception is encountered while creating the factory,
* it is passed up to the caller.
* <li>If {@code refInfo} is a {@code Reference} or
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,9 +467,9 @@ private Object decodeObject(Remote r, Name name) throws NamingException {
: (Object)r;

/*
* Classes may only be loaded from an arbitrary URL codebase when
* a custom ObjectFactoryBuilder() is setup, otherwise load from
* arbitrary URL codebase is disabled.
* Downloading a factory class from a location specified in the reference
* is not supported out of the box. A custom "ObjectFactoryBuilder"
* may be used if a different policy is desired.
*/

// Use reference if possible
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,4 +220,4 @@ public Socket createSocket(String host, int port) throws IOException {
private static final String OBJ_FACTORY_CLASS_NAME = "TestFactory.class";
// Package directory of the test's objects factory class
private static final Path OBJ_FACTORY_PACKAGE_PATH = Paths.get("com").resolve("test");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ public ObjectFactory createObjectFactory(Object obj, Hashtable<?, ?> environment
"supports only Reference types");
}
}
}
}

0 comments on commit 7b3edb8

Please sign in to comment.