glassfish
  1. glassfish
  2. GLASSFISH-18379

Use JSR 330 annotations in GlassFish Connectors

    Details

    • Type: Task Task
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: jca
    • Labels:
      None

      Description

      GlassFish modules should move away from using non standard Classes like Habitat and use standards based annotations and classes as specified by jsr 330(javax.inject.Inject, javax.inject.Provider etc.). To quote Jerome: "Classes like Habitat exposes too many APIs available to the users that makes the hk2 evolution very difficult. " Also some of the APIs are unclear (when to use habitat.getComponent() versus habitat.getByType() /habitat.getByContract() ).

      So, the first step is to move away from Habitat (where ever possible) and use jsr 330 interface and annotations.

      In order to do this, the hk2 team will be making the following changes to the GlassFish modules.

      1. Move away from org.jvnet.hk2.annotations.Inject to javax.inject.Inject

      1.1 We will convert

      @org.jvnet.hk2.annotations.Inject Foo foo

      to

      @javax.inject.Inject 
      Foo foo;

      1.2 We will convert

      @org.jvnet.hk2.annotations.Inject(name="foo") Foo foo

      to

      @javax.inject.Inject
      @javax.inject.Named("foo")
      Foo foo;

      1.3 We will convert

      @org.jvnet.hk2.annotations.Inject(optional=true) Foo foo

      to

      @javax.inject.Inject
      @org.jvnet.hk2.annotations.Optional
      Foo foo;

      1.4 We will convert

      @org.jvnet.hk2.annotations.Inject(name="foo", option=true) Foo foo

      to

      @javax.inject.Inject
      @javax.inject.Named("foo")
      @org.jvnet.hk2.annotations.Optional
      Foo foo;

      2. If we find that a class injects Habitat (or Services) and uses

      habitat.getByContract(Foo.class)

      or

      service.forContract(Foo.class).get()

      then we will do the following:

      2.1 Introduce a new injection:

      @javax.inject.Inject
      javax.inject.Provider<Foo>  fooProvider;

      2.2 replace the getBycontract() / forContract() calls with:

      fooProvider.get();

      3. If we find that a class...

      a) implements PostConstruct,
      b) injects Habitat (or Services) and
      c) uses habitat.getByContract(Foo.class) or services.forContract(Foo.class).get() in the postConstruct method,

      ...then we will do the following:

      3.1 replace the getBycontract() / forConttract() calls with:

      @javax.inject.Inject Foo foo;

      3.2 Obviously, we will talk to the module owner to find out why the injection was not made in the first place.

        Activity

        tbeerbower created issue -
        tbeerbower made changes -
        Field Original Value New Value
        Status Open [ 1 ] In Progress [ 3 ]
        Hide
        tbeerbower added a comment -

        Submitted revision 52634 ...

        M appserver/connectors/connectors-connector/src/main/java/com/sun/enterprise/connectors/connector/module/ConnectorSniffer.java
        M appserver/connectors/connectors-connector/src/main/java/com/sun/enterprise/connectors/connector/module/RarDetector.java
        M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/ConnectorConnectionPoolManager.java
        M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/ListConnectorWorkSecurityMaps.java
        M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/DeleteAdminObject.java
        M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/CreateAdminObject.java
        M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/CreateConnectorSecurityMap.java
        M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/ListResources.java
        M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/PingConnectionPool.java
        M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/CreateConnectorWorkSecurityMap.java
        M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/ListConnectorResources.java
        M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/UpdateConnectorSecurityMap.java
        M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/ListConnectorConnectionPools.java
        M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/UpdateConnectorWorkSecurityMap.java
        M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/ConnectionPoolUtil.java
        M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/FlushConnectionPool.java
        M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/internal/GetMessageListenerTypes.java
        M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/internal/GetConnectionDefinitionPropertiesAndDefaults.java
        M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/internal/GetActivationSpecClass.java
        M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/internal/GetAdminObjectInterfaceNames.java
        M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/internal/GetMCFConfigProperties.java
        M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/internal/GetSystemRarsAllowingPoolCreation.java
        M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/internal/GetAdminObjectClassNames.java
        M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/internal/GetAdminObjectConfigProps.java
        M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/internal/GetMessageListenerConfigPropertyTypes.java
        M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/internal/GetConnectorConfigJavaBeans.java
        M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/internal/GetResourceAdapterConfigProperties.java
        M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/internal/GetBuiltInCustomResources.java
        M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/internal/GetConnectionDefinitionNames.java
        M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/internal/GetMessageListenerConfigProperties.java
        M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/ListConnectorSecurityMaps.java
        M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/DeleteResourceAdapterConfig.java
        M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/CreateResourceAdapterConfig.java
        M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/DeleteConnectorSecurityMap.java
        M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/DeleteConnectorWorkSecurityMap.java
        M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/AdminObjectManager.java
        M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/DeleteConnectorResource.java
        M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/CreateConnectorResource.java
        M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/DeleteConnectorConnectionPool.java
        M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/CreateConnectorConnectionPool.java
        M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/ListResourceAdapterConfigs.java
        M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/ConnectorResourceManager.java
        M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/ListAdminObjects.java
        M appserver/connectors/connectors-inbound-runtime/src/main/java/com/sun/enterprise/connectors/inbound/InboundRecoveryHandler.java
        M appserver/connectors/connectors-inbound-runtime/src/main/java/com/sun/enterprise/connectors/inbound/ConnectorMessageBeanClientFactory.java
        M appserver/connectors/work-management/src/main/java/com/sun/enterprise/connectors/work/context/WorkContextHandler.java
        M appserver/connectors/work-management/src/main/java/com/sun/enterprise/connectors/work/WorkManagerFactory.java
        M appserver/connectors/connectors-internal-api/src/main/java/com/sun/appserv/connectors/internal/ConnectorResourceManagerLifecycleListener.java
        M appserver/connectors/connectors-internal-api/src/main/java/com/sun/appserv/connectors/internal/api/ConnectorsClassLoaderUtil.java
        M appserver/connectors/connectors-internal-api/src/main/java/com/sun/appserv/connectors/internal/api/ConnectorClassLoaderServiceImpl.java
        M appserver/connectors/connectors-internal-api/src/main/java/com/sun/appserv/connectors/internal/api/ConnectorDescriptorProxy.java
        M appserver/connectors/connectors-internal-api/src/main/java/com/sun/appserv/connectors/internal/api/AppSpecificConnectorClassLoaderUtil.java
        M appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/deployer/JdbcConnectionPoolDeployer.java
        M appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/deployer/ResourceAdapterConfigDeployer.java
        M appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/deployer/ConnectorResourceDeployer.java
        M appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/deployer/DataSourceDefinitionDeployer.java
        M appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/deployer/ConnectorConnectionPoolDeployer.java
        M appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/deployer/AdminObjectResourceDeployer.java
        M appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/deployer/JdbcResourceDeployer.java
        M appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/recovery/ThirdPartyRecoveryResourceHandler.java
        M appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/recovery/ConnectorsRecoveryResourceHandler.java
        M appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/recovery/JdbcRecoveryResourceHandler.java
        M appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/pool/monitor/PoolMonitoringLevelListener.java
        M appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/pool/monitor/ConnectionPoolStatsProviderBootstrap.java
        M appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/pool/monitor/ConnectionPoolProbeProviderUtil.java
        M appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/pool/PoolManagerImpl.java
        M appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/connectors/deployment/util/ConnectorArchivist.java
        M appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/connectors/ActiveOutboundResourceAdapter.java
        M appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/connectors/module/RarHandler.java
        M appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/connectors/module/ConnectorDeployer.java
        M appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/connectors/ActiveRAFactory.java
        M appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/connectors/ConnectorRuntime.java

        Show
        tbeerbower added a comment - Submitted revision 52634 ... M appserver/connectors/connectors-connector/src/main/java/com/sun/enterprise/connectors/connector/module/ConnectorSniffer.java M appserver/connectors/connectors-connector/src/main/java/com/sun/enterprise/connectors/connector/module/RarDetector.java M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/ConnectorConnectionPoolManager.java M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/ListConnectorWorkSecurityMaps.java M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/DeleteAdminObject.java M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/CreateAdminObject.java M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/CreateConnectorSecurityMap.java M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/ListResources.java M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/PingConnectionPool.java M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/CreateConnectorWorkSecurityMap.java M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/ListConnectorResources.java M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/UpdateConnectorSecurityMap.java M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/ListConnectorConnectionPools.java M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/UpdateConnectorWorkSecurityMap.java M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/ConnectionPoolUtil.java M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/FlushConnectionPool.java M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/internal/GetMessageListenerTypes.java M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/internal/GetConnectionDefinitionPropertiesAndDefaults.java M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/internal/GetActivationSpecClass.java M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/internal/GetAdminObjectInterfaceNames.java M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/internal/GetMCFConfigProperties.java M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/internal/GetSystemRarsAllowingPoolCreation.java M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/internal/GetAdminObjectClassNames.java M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/internal/GetAdminObjectConfigProps.java M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/internal/GetMessageListenerConfigPropertyTypes.java M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/internal/GetConnectorConfigJavaBeans.java M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/internal/GetResourceAdapterConfigProperties.java M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/internal/GetBuiltInCustomResources.java M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/internal/GetConnectionDefinitionNames.java M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/internal/GetMessageListenerConfigProperties.java M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/ListConnectorSecurityMaps.java M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/DeleteResourceAdapterConfig.java M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/CreateResourceAdapterConfig.java M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/DeleteConnectorSecurityMap.java M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/DeleteConnectorWorkSecurityMap.java M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/AdminObjectManager.java M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/DeleteConnectorResource.java M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/CreateConnectorResource.java M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/DeleteConnectorConnectionPool.java M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/CreateConnectorConnectionPool.java M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/ListResourceAdapterConfigs.java M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/ConnectorResourceManager.java M appserver/connectors/admin/src/main/java/org/glassfish/connectors/admin/cli/ListAdminObjects.java M appserver/connectors/connectors-inbound-runtime/src/main/java/com/sun/enterprise/connectors/inbound/InboundRecoveryHandler.java M appserver/connectors/connectors-inbound-runtime/src/main/java/com/sun/enterprise/connectors/inbound/ConnectorMessageBeanClientFactory.java M appserver/connectors/work-management/src/main/java/com/sun/enterprise/connectors/work/context/WorkContextHandler.java M appserver/connectors/work-management/src/main/java/com/sun/enterprise/connectors/work/WorkManagerFactory.java M appserver/connectors/connectors-internal-api/src/main/java/com/sun/appserv/connectors/internal/ConnectorResourceManagerLifecycleListener.java M appserver/connectors/connectors-internal-api/src/main/java/com/sun/appserv/connectors/internal/api/ConnectorsClassLoaderUtil.java M appserver/connectors/connectors-internal-api/src/main/java/com/sun/appserv/connectors/internal/api/ConnectorClassLoaderServiceImpl.java M appserver/connectors/connectors-internal-api/src/main/java/com/sun/appserv/connectors/internal/api/ConnectorDescriptorProxy.java M appserver/connectors/connectors-internal-api/src/main/java/com/sun/appserv/connectors/internal/api/AppSpecificConnectorClassLoaderUtil.java M appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/deployer/JdbcConnectionPoolDeployer.java M appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/deployer/ResourceAdapterConfigDeployer.java M appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/deployer/ConnectorResourceDeployer.java M appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/deployer/DataSourceDefinitionDeployer.java M appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/deployer/ConnectorConnectionPoolDeployer.java M appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/deployer/AdminObjectResourceDeployer.java M appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/deployer/JdbcResourceDeployer.java M appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/recovery/ThirdPartyRecoveryResourceHandler.java M appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/recovery/ConnectorsRecoveryResourceHandler.java M appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/recovery/JdbcRecoveryResourceHandler.java M appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/pool/monitor/PoolMonitoringLevelListener.java M appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/pool/monitor/ConnectionPoolStatsProviderBootstrap.java M appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/pool/monitor/ConnectionPoolProbeProviderUtil.java M appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/pool/PoolManagerImpl.java M appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/connectors/deployment/util/ConnectorArchivist.java M appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/connectors/ActiveOutboundResourceAdapter.java M appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/connectors/module/RarHandler.java M appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/connectors/module/ConnectorDeployer.java M appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/connectors/ActiveRAFactory.java M appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/connectors/ConnectorRuntime.java
        Hide
        tbeerbower added a comment -

        The above replaces all usages of

        org.jvnet.hk2.annotations.Inject 

        with

        javax.inject.Inject 

        The following remaining usages of Habitat need to be looked at ...

        1) com.sun.appserv.connectors.internal.ConnectorResourceManagerLifecycleListener

        @Inject
        private Habitat connectorRuntimeHabitat;
        ...
        Collection<Inhabitant<? extends ConnectorRuntime>> inhabitants =
            connectorRuntimeHabitat.getInhabitants(ConnectorRuntime.class);
        

        2) com.sun.enterprise.connectors.ActiveRAFactory

        use of

        habitat.getAllByContract(...)

        3) com.sun.enterprise.connectors.module.ConnectorDeployer

        habitat injection occurs in super class JavaEEDeployer defined in another module

        4) com.sun.enterprise.resource.naming.ConnectorNamingUtils

        habitat acquired through …

        Habitat habitat = Globals.getStaticHabitat()
        

        5) Tests

        habitat acquired through Utils.getHabitat();

        Show
        tbeerbower added a comment - The above replaces all usages of org.jvnet.hk2.annotations.Inject with javax.inject.Inject The following remaining usages of Habitat need to be looked at ... 1) com.sun.appserv.connectors.internal.ConnectorResourceManagerLifecycleListener @Inject private Habitat connectorRuntimeHabitat; ... Collection<Inhabitant<? extends ConnectorRuntime>> inhabitants = connectorRuntimeHabitat.getInhabitants(ConnectorRuntime.class); 2) com.sun.enterprise.connectors.ActiveRAFactory use of habitat.getAllByContract(...) 3) com.sun.enterprise.connectors.module.ConnectorDeployer habitat injection occurs in super class JavaEEDeployer defined in another module 4) com.sun.enterprise.resource.naming.ConnectorNamingUtils habitat acquired through … Habitat habitat = Globals.getStaticHabitat() 5) Tests habitat acquired through Utils.getHabitat();
        Hide
        tbeerbower added a comment -

        Passes quicklook tests and Connector devtests. Approved by Jagadish.

        Show
        tbeerbower added a comment - Passes quicklook tests and Connector devtests. Approved by Jagadish.
        Tom Mueller made changes -
        Assignee tbeerbower [ tbeerbower ] jwells [ jwells ]
        Hide
        jwells added a comment -

        Fixed since July 2012

        Show
        jwells added a comment - Fixed since July 2012
        jwells made changes -
        Status In Progress [ 3 ] Closed [ 6 ]
        Resolution Fixed [ 1 ]

          People

          • Assignee:
            jwells
            Reporter:
            tbeerbower
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: