adutra commented on code in PR #2434: URL: https://github.com/apache/polaris/pull/2434#discussion_r2301468051
########## runtime/service/src/main/java/org/apache/polaris/service/admin/EventsServiceDelegator.java: ########## @@ -0,0 +1,36 @@ +/* + * 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.polaris.service.admin; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import jakarta.inject.Qualifier; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +// Used to annotate delegator classes, which are emitting events Review Comment: ```suggestion /** Used to annotate delegator classes, which are emitting events. */ ``` ########## runtime/service/src/main/java/org/apache/polaris/service/admin/PolarisServiceImpl.java: ########## @@ -89,6 +89,7 @@ /** Concrete implementation of the Polaris API services */ @RequestScoped +@MainService Review Comment: This may not be necessary anymore when using proper interfaces and `@Decorator` / `@Delegate`. ########## runtime/service/src/main/java/org/apache/polaris/service/admin/PolarisCatalogsServiceDefaultDelegator.java: ########## @@ -0,0 +1,181 @@ +/* + * 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.polaris.service.admin; + +import jakarta.annotation.Priority; +import jakarta.enterprise.context.RequestScoped; +import jakarta.enterprise.inject.Alternative; +import jakarta.enterprise.inject.Default; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.SecurityContext; +import org.apache.polaris.core.admin.model.AddGrantRequest; +import org.apache.polaris.core.admin.model.CreateCatalogRequest; +import org.apache.polaris.core.admin.model.CreateCatalogRoleRequest; +import org.apache.polaris.core.admin.model.RevokeGrantRequest; +import org.apache.polaris.core.admin.model.UpdateCatalogRequest; +import org.apache.polaris.core.admin.model.UpdateCatalogRoleRequest; +import org.apache.polaris.core.context.RealmContext; +import org.apache.polaris.service.admin.api.PolarisCatalogsApiService; + +@RequestScoped +@Default +@EventsServiceDelegator +@Alternative +@Priority(1000) // Will allow downstream project-specific delegators to be added and used +public class PolarisCatalogsServiceDefaultDelegator implements PolarisCatalogsApiService { + private final PolarisCatalogsApiService delegate; + + public PolarisCatalogsServiceDefaultDelegator(@MainService PolarisCatalogsApiService delegate) { + this.delegate = delegate; + } + + /** From PolarisCatalogsApiService */ Review Comment: nit: do we need these dummy javadocs? ########## runtime/service/src/main/java/org/apache/polaris/service/admin/PolarisPrincipalRolesServiceDefaultDelegator.java: ########## @@ -0,0 +1,132 @@ +/* + * 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.polaris.service.admin; + +import jakarta.annotation.Priority; +import jakarta.enterprise.context.RequestScoped; +import jakarta.enterprise.inject.Alternative; +import jakarta.enterprise.inject.Default; +import jakarta.inject.Inject; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.SecurityContext; +import org.apache.polaris.core.admin.model.CreatePrincipalRoleRequest; +import org.apache.polaris.core.admin.model.GrantCatalogRoleRequest; +import org.apache.polaris.core.admin.model.UpdatePrincipalRoleRequest; +import org.apache.polaris.core.context.RealmContext; +import org.apache.polaris.service.admin.api.PolarisPrincipalRolesApiService; + +@RequestScoped +@Default +@EventsServiceDelegator +@Alternative +@Priority(1000) // Will allow downstream project-specific delegators to be added and used +public class PolarisPrincipalRolesServiceDefaultDelegator Review Comment: nit: the naming convention is a bit odd, I'd expect the decorator to be named `<DelegateName>EventServiceDelegator` or something like that. ########## runtime/service/src/main/java/org/apache/polaris/service/admin/PolarisCatalogsServiceDefaultDelegator.java: ########## @@ -0,0 +1,181 @@ +/* + * 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.polaris.service.admin; + +import jakarta.annotation.Priority; +import jakarta.enterprise.context.RequestScoped; +import jakarta.enterprise.inject.Alternative; +import jakarta.enterprise.inject.Default; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.SecurityContext; +import org.apache.polaris.core.admin.model.AddGrantRequest; +import org.apache.polaris.core.admin.model.CreateCatalogRequest; +import org.apache.polaris.core.admin.model.CreateCatalogRoleRequest; +import org.apache.polaris.core.admin.model.RevokeGrantRequest; +import org.apache.polaris.core.admin.model.UpdateCatalogRequest; +import org.apache.polaris.core.admin.model.UpdateCatalogRoleRequest; +import org.apache.polaris.core.context.RealmContext; +import org.apache.polaris.service.admin.api.PolarisCatalogsApiService; + +@RequestScoped +@Default +@EventsServiceDelegator +@Alternative +@Priority(1000) // Will allow downstream project-specific delegators to be added and used +public class PolarisCatalogsServiceDefaultDelegator implements PolarisCatalogsApiService { Review Comment: I like the general direction we are taking in this PR, but wanted to mention that this CDI pattern has dedicated annotations: `@Decorator` and `@Delegate`. It's explained here: - https://quarkus.io/guides/cdi#decorators - https://jakarta.ee/specifications/cdi/3.0/jakarta-cdi-spec-3.0#decorator_bean However, these annotations require both decorator and delegate beans to implement one common interface. This might not be possible for beans like `IcebergCatalogAdapter` since it's not an interface. We'd need to extract an interface from it in order to make the Decorator CDI pattern work. Here, it could look like this: ```java @RequestScoped @Default @EventsServiceDelegator @Decorator @Priority(1000) // Will allow downstream project-specific delegators to be added and used public class PolarisCatalogsServiceDefaultDelegator implements PolarisCatalogsApiService { private final PolarisCatalogsApiService delegate; @Inject public PolarisCatalogsServiceDefaultDelegator(@Delegate @MainService PolarisCatalogsApiService delegate) { this.delegate = delegate; } ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@polaris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org