/** * retrieves the object for the given objectName, ensuring it is constructed and initialized. * * @return the object found, or null if the object was not found. */ @Override public Object get(final String objectName) { return get(objectName, false); }
Object object = wireContext.get(objectName); if (object == null) { String message = ExceptionManager.getInstance().getFullMessage(
object = wireContext.get(factoryObjectName, false); if (object == null) { String message = ExceptionManager.getInstance().getFullMessage(
@Override public <T> T get(final Class<T> type) { return environmentFactoryCtxWireContext.get(type); }
@Override public Object get(final String key) { return environmentFactoryCtxWireContext.get(key); }
@Override public Object construct(final WireContext wireContext) { if (LOG.isLoggable(Level.FINE)) { LOG.fine("looking up " + type + " by type in " + wireContext); } if (type != null) { return wireContext.get(type); } return null; }
@Override public Object construct(final WireContext wireContext) { return wireContext.get(text, isDelayedInitializationAllowed()); }
/** * searches for the first descriptor that defines an object of the given type. In case of multiple objects of the same * type, the first object that is declared of the given type will be found. Also super classes and interfaces are * taken into account. Not all descriptor types will be type sensitive, only: * * <pre> * | ObjectDescriptor | object | * | HibernatePersistenceServiceDescriptor | business-calendar | * | TransactionDescriptor | transaction | * | PropertiesDescriptor | properties | * | BusinessCalendarDescriptor | business-calendar | * </ul> * </pre> */ @Override @SuppressWarnings("unchecked") public <T> T get(final Class<T> type) { if (wireDefinition != null) { final String name = wireDefinition.getDescriptorName(type); if (name != null) { return (T) get(name); } } return null; }
public Object construct(WireContext wireContext) { Session session = null; if (sessionName != null) { session = (Session) wireContext.get(sessionName); if (session == null) { throw new WireException("Could not find a session with name: " + sessionName); } } else { session = wireContext.get(Session.class); if (session == null) { throw new WireException("No object ob type Session found in environment"); } } return getDbSessionObject(session); }
/** * @throws WireException * if this operation is applied on an object which is not a resource * or if the specified transaction cannot be found. */ public void apply(Object target, WireContext wireContext) { if (!(target instanceof StandardResource)) { String message = ExceptionManager.getInstance().getFullMessage( "bp_EO_1", StandardResource.class.getName(), target, (target != null ? " (" + target.getClass().getName() + ")" : "")); throw new WireException(message); } Object object = null; if (transactionName != null) { object = wireContext.get(transactionName); } else { object = wireContext.get(Transaction.class); } if ((object == null) || (!(object instanceof StandardTransaction))) { String message = ExceptionManager.getInstance().getFullMessage( "bp_EO_2", StandardTransaction.class.getName(), (transactionName != null ? "'" + transactionName + "'" : "by type"), target); throw new WireException(message); } StandardTransaction standardTransaction = (StandardTransaction) object; if (LOG.isLoggable(Level.FINE)) { LOG.fine("enlisting resource " + target + " with transaction"); } standardTransaction.enlistResource((StandardResource) target); }
sessionFactory = (SessionFactory) wireContext.get(factoryName); } else { sessionFactory = environment.get(SessionFactory.class); Connection connection = (Connection) wireContext.get(connectionName); if (LOG.isLoggable(Level.FINE)) { LOG.fine("creating hibernate session with connection " + connection);
/** * Initializes all the eager objects defined in the {@link #wireDefinition}. */ void initializeEagerObjects() { if (wireDefinition != null) { final List<String> eagerInitObjectNames = wireDefinition.getEagerInitNames(); if (eagerInitObjectNames != null) { for (final String eagerInitObjectName : eagerInitObjectNames) { final Descriptor descriptor = wireDefinition.getDescriptor(eagerInitObjectName); if (descriptor.isEagerInit()) { if (LOG.isLoggable(Level.FINE)) { LOG.fine("eagerly initializing " + eagerInitObjectName); } get(eagerInitObjectName, descriptor.isDelayable()); } } while (!hasObjectUnderConstruction() && !hasObjectUnderInitialization() && hasPendingInitializations()) { processPendingInitializations(); } } } }
@Override public Object construct(final WireContext wireContext) { Configuration configuration = null; if (configurationName != null) { configuration = (Configuration) wireContext.get(configurationName); } else if (configurationDescriptor != null) { configuration = (Configuration) wireContext.create(configurationDescriptor, false); } else { configuration = wireContext.get(Configuration.class); } if (configuration == null) { final String message = ExceptionManager.getInstance().getFullMessage("bp_HSF_1"); throw new WireException(message); } SearchUtil.addSearchConfiguration(configuration); addInterceptor(configuration); final SessionFactory sessionFactory = configuration.buildSessionFactory(); wireContext.addListener(new SessionFactoryCloser(sessionFactory)); return sessionFactory; }