@Override public Object apply( PropertyDescriptor propertyDescriptor ) { StateHolder state = getValueStateInstance( value ); Property<Object> property = state.propertyFor( propertyDescriptor.accessor() ); return property.get(); } }
@Override public Object apply( PropertyDescriptor descriptor ) { return prototypeState.propertyFor( descriptor.accessor() ).get(); } }
@Override public void exportDataSources() throws MalformedObjectNameException, MBeanRegistrationException, InstanceAlreadyExistsException, NotCompliantMBeanException { for ( ServiceReference<DataSource> dataSource : dataSources ) { ModuleDescriptor module = spi.moduleOf( dataSource ); EntityDescriptor descriptor = module.entityDescriptor( DataSourceConfiguration.class.getName() ); List<MBeanAttributeInfo> attributes = new ArrayList<>(); Map<String, AccessibleObject> properties = new LinkedHashMap<>(); descriptor.state().properties().forEach(persistentProperty -> { if ( !persistentProperty.isImmutable() ) { String propertyName = persistentProperty.qualifiedName().name(); String type = persistentProperty.valueType().primaryType().getName(); attributes.add( new MBeanAttributeInfo( propertyName, type, propertyName, true, true, type.equals( "java.lang.Boolean" ) ) ); properties.put( propertyName, persistentProperty.accessor() ); } } ); List<MBeanOperationInfo> operations = new ArrayList<>(); operations.add( new MBeanOperationInfo( "restart", "Restart DataSource", new MBeanParameterInfo[ 0 ], "void", MBeanOperationInfo.ACTION_INFO ) ); String mbeanName = dataSource.identity().toString(); MBeanInfo mbeanInfo = new MBeanInfo( DataSourceConfiguration.class.getName(), mbeanName, attributes.toArray( new MBeanAttributeInfo[ attributes.size() ] ), null, operations.toArray( new MBeanOperationInfo[ operations.size() ] ), null ); Object mbean = new ConfigurableDataSource( dataSourceService, mbeanInfo, mbeanName, properties ); ObjectName configurableDataSourceName = new ObjectName( "Polygene:application=" + application.name() + ",class=Datasource,name=" + mbeanName ); server.registerMBean( mbean, configurableDataSourceName ); configurationNames.add( configurableDataSourceName ); } }
@Override public void exportDataSources() throws MalformedObjectNameException, MBeanRegistrationException, InstanceAlreadyExistsException, NotCompliantMBeanException { for ( ServiceReference<DataSource> dataSource : dataSources ) { ModuleDescriptor module = spi.moduleOf( dataSource ); EntityDescriptor descriptor = module.entityDescriptor( DataSourceConfiguration.class.getName() ); List<MBeanAttributeInfo> attributes = new ArrayList<>(); Map<String, AccessibleObject> properties = new LinkedHashMap<>(); descriptor.state().properties().forEach(persistentProperty -> { if ( !persistentProperty.isImmutable() ) { String propertyName = persistentProperty.qualifiedName().name(); String type = persistentProperty.valueType().primaryType().getName(); attributes.add( new MBeanAttributeInfo( propertyName, type, propertyName, true, true, type.equals( "java.lang.Boolean" ) ) ); properties.put( propertyName, persistentProperty.accessor() ); } } ); List<MBeanOperationInfo> operations = new ArrayList<>(); operations.add( new MBeanOperationInfo( "restart", "Restart DataSource", new MBeanParameterInfo[ 0 ], "void", MBeanOperationInfo.ACTION_INFO ) ); String mbeanName = dataSource.identity().toString(); MBeanInfo mbeanInfo = new MBeanInfo( DataSourceConfiguration.class.getName(), mbeanName, attributes.toArray( new MBeanAttributeInfo[ attributes.size() ] ), null, operations.toArray( new MBeanOperationInfo[ operations.size() ] ), null ); Object mbean = new ConfigurableDataSource( dataSourceService, mbeanInfo, mbeanName, properties ); ObjectName configurableDataSourceName = new ObjectName( "Polygene:application=" + application.name() + ",class=Datasource,name=" + mbeanName ); server.registerMBean( mbean, configurableDataSourceName ); configurationNames.add( configurableDataSourceName ); } }
@Override public Object provideInjection( InjectionContext context ) throws InjectionProviderException { Property<?> value = context.state().propertyFor( propertyDescriptor.accessor() ); if( value != null ) { return value; } else { throw new InjectionProviderException( "Non-optional property " + propertyDescriptor + " had no value" ); } } }
@Override public void write( OutputStream outputStream ) throws IOException { if( representation != null ) { representation.write( outputStream ); } else if( object != null ) { AssociationStateHolder state = spi.stateOf( (ValueComposite) object ); ValueDescriptor descriptor = (ValueDescriptor) spi.modelDescriptorFor( object ); descriptor.state().properties().forEach( property -> { String name = property.qualifiedName().name(); String value = state.propertyFor( property.accessor() ).get().toString(); try { outputStream.write( name.getBytes( "UTF-8" ) ); outputStream.write( "=".getBytes( "UTF-8" ) ); outputStream.write( value.getBytes( "UTF-8" ) ); outputStream.write( '\n' ); } catch( IOException e ) { // TODO; not sure what could happen here. } } ); } } }
private void extractPropertyQNames( EntityDescriptor entityDesc, Map<QualifiedName, QNameInfo> qNameInfos, Set<QualifiedName> newQNames, List<CompositeDescriptorInfo> vDescriptors, Set<String> enumValues, Boolean setQNameTableNameToNull ) { entityDesc.state().properties().forEach( pDesc -> { if( SQLSkeletonUtil.isQueryable( pDesc.accessor() ) ) { this.processPropertyTypeForQNames( pDesc, qNameInfos, newQNames, vDescriptors, enumValues, setQNameTableNameToNull // ); } } ); }
@Override public TemplateModel get( String key ) throws TemplateModelException { try { return wrapper.wrap( PolygeneAPI.FUNCTION_COMPOSITE_INSTANCE_OF .apply( composite ) .state() .propertyFor( descriptor.state().findPropertyModelByName( key ).accessor() ) .get() ); } catch( IllegalArgumentException e ) { return null; } }
@Override public TemplateModel get( String key ) throws TemplateModelException { try { return wrapper.wrap( PolygeneAPI.FUNCTION_COMPOSITE_INSTANCE_OF .apply( composite ) .state() .propertyFor( descriptor.state().findPropertyModelByName( key ).accessor() ) .get() ); } catch( IllegalArgumentException e ) { return null; } }
@Override public <T> TransientBuilder<T> newTransientBuilder( Class<T> mixinType ) throws NoSuchTransientTypeException { Objects.requireNonNull( mixinType, "mixinType" ); TransientDescriptor model = typeLookup.lookupTransientModel( mixinType ); if( model == null ) { throw new NoSuchTransientTypeException( mixinType.getName(), descriptor() ); } Map<AccessibleObject, Property<?>> properties = new HashMap<>(); model.state().properties().forEach( propertyModel -> { Object initialValue = propertyModel.resolveInitialValue( model.module() ); Property<?> property = new PropertyInstance<>( ( (PropertyModel) propertyModel ).getBuilderInfo(), initialValue ); properties.put( propertyModel.accessor(), property ); } ); TransientStateInstance state = new TransientStateInstance( properties ); return new TransientBuilderInstance<>( model, state, UsesInstance.EMPTY_USES ); }
private void validateState( AssociationStateHolder state, EntityDescriptor entityDescriptor ) { entityDescriptor.state().properties().forEach( propertyDescriptor -> { Property<?> prop = state.propertyFor( propertyDescriptor.accessor() ); assertThat( "Properties could be listed", prop, CoreMatchers.notNullValue() ); } ); AssociationStateDescriptor descriptor = entityDescriptor.state(); descriptor.associations().forEach( associationDescriptor -> { AbstractAssociation assoc = state.associationFor( associationDescriptor.accessor() ); assertThat( "Assocs could be listed", assoc, CoreMatchers.notNullValue() ); } ); }
entityPK, pDesc.qualifiedName(), state.propertyFor( pDesc.accessor() ).get(), localPK );
property -> Object value = state.propertyFor( property.accessor() ).get(); Converter<Object> converter = converters.converterFor( property ); if( converter != null )
property -> Object value = state.propertyFor( property.accessor() ).get(); Converter converter = converters.converterFor( property ); if( converter != null )
final Integer propertyPK[] = { 0 }; state.entityDescriptor().state().properties() .filter( pDesc -> SQLSkeletonUtil.isQueryable( pDesc.accessor() ) ) .forEach( pDesc -> { try
property -> Object value = state.propertyFor( property.accessor() ).get(); Converter converter = converters.converterFor( property ); if( converter != null )
.apply( value ) .state() .propertyFor( persistentProperty.accessor() ) .get();
property -> Object value = state.propertyFor( property.accessor() ).get(); Converter<Object> converter = converters.converterFor( property ); if( converter != null )
try Object value = holder.propertyFor( propertyDescriptor.accessor() ).get(); String param; if( value == null )