use of javax.naming.spi.ObjectFactoryBuilder in project aries by apache.
the class DirObjectFactoryHelper method getObjectInstanceUsingObjectFactoryBuilders.
private Object getObjectInstanceUsingObjectFactoryBuilders(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment, Attributes attrs) throws Exception {
ObjectFactory factory = null;
ServiceReference[] refs = Utils.getReferencesPrivileged(callerContext, ObjectFactoryBuilder.class);
if (refs != null) {
Arrays.sort(refs, Utils.SERVICE_REFERENCE_COMPARATOR);
for (ServiceReference ref : refs) {
ObjectFactoryBuilder builder = (ObjectFactoryBuilder) Utils.getServicePrivileged(callerContext, ref);
try {
factory = builder.createObjectFactory(obj, environment);
} catch (NamingException e) {
// TODO: log it
} finally {
callerContext.ungetService(ref);
}
if (factory != null) {
break;
}
}
}
Object result = null;
if (factory != null) {
if (factory instanceof DirObjectFactory) {
result = ((DirObjectFactory) factory).getObjectInstance(obj, name, nameCtx, environment, attrs);
} else {
result = factory.getObjectInstance(obj, name, nameCtx, environment);
}
}
return (result == null) ? obj : result;
}
use of javax.naming.spi.ObjectFactoryBuilder in project aries by apache.
the class ObjectFactoryHelper method getObjectInstanceUsingObjectFactoryBuilders.
private Object getObjectInstanceUsingObjectFactoryBuilders(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment, Attributes attrs) throws Exception {
ObjectFactory factory = null;
for (ObjectFactoryBuilder ofb : Activator.getServices(callerContext, ObjectFactoryBuilder.class)) {
try {
factory = ofb.createObjectFactory(obj, environment);
} catch (NamingException e) {
// TODO: log it
}
if (factory != null) {
break;
}
}
Object result = null;
if (factory != null) {
result = getObjectFromFactory(obj, name, nameCtx, environment, attrs, factory);
}
return (result == null) ? obj : result;
}
use of javax.naming.spi.ObjectFactoryBuilder in project aries by apache.
the class ObjectFactoryHelper method getObjectInstanceUsingObjectFactoryBuilders.
private Object getObjectInstanceUsingObjectFactoryBuilders(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment) throws Exception {
ObjectFactory factory = null;
ServiceReference[] refs = Utils.getReferencesPrivileged(callerContext, ObjectFactoryBuilder.class);
if (refs != null) {
Arrays.sort(refs, Utils.SERVICE_REFERENCE_COMPARATOR);
for (ServiceReference ref : refs) {
ObjectFactoryBuilder builder = (ObjectFactoryBuilder) Utils.getServicePrivileged(callerContext, ref);
try {
factory = builder.createObjectFactory(obj, environment);
} catch (NamingException e) {
// TODO: log it
} finally {
callerContext.ungetService(ref);
}
if (factory != null) {
break;
}
}
}
Object result = null;
if (factory != null) {
result = factory.getObjectInstance(obj, name, nameCtx, environment);
}
return (result == null) ? obj : result;
}
Aggregations