Skip to content

Commit

Permalink
refactor: use annotations instead of XML for metatype
Browse files Browse the repository at this point in the history
  • Loading branch information
joe-chacko committed Oct 30, 2024
1 parent 4b85680 commit cc5aace
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,4 @@
* </li>
* </ol>
*/
public interface ApplicationPrereq {
}
public interface ApplicationPrereq {}
3 changes: 3 additions & 0 deletions dev/com.ibm.ws.jndi.iiop/bnd.bnd
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Include-Resource: OSGI-INF=resources/OSGI-INF
IBM-Default-Config: OSGI-INF/wlp/defaultInstances.xml

-dsannotations: com.ibm.ws.jndi.iiop.*UrlContextFactory
-metatypeannotations: com.ibm.ws.jndi.iiop.*UrlContextFactory*

instrument.classesExcludes: com/ibm/ws/jndi/iiop/*.class

Expand All @@ -51,6 +52,8 @@ instrument.classesExcludes: com/ibm/ws/jndi/iiop/*.class
com.ibm.ws.org.apache.yoko.rmi.spec.1.5;version=latest,\
com.ibm.websphere.org.osgi.core;version=latest,\
com.ibm.wsspi.org.osgi.service.component.annotations;version=latest,\
com.ibm.wsspi.org.osgi.service.metatype.annotations;version=latest, \
com.ibm.ws.bnd.annotations;version=latest, \
com.ibm.websphere.appserver.spi.logging;version=latest,\
com.ibm.ws.app.manager.lifecycle;version=latest,\
com.ibm.ws.container.service;version=latest,\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
-->
<metatype:MetaData xmlns:metatype="http://www.osgi.org/xmlns/metatype/v1.1.0"
xmlns:ibm="http://www.ibm.com/xmlns/appservers/osgi/metatype/v1.0.0"
xmlns:ibmui="http://www.ibm.com/xmlns/appservers/osgi/metatype/ui/v1.0.0"
localization="OSGI-INF/l10n/metatype">
xmlns:ibmui="http://www.ibm.com/xmlns/appservers/osgi/metatype/ui/v1.0.0">

<Designate pid="com.ibm.ws.jndi.iiop.CorbanameUrlContextFactory">
<Object ocdref="com.ibm.ws.jndi.iiop.CorbanameUrlContextFactory" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,25 @@
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.metatype.annotations.AttributeDefinition;
import org.osgi.service.metatype.annotations.Designate;
import org.osgi.service.metatype.annotations.ObjectClassDefinition;

import com.ibm.ws.bnd.metatype.annotation.Ext;
import com.ibm.ws.transport.iiop.spi.ClientORBRef;
import com.ibm.wsspi.application.lifecycle.ApplicationPrereq;
import com.ibm.wsspi.application.lifecycle.ApplicationRecycleComponent;

@Component(configurationPolicy=REQUIRE,property={"service.vendor=ibm","osgi.jndi.url.scheme=corbaloc"})
public class CorbalocUrlContextFactory extends UrlContextFactory implements ObjectFactory, ApplicationRecycleComponent, ApplicationPrereq {
@ObjectClassDefinition(name = "internal", description = "internal use only")
@Ext.ObjectClass(ApplicationPrereq.OBJECT_CLASS)
@interface CorbalocUrlContextFactoryConfig {
@AttributeDefinition(name = "internal", description = "internal use only")
String id();
}

@Component(configurationPolicy = REQUIRE, property = "osgi.jndi.url.scheme=corbaloc")
@Designate(ocd = CorbalocUrlContextFactoryConfig.class)
public class CorbalocUrlContextFactory extends UrlContextFactory implements ObjectFactory, ApplicationRecycleComponent, ApplicationPrereq {
@Activate
public CorbalocUrlContextFactory(@Reference ClientORBRef orbRef) {
super(orbRef);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,24 @@
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.metatype.annotations.AttributeDefinition;
import org.osgi.service.metatype.annotations.Designate;
import org.osgi.service.metatype.annotations.ObjectClassDefinition;

import com.ibm.ws.bnd.metatype.annotation.Ext;
import com.ibm.ws.transport.iiop.spi.ClientORBRef;
import com.ibm.wsspi.application.lifecycle.ApplicationPrereq;
import com.ibm.wsspi.application.lifecycle.ApplicationRecycleComponent;

@Component(configurationPolicy=REQUIRE,property={"service.vendor=ibm","osgi.jndi.url.scheme=corbaname"})
@ObjectClassDefinition(name = "internal", description = "internal use only")
@Ext.ObjectClassClass(ApplicationPrereq.class)
@interface CorbanameUrlContextFactoryConfig {
@AttributeDefinition(name = "internal", description = "internal use only")
String id();
}

@Component(configurationPolicy = REQUIRE, property = "osgi.jndi.url.scheme=corbaname")
@Designate(ocd = CorbanameUrlContextFactoryConfig.class)
public class CorbanameUrlContextFactory extends UrlContextFactory implements ObjectFactory, ApplicationRecycleComponent, ApplicationPrereq {
@Activate
public CorbanameUrlContextFactory(@Reference ClientORBRef orbRef) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,24 @@
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.metatype.annotations.AttributeDefinition;
import org.osgi.service.metatype.annotations.Designate;
import org.osgi.service.metatype.annotations.ObjectClassDefinition;

import com.ibm.ws.bnd.metatype.annotation.Ext;
import com.ibm.ws.transport.iiop.spi.ClientORBRef;
import com.ibm.wsspi.application.lifecycle.ApplicationPrereq;
import com.ibm.wsspi.application.lifecycle.ApplicationRecycleComponent;

@Component(configurationPolicy=REQUIRE,property={"service.vendor=ibm","osgi.jndi.url.scheme=ior"})
@ObjectClassDefinition(name = "internal", description = "internal use only")
@Ext.ObjectClassClass(ApplicationPrereq.class)
@interface IorUrlContextFactoryConfig {
@AttributeDefinition(name = "internal", description = "internal use only", required = true)
String id();
}

@Component(configurationPolicy = REQUIRE, property = "osgi.jndi.url.scheme=ior")
@Designate(ocd = IorUrlContextFactoryConfig.class)
public class IorUrlContextFactory extends UrlContextFactory implements ObjectFactory, ApplicationRecycleComponent, ApplicationPrereq {
@Activate
public IorUrlContextFactory(@Reference ClientORBRef orbRef) {
Expand Down

0 comments on commit cc5aace

Please sign in to comment.