protected Application newApplicationInstance( ApplicationDescriptor applicationModel ) { return applicationModel.newInstance( polygene.api() ); }
protected Application newApplicationInstance( ApplicationDescriptor applicationModel ) { return applicationModel.newInstance( polygene.api() ); }
@Override public final void contextInitialized( ServletContextEvent sce ) { try { ServletContext context = sce.getServletContext(); LOGGER.trace( "Assembling Application" ); polygene = new Energy4Java(); applicationModel = polygene.newApplicationModel( this ); LOGGER.trace( "Instanciating and activating Application" ); application = applicationModel.newInstance( polygene.api() ); api = polygene.api(); beforeApplicationActivation( application ); application.activate(); afterApplicationActivation( application ); LOGGER.trace( "Storing Application in ServletContext" ); context.setAttribute( PolygeneServletSupport.APP_IN_CTX, application ); } catch ( Exception ex ) { if ( application != null ) { try { beforeApplicationPassivation( application ); application.passivate(); afterApplicationPassivation( application ); } catch ( Exception ex1 ) { LOGGER.warn( "Application not null and could not passivate it.", ex1 ); } } throw new InvalidApplicationException( "Unexpected error during ServletContext initialization, see previous log for errors.", ex ); } }
@Override public final void contextInitialized( ServletContextEvent sce ) { try { ServletContext context = sce.getServletContext(); LOGGER.trace( "Assembling Application" ); polygene = new Energy4Java(); applicationModel = polygene.newApplicationModel( this ); LOGGER.trace( "Instanciating and activating Application" ); application = applicationModel.newInstance( polygene.api() ); api = polygene.api(); beforeApplicationActivation( application ); application.activate(); afterApplicationActivation( application ); LOGGER.trace( "Storing Application in ServletContext" ); context.setAttribute( PolygeneServletSupport.APP_IN_CTX, application ); } catch ( Exception ex ) { if ( application != null ) { try { beforeApplicationPassivation( application ); application.passivate(); afterApplicationPassivation( application ); } catch ( Exception ex1 ) { LOGGER.warn( "Application not null and could not passivate it.", ex1 ); } } throw new InvalidApplicationException( "Unexpected error during ServletContext initialization, see previous log for errors.", ex ); } }
@Override protected Application newApplicationInstance( ApplicationDescriptor applicationModel ) { return applicationModel.newInstance( polygene.api(), new MetadataService() ); }
@Override protected Application newApplicationInstance( ApplicationDescriptor applicationModel ) { return applicationModel.newInstance( polygene.api(), new MetadataService() ); }
@Test public void givenValuesOfCommonTypesWhenTestingValueDescriptorEqualityExpectNotEquals() { Some some = buildSomeValue( valueBuilderFactory ); ValueDescriptor someDescriptor = polygene.api().valueDescriptorFor( some ); PrimitivesValue primitive = buildPrimitivesValue( valueBuilderFactory ); ValueDescriptor primitiveDescriptor = polygene.api().valueDescriptorFor( primitive ); assertThat( "ValueDescriptors not equal", someDescriptor, not( equalTo( primitiveDescriptor ) ) ); assertThat( "ValueDescriptors hashcode not equal", someDescriptor.hashCode(), not( equalTo( primitiveDescriptor.hashCode() ) ) ); }
@Test public void givenValuesOfDifferentTypesWhenTestingValueDescriptorEqualityExpectNotEquals() { Some some = buildSomeValue( valueBuilderFactory ); ValueDescriptor someDescriptor = polygene.api().valueDescriptorFor( some ); Other other = buildOtherValue( valueBuilderFactory ); ValueDescriptor otherDescriptor = polygene.api().valueDescriptorFor( other ); assertThat( "ValueDescriptors not equal", someDescriptor, not( equalTo( otherDescriptor ) ) ); assertThat( "ValueDescriptors hashcode not equal", someDescriptor.hashCode(), not( equalTo( otherDescriptor.hashCode() ) ) ); }
@Test public void givenValuesOfTheSameTypeWhenTestingValueDescriptorEqualityExpectEquals() { Some some = buildSomeValue(valueBuilderFactory); ValueDescriptor someDescriptor = polygene.api().valueDescriptorFor( some ); Some other = buildSomeValue( valueBuilderFactory ); ValueDescriptor otherDescriptor = polygene.api().valueDescriptorFor( other ); assertThat( "ValueDescriptors equal", someDescriptor, equalTo( otherDescriptor ) ); assertThat( "ValueDescriptors hashcode equal", someDescriptor.hashCode(), equalTo( otherDescriptor.hashCode() ) ); }
Application application = model.newInstance( polygene.api() ); for( ActivationEventListener activationListener : activationListeners )
Application application = model.newInstance( polygene.api() ); for( ActivationEventListener activationListener : activationListeners )
@Test public void givenValuesOfDifferentTypesWhenTestingPropertyDescriptorEqualityExpectNotEquals() { Some some = buildSomeValue( valueBuilderFactory ); ValueDescriptor someDescriptor = polygene.api().valueDescriptorFor( some ); PropertyDescriptor someCharPropDesc = someDescriptor.state().findPropertyModelByName( "characterProperty" ); Other other = buildOtherValue( valueBuilderFactory ); ValueDescriptor otherDescriptor = polygene.api().valueDescriptorFor( other ); PropertyDescriptor otherCharPropDesc = otherDescriptor.state().findPropertyModelByName( "characterProperty" ); assertThat( "PropertyDescriptors not equal", someCharPropDesc, not( equalTo( otherCharPropDesc ) ) ); assertThat( "PropertyDescriptors hashcode not equal", someCharPropDesc.hashCode(), not( equalTo( otherCharPropDesc.hashCode() ) ) ); }
AssociationDescriptor someAssocDesc = polygene.api().associationDescriptorFor( some.anEntity() ); AssociationDescriptor someManyAssocDesc = polygene.api().associationDescriptorFor( some.manyEntities() ); AssociationDescriptor someNamedAssocDesc = polygene.api().associationDescriptorFor( some.namedEntities() ); AssociationDescriptor otherAssocDesc = polygene.api().associationDescriptorFor( other.anEntity() ); AssociationDescriptor otherManyAssocDesc = polygene.api().associationDescriptorFor( other.manyEntities() ); AssociationDescriptor otherNamedAssocDesc = polygene.api().associationDescriptorFor( other.namedEntities() );
@Test public void givenValuesOfTheSameTypeWhenTestingPropertyDescriptorEqualityExpectEquals() { Some some = buildSomeValue( valueBuilderFactory ); ValueDescriptor someDescriptor = polygene.api().valueDescriptorFor( some ); PropertyDescriptor someCharPropDesc = someDescriptor.state().findPropertyModelByName( "characterProperty" ); Some other = buildSomeValue( valueBuilderFactory ); ValueDescriptor otherDescriptor = polygene.api().valueDescriptorFor( other ); PropertyDescriptor otherCharPropDesc = otherDescriptor.state().findPropertyModelByName( "characterProperty" ); assertThat( "PropertyDescriptors equal", someCharPropDesc, equalTo( otherCharPropDesc ) ); assertThat( "PropertyDescriptors hashcode equal", someCharPropDesc.hashCode(), equalTo( otherCharPropDesc.hashCode() ) ); }
@Test public void givenValuesOfCommonTypesWhenTestingPropertyDescriptorEqualityExpectEquals() { Some some = buildSomeValue( valueBuilderFactory ); ValueDescriptor someDescriptor = polygene.api().valueDescriptorFor( some ); PropertyDescriptor someCharPropDesc = someDescriptor.state().findPropertyModelByName( "characterProperty" ); PrimitivesValue primitive = buildPrimitivesValue( valueBuilderFactory ); ValueDescriptor primitiveDescriptor = polygene.api().valueDescriptorFor( primitive ); PropertyDescriptor primitiveCharPropDesc = primitiveDescriptor.state() .findPropertyModelByName( "characterProperty" ); assertThat( "PropertyDescriptors equal", someCharPropDesc, equalTo( primitiveCharPropDesc ) ); assertThat( "PropertyDescriptors hashcode equal", someCharPropDesc.hashCode(), equalTo( primitiveCharPropDesc.hashCode() ) ); }
AssociationDescriptor someAssocDesc = polygene.api().associationDescriptorFor( some.anEntity() ); AssociationDescriptor someManyAssocDesc = polygene.api().associationDescriptorFor( some.manyEntities() ); AssociationDescriptor someNamedAssocDesc = polygene.api().associationDescriptorFor( some.namedEntities() ); AssociationDescriptor some2AssocDesc = polygene.api().associationDescriptorFor( some2.anEntity() ); AssociationDescriptor some2ManyAssocDesc = polygene.api().associationDescriptorFor( some2.manyEntities() ); AssociationDescriptor some2NamedAssocDesc = polygene.api().associationDescriptorFor( some2.namedEntities() );
AssociationDescriptor someAssocDesc = polygene.api().associationDescriptorFor( some.anEntity() ); AssociationDescriptor someManyAssocDesc = polygene.api().associationDescriptorFor( some.manyEntities() ); AssociationDescriptor someNamedAssocDesc = polygene.api().associationDescriptorFor( some.namedEntities() ); AssociationDescriptor some2AssocDesc = polygene.api().associationDescriptorFor( some2.anEntity() ); AssociationDescriptor some2ManyAssocDesc = polygene.api().associationDescriptorFor( some2.manyEntities() ); AssociationDescriptor some2NamedAssocDesc = polygene.api().associationDescriptorFor( some2.namedEntities() );
@Test public void entityBuilderAssociationTypeIsNotNull() { UnitOfWork uow = unitOfWorkFactory.newUnitOfWork(); try { EntityBuilder<Item> builder = uow.newEntityBuilder( Item.class ); assertEquals( ItemType.class, polygene.api() .entityDescriptorFor( builder.instance() ) .state() .getAssociationByName( "typeOfItem" ) .type() ); } finally { uow.discard(); } }