AEM 6.5 Custom OSGI Config is not visible

Avatar

Avatar

florind

Avatar

florind

florind

07-01-2020

Hey guys,

I am using AEM 6.5 and I've deployed a custom OSGI service config. I was expecting to find the config under http://localhost:4502/system/console/configMgr

Here is my Service. 

MyService.java

public interface MyService {

    /**
     * This method returns the entered password into a hash equivalent with some
     * properties passed by the user
     *
     * @Param type
     * @Return {@link String}
     */
    String getPassword(String type);
}


MyServiceImpl.java

 

@Component(service = MyService.class,
property = {
"label=My Service Implementation"
}
)
@Designate(ocd = MyConfiguration.class)
public class MyServiceImpl implements MyService {

private final Logger log = LoggerFactory.getLogger(this.getClass());

// Two properties to be read
private String propertyOne;
private String propertyTwo;

@Activate
protected void activate(MyConfiguration config) {
// Reading properties from the configuration
propertyOne = config.getPropertyOne();
propertyTwo = config.getPropertyTwo();

}

@Override
public String getPassword(String type) {

// MD5 equivalent of password string
String passwordHash = null;

try {

type = type + propertyOne + propertyTwo;

log.info("Resulant password: " + type);

// Convert string to bytes - this is for the sample implementation (for show casing)
byte[] passwordByte = type.getBytes("UTF-8");

// Getting instance of MessageDigest
MessageDigest md = MessageDigest.getInstance("MD5");

// Convert bytes array to hash using MD5 algorithm
byte[] digest = md.digest(passwordByte);

passwordHash = new String(digest);

} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}

return passwordHash;
}

}



MyConfiguration.java

import org.osgi.service.metatype.annotations.AttributeDefinition;
import org.osgi.service.metatype.annotations.AttributeType;
import org.osgi.service.metatype.annotations.ObjectClassDefinition;

@ObjectClassDefinition(name = "My Configuration",
description = "This configuration will be used to read the value of properties.")
public @interface MyConfiguration {

@AttributeDefinition(name = "Property One", description = "Read property one", type = AttributeType.STRING)
public String getPropertyOne() default "Property One";

@AttributeDefinition(name = "Property Two", description = "Read property two", type = AttributeType.STRING)
public String getPropertyTwo() default "Property Two";
}

 

aem6.5 bundle not visible osgi

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

Arun_Patidar

MVP

Total Posts

(val/1000)?string[".0"]}K

Likes

958

Correct Answer

820

Avatar

Arun_Patidar

MVP

Total Posts

(val/1000)?string[".0"]}K

Likes

958

Correct Answer

820
Arun_Patidar
MVP

07-01-2020

Hi,

Could you please check if your bundle is active or not? Code looks fine, could be issue with imports.

I have a sample code you can refer just to cross check in case you missed something

https://github.com/arunpatidar02/aem63app-repo/tree/master/java/page/json/com/acc/aem64/core/service...

 

Answers (0)