Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ public FieldSet(final String name) {
@Getter @Setter
private String id;


/**
* Whether this fieldset should be used to hold any unreferenced actions (contributed or "native").
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,10 @@ public enum EntityState {
*/
TRANSIENT_OR_REMOVED(false),
/**
* @deprecated - This entity state is no longer in use; was specific to JDO/DataNucleus object store, now retired.
* Set by the framework after entity removal.
* <p> However, detecting an entity's state in the JPA context will never yield {@link #REMOVED}.
*/
@Deprecated // JDO specific
REMOVED(false)
;
REMOVED(false);

// -- PREDICATES

Expand All @@ -89,7 +88,6 @@ public enum EntityState {
public boolean isTransientOrRemoved() { return this == TRANSIENT_OR_REMOVED
|| this == REMOVED; }
/** @see #REMOVED */
@Deprecated // JDO specific
public boolean isRemoved() { return this == REMOVED; }

// -- SPECIAL STATES
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,5 +345,4 @@ default DateTimeFormatter getTemporalIsoFormat(
};
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,6 @@ public static BytesOperator operator() {
.andThen(bytes->decodeBase64(Base64.getDecoder(), bytes))
.andThen(_Bytes::decompress);


// -- EXTERNAL FORMAT

public static byte[] fromInts(final int[] ints) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ public static <T> HashSet<T> newHashSet(final @Nullable Iterable<T> iterable) {

// -- LINKED HASH SET


public static <T> LinkedHashSet<T> newLinkedHashSet(final @Nullable Collection<T> collection) {
if(collection==null)
return new LinkedHashSet<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@

import java.util.Objects;

import jakarta.inject.Named;

import org.apache.causeway.applib.annotation.DomainObject;
import org.apache.causeway.applib.annotation.DomainService;
import org.apache.causeway.commons.internal.base._Timing;
import org.apache.causeway.core.config.CausewayModuleCoreConfig;
import org.apache.causeway.core.config.beans.CausewayBeanTypeClassifier.ContextType;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
Expand All @@ -32,12 +35,7 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import org.apache.causeway.applib.annotation.DomainObject;
import org.apache.causeway.applib.annotation.DomainService;
import org.apache.causeway.commons.internal.base._Timing;
import org.apache.causeway.core.config.CausewayModuleCoreConfig;
import org.apache.causeway.core.config.beans.CausewayBeanTypeClassifier.ContextType;

import jakarta.inject.Named;
import lombok.extern.slf4j.Slf4j;

/**
Expand Down Expand Up @@ -87,8 +85,8 @@ public void postProcessBeanFactory(final ConfigurableListableBeanFactory beanFac
this.componentScanResult = new CausewayBeanTypeRegistry(introspectableTypes);

log.info("post processing {}/{} bean definitions took {}ms",
introspectableTypes.size(),
beanFactory.getBeanDefinitionCount(),
introspectableTypes.size(),
stopWatch.getMillis());

if(log.isDebugEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ private void collect(final String beanDefinitionName) {
}
}


/**
* Allows for the given type-meta to be modified before bean-definition registration
* is finalized by Spring, immediately after the type-scan phase.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,22 @@

import java.util.Optional;

import org.apache.causeway.commons.internal.observation.ObservationClosure;
import org.apache.causeway.core.config.observation.CausewayObservationAutoConfiguration.DiscardedSpanExportingPredicate;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.Profile;

import org.apache.causeway.commons.internal.observation.ObservationClosure;
import org.apache.causeway.core.config.observation.CausewayObservationAutoConfiguration.DiscardedSpanExportingPredicate;

import io.micrometer.observation.ObservationRegistry;
import io.micrometer.tracing.exporter.FinishedSpan;
import io.micrometer.tracing.exporter.SpanExportingPredicate;

/**
* Makes observation an opt-in choice based on Spring Profile 'observation' being active.
*
*
* <p>see Spring's org.springframework.boot.micrometer.observation.autoconfigure.ObservationAutoConfiguration
*/
@AutoConfiguration
Expand All @@ -27,7 +26,7 @@
DiscardedSpanExportingPredicate.class
})
public class CausewayObservationAutoConfiguration {

/**
* Does not allow discarded spans to be exported. Register with Spring (before auto configuration is running).
*/
Expand All @@ -37,26 +36,26 @@ public boolean isExportable(final FinishedSpan span) {
return !span.getTags().containsKey(ObservationClosure.DISCARD_KEY.getKey());
}
}

@Profile("!observation")
@Bean
ObservationRegistry noopObservationRegistry() {
@Bean
public ObservationRegistry noopObservationRegistry() {
return ObservationRegistry.NOOP;
}

/**
* Same as in org.springframework.boot.micrometer.observation.autoconfigure.ObservationAutoConfiguration,
* that is, acts as a fallback.
* that is, acts as a fallback.
*/
@Profile("observation")
@Bean
@ConditionalOnMissingBean
ObservationRegistry observationRegistry() {
public ObservationRegistry observationRegistry() {
return ObservationRegistry.create();
}

@Bean
CausewayObservationIntegration causewayObservationIntegration(
public CausewayObservationIntegration causewayObservationIntegration(
final Optional<ObservationRegistry> observationRegistryOpt) {
return new CausewayObservationIntegration(observationRegistryOpt);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ public static void discard(@Nullable final Observation obs) {
ObservationClosure.discard(obs);
}


//TODO perhaps threshold should not be hardcoded at call site; what we really want is to report Observations
// that are way off a base-line; this would require some profiling to establish base-lines
public record ObservationWithTimeThreshold(Observation delegate, Duration threshold, Timer timer) implements Observation {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public record ExecutionContext(
MetamodelEventService metamodelEventService,
QueryResultsCache queryResultsCache) {


public CommandPublisher commandPublisher() {
return commandPublisherProvider.get();
}
Expand All @@ -72,4 +71,4 @@ public ObservationProvider observationProvider(final Class<?> participant, final
: __->Observation.NOOP;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.apache.causeway.applib.Identifier;
import org.apache.causeway.commons.internal.exceptions._Exceptions;
import org.apache.causeway.core.metamodel.facets.FacetFactory;
import org.apache.causeway.core.metamodel.facets.FacetedMethod;
import org.apache.causeway.core.metamodel.facets.actions.action.invocation.ActionInvocationFacet;
import org.apache.causeway.core.metamodel.facets.all.named.ObjectNamedFacet;

Expand Down Expand Up @@ -127,7 +126,7 @@ default Identifier getFeatureIdentifier() {
}

default Optional<FacetRanking> getSharedFacetRanking() {
return facetHolder().getFacetRanking(facetType());
return facetHolder().lookupFacetRanking(facetType());
}

default FacetRanking getSharedFacetRankingElseFail() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
package org.apache.causeway.core.metamodel.facetapi;

import java.util.Objects;

import org.apache.causeway.core.metamodel.context.HasMetaModelContext;
import org.jspecify.annotations.NonNull;

Expand All @@ -27,28 +29,43 @@
public abstract class FacetAbstract
implements Facet, HasMetaModelContext {

@Getter(onMethod_ = {@Override}) @Accessors(fluent = true)
@Getter(onMethod_ = {@Override}) @Accessors(fluent = true, makeFinal = true)
private final @NonNull Class<? extends Facet> facetType;

@Override
public Precedence precedence() {
return Precedence.DEFAULT;
}

@Getter(onMethod_ = {@Override}) @Accessors(fluent = true)
@Getter(onMethod_ = {@Override}) @Accessors(fluent = true, makeFinal = true)
private final @NonNull FacetHolder facetHolder;

protected FacetAbstract(
final Class<? extends Facet> facetType,
final FacetHolder facetHolder) {
this.facetType = facetType;
this.facetHolder = facetHolder;
//TODO refactor facetHolder.addFacet(this);
this.facetType = Objects.requireNonNull(facetType);
this.facetHolder = Objects.requireNonNull(facetHolder);
prebind(facetHolder);
// binding by contract
_BindUtil.resolveInternalElseFail(facetHolder)
.addFacet(this);
}

@Override
public Precedence precedence() {
return Precedence.DEFAULT;
}

@Override
public String toString() {
return FacetUtil.toString(this);
}

// -- HELPER

/**
* Some {@link Facet}(s) may need certain adjustments to the {@link FacetHolder} which they are about to be added to.
* This method is called before binding this {@link Facet} to its holder. It is called inside the {@link Facet}'s constructor.
*/
private final void prebind(final FacetHolder facetHolder) {
if(this instanceof ReloadableFacet reloadableFacet) {
reloadableFacet.onPrebind(facetHolder); // dynamic update support
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@
import java.util.function.Predicate;
import java.util.stream.Stream;

import org.jspecify.annotations.NonNull;

import org.apache.causeway.applib.Identifier;
import org.apache.causeway.applib.id.LogicalType;
import org.apache.causeway.applib.services.i18n.HasTranslationContext;
import org.apache.causeway.applib.services.i18n.TranslationContext;
import org.apache.causeway.core.metamodel.context.HasMetaModelContext;
import org.apache.causeway.core.metamodel.context.MetaModelContext;
import org.jspecify.annotations.NonNull;

/**
* Anything in the metamodel (which also includes peers in the reflector) that
Expand Down Expand Up @@ -70,7 +69,6 @@ public static FacetHolder forTesting(final MetaModelContext mmc) {

int getFacetCount();


// -- FACET LOOKUP

<T extends Facet> Optional<T> lookupFacet(final @NonNull Class<T> facetType);
Expand All @@ -86,16 +84,6 @@ default <T extends Facet> Optional<T> lookupNonFallbackFacet(
return lookupFacet(facetType, facet->!facet.precedence().isFallback());
}

/**
* Get the facet of the specified type (as per the type it reports from
* {@link Facet#facetType()}).
* @deprecated
*/
@Deprecated
default <T extends Facet> T getFacet(final Class<T> facetType) {
return lookupFacet(facetType).orElse(null);
}

// -- CONTAINS

/**
Expand Down Expand Up @@ -135,20 +123,10 @@ default <F extends Facet> Stream<F> streamFacets(final Class<F> requiredType) {
.map(requiredType::cast);
}

/**
* Adds the facet, extracting its {@link Facet#facetType() type} as the key.
*
* <p>
* Any previously added facet of the same type will be overwritten,
* when given {@link Facet} has equal or higher precedence.
* Otherwise is ignored.
*/
void addFacet(@NonNull Facet facet);

// -- VALIDATION SUPPORT

Stream<FacetRanking> streamFacetRankings();
Optional<FacetRanking> getFacetRanking(Class<? extends Facet> facetType);
Optional<FacetRanking> lookupFacetRanking(Class<? extends Facet> facetType);

// -- TRANSLATION CONTEXT

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.causeway.core.metamodel.facetapi;

import org.jspecify.annotations.Nullable;

interface FacetHolderInternal extends FacetHolder {

/**
* Adds the facet, extracting its {@link Facet#facetType() type} as the key.
*
* <p> Any previously added facet of the same type will be overwritten,
* when given {@link Facet} has equal or higher precedence.
* Otherwise is ignored.
*
* <p> If facet is <code>null</code> acts as a no-op.
*/
void addFacet(@Nullable Facet facet);

/**
* @deprecated Use for debugging only! Breaks the contract, that every facet is contained by its holder.
* @throws {@link IllegalArgumentException} when facet is not found, or facet is of EVENT precedence.
*/
@Deprecated
void removeFacet(@Nullable Facet facet);

}
Loading
Loading