本文整理匯總了Java中org.apache.felix.scr.annotations.Properties類的典型用法代碼示例。如果您正苦於以下問題:Java Properties類的具體用法?Java Properties怎麽用?Java Properties使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Properties類屬於org.apache.felix.scr.annotations包,在下文中一共展示了Properties類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: active
import org.apache.felix.scr.annotations.Properties; //導入依賴的package包/類
@Activate
public void active() throws IOException {
gav2isPluginFile = repository.getRootDir().resolve("gav2isPlugin.properties");
if (Files.exists(gav2isPluginFile)) {
java.util.Properties properties = new java.util.Properties();
try (Reader reader = new InputStreamReader(Files.newInputStream(gav2isPluginFile), "UTF-8")) {
properties.load(reader);
}
properties.forEach((k, v) -> gav2isPlugin.put(String.valueOf(k), Boolean.valueOf(String.valueOf(v))));
} else {
PathUtils.tryMkdirsParent(gav2isPluginFile);
saveGav2isPlugin();
}
}
示例2: saveGav2isPlugin
import org.apache.felix.scr.annotations.Properties; //導入依賴的package包/類
private void saveGav2isPlugin() {
synchronized (gav2isPluginFile) {
java.util.Properties properties = new java.util.Properties();
gav2isPlugin.forEach((k, v) -> properties.put(k, String.valueOf(v)));
try (Writer writer = new OutputStreamWriter(Files.newOutputStream(gav2isPluginFile), "UTF-8")) {
properties.store(writer, "org.to2mbn.lolixl.plugin.impl.gav2isPlugin");
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
}
示例3: addSubjects
import org.apache.felix.scr.annotations.Properties; //導入依賴的package包/類
/**
* Add dc:subject property to items pointing to entities extracted by NLP
* engines in the default chain. Given a node and a TripleCollection
* containing fise:Enhancements about that node dc:subject properties are
* added to an item pointing to entities referenced by those enhancements if
* the enhancement confidence value is above a threshold.
*
* @param node
* @param metadata
*/
private void addSubjects(MGraph targetGraph, UriRef itemRef, TripleCollection metadata) {
final GraphNode enhancementType = new GraphNode(TechnicalClasses.ENHANCER_ENHANCEMENT, metadata);
final Set<UriRef> entities = new HashSet<UriRef>();
// get all the enhancements
final Iterator<GraphNode> enhancements = enhancementType.getSubjectNodes(RDF.type);
while (enhancements.hasNext()) {
final GraphNode enhhancement = enhancements.next();
final Iterator<Literal> confidenceLiterals = enhhancement.getLiterals(org.apache.stanbol.enhancer.servicesapi.rdf.Properties.ENHANCER_CONFIDENCE);
//look the confidence value for each enhancement
double enhancementConfidence = confidenceLiterals.hasNext() ?
LiteralFactory.getInstance().createObject(Double.class,
(TypedLiteral) confidenceLiterals.next()) : 1;
if (enhancementConfidence >= confidenceThreshold) {
// get entities referenced in the enhancement
final Iterator<Resource> referencedEntities = enhhancement.getObjects(org.apache.stanbol.enhancer.servicesapi.rdf.Properties.ENHANCER_ENTITY_REFERENCE);
while (referencedEntities.hasNext()) {
final UriRef entity = (UriRef) referencedEntities.next();
// Add dc:subject to the patent for each referenced entity
targetGraph.add(new TripleImpl(itemRef, DC.subject, entity));
entities.add(entity);
}
}
}
for (UriRef uriRef : entities) {
// We don't get the entity description directly from metadata
// as the context there would include
addResourceDescription(uriRef, targetGraph);
}
}
示例4: sendMail
import org.apache.felix.scr.annotations.Properties; //導入依賴的package包/類
/**
* Send an email.
*
* @param recipient The recipient of the email
* @param subject The subject of the email.
* @param body The body of the email.
* @return true if the email was sent successfully.
*/
public boolean sendMail(final String recipient, final String subject, final String body) {
boolean result = false;
// Create a Properties object to contain connection configuration information.
java.util.Properties props = System.getProperties();
props.put("mail.transport.protocol", "smtp");
props.put("mail.smtp.port", getPort());
// Set properties indicating that we want to use STARTTLS to encrypt the connection.
// The SMTP session will begin on an unencrypted connection, and then the client
// will issue a STARTTLS command to upgrade to an encrypted connection.
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.starttls.required", "true");
// Create a Session object to represent a mail session with the specified properties.
Session session = Session.getDefaultInstance(props);
// Create a message with the specified information.
MimeMessage msg = new MimeMessage(session);
Transport transport = null;
// Send the message.
try {
msg.setFrom(new InternetAddress(getSender()));
msg.setRecipient(Message.RecipientType.TO, new InternetAddress(recipient));
msg.setSubject(subject);
msg.setContent(body, "text/plain");
// Create a transport.
transport = session.getTransport();
// Connect to email server using the SMTP username and password you specified above.
transport.connect(getHost(), getSmtpUsername(), getUnobfuscatedSmtpPassword());
// Send the email.
transport.sendMessage(msg, msg.getAllRecipients());
result = true;
} catch (Exception ex) {
LOGGER.error("The email was not sent.", ex);
} finally {
// Close and terminate the connection.
try {
transport.close();
} catch (MessagingException e) {
LOGGER.error("Could not close transport", e);
}
}
return result;
}